Hi
I use SOA 12.2.1, in my scenario i need to generate many rest json web service throw oracle soa (i am not using osb), in my case i need to pass jwt token (http_jwt_token_service_policy) with any web service that i call, i add this policy to my rest web service as display in screen below. I generate java class to generate (code below) and then i use the out put token to test the web service, but every time return Unauthorized.
What i need to know is that correct to generate my own java class to generate jwt token? if not how can i create the token, and if yes how i fix Unauthorized call web service (in other way how soa know if token valid or not).
Many thanks

public static String jwtCreate(String username, int systemId, String userRole,
String secretKey) throws Exception {
try {
String result = null;
JwtToken jwtToken = new JwtToken();
//Fill in all the parameters- algorithm, issuer, expiry time, other claims etc
jwtToken.setAlgorithm(JwtToken.SIGN\_ALGORITHM.HS512.toString());
jwtToken.setType(JwtToken.JWT);
jwtToken.setClaimParameter("username", username);
jwtToken.setClaimParameter("systemId", systemId);
jwtToken.setClaimParameter("userRole", userRole);
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
jwtToken.setIssueTime(now);
// expiry = 8 \* 60 minutes
jwtToken.setExpiryTime(new Date(nowMillis + (8 \* 60) \* 60 \* 1000));
// Get the private key and sign the token with a secret key or a private key
result = jwtToken.signAndSerialize(secretKey.getBytes());
return result;
} catch (Exception e) {
return "";
}
}