Extract Variable Pattern to Header with Multi value

Hi All , 

I have to extract one header value inside API proxy . 

Example: 

Header name = cert_app 

Header Value1   cn=api.google.com,org=google,type=search,reg=us

Header Value2  org=google,cn=api.google.com,type=search,reg=us

Header Value3  org=google,type=search,reg=us,cn=api.google.com,

I have to extract cn=api.google.com from the header value to a variable . Basically this can come at start ,end or in between of the string which is separated by comma.

Appreciate suggestion on this.

 

Best Regards,

Patty

0 2 152
2 REPLIES 2

You could probably use some javascript to either build an array of key/value pairs from the header value, and then look at the value of the cn entry.

Or use match() with a suitable regex? Something like cn=[a-zA-Z0-9.]*

It's not clear to me exactly what you are looking to do. What are the distinguished names (DNs) sent via http headers representative of? An LDAP object? A certificate subject? Something else?

How do you plan to use the common name (CN) values you extracted? Will this be for strict authorization purposes?

Do you know every potential value that be passed?

You should review RFC 4514 (https://www.ietf.org/rfc/rfc4514.txt) as there are likely considerations you may need to make.

If you have strict requirements and you need a complete solution, you'll likely end up using Java library.

If not, then you might get away with simply splitting the string into an array and performing string matching, as Dane has mentioned in the other comment.