use of org.wso2.carbon.identity.oauth2.model.RequestParameter in project carbon-apimgt by wso2.
the class SystemScopesIssuer method getSignedJWT.
/**
* Method to parse the assertion and retrieve the signed JWT
*
* @param tokReqMsgCtx request
* @return SignedJWT object
* @throws IdentityOAuth2Exception exception thrown due to a parsing error
*/
private SignedJWT getSignedJWT(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
RequestParameter[] params = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getRequestParameters();
String assertion = null;
SignedJWT signedJWT;
for (RequestParameter param : params) {
if (param.getKey().equals(APIConstants.SystemScopeConstants.OAUTH_JWT_ASSERTION)) {
assertion = param.getValue()[0];
break;
}
}
if (StringUtils.isEmpty(assertion)) {
String errorMessage = "Error while retrieving assertion";
throw new IdentityOAuth2Exception(errorMessage);
}
try {
signedJWT = SignedJWT.parse(assertion);
if (log.isDebugEnabled()) {
log.debug(signedJWT);
}
} catch (ParseException e) {
String errorMessage = "Error while parsing the JWT.";
throw new IdentityOAuth2Exception(errorMessage, e);
}
return signedJWT;
}
Aggregations