I have decoded a JWT token which has a specific claim - {jwt.ContextToken.claim.appctxsender}However I need to use part of this string - the format or the claim string is abcdefghiljk@123456677 - how would I use the characters after the @ symbol in another policy. In javascript it would be myclaim.split("@")[1], but how do I do this in the Apigee XML?
You can use extract variable policy like
abcdefghiljk@{variable_value}. You can set this in header or query param before this policy and then extract.
But I would suggest python script for this as that is the simplest of all.
You can use the Extract Variables policy on variables, in this case the variable is a query param named splitme, but it could be any variable. I think this is pretty simple and will be more efficient than using Python in this simple use case.
<ExtractVariables name="EV-split-queryparam"> <DisplayName>EV-split-queryparam</DisplayName> <Variable name="request.queryparam.splitme"> <Pattern>abcdefghiljk@{split_value}</Pattern> </Variable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </ExtractVariables>
Thanks both- but if I did not know the
abcdefghiljk part before the "@" symbol how would I handle it? e.g. *@{split_value} - a wildcard
You can use multiple variable assignments in the Pattern expression:
<ExtractVariables name="EV-split-queryparam"> <DisplayName>EV-split-queryparam</DisplayName> <Variable name="request.queryparam.splitme"> <Pattern>{prefix_value}@{suffix_value}</Pattern> </Variable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </ExtractVariables>
Great thanks - I will try this