Form form = readFormData(message);
String assertionType = form.getData().getFirst(Constants.CLIENT_AUTH_ASSERTION_TYPE);
String decodedAssertionType = assertionType != null ? HttpUtils.urlDecode(assertionType) : null;
if (decodedAssertionType == null || !Constants.CLIENT_AUTH_SAML2_BEARER.equals(decodedAssertionType)) {
throw new NotAuthorizedException(errorResponse());
}
String assertion = form.getData().getFirst(Constants.CLIENT_AUTH_ASSERTION_PARAM);
Element token = readToken(message, assertion);
String clientId = form.getData().getFirst(OAuthConstants.CLIENT_ID);
validateToken(message, token, clientId);
form.getData().remove(OAuthConstants.CLIENT_ID);
form.getData().remove(Constants.CLIENT_AUTH_ASSERTION_PARAM);
form.getData().remove(Constants.CLIENT_AUTH_ASSERTION_TYPE);
// restore input stream
try {
FormUtils.restoreForm(provider, form, message);
} catch (Exception ex) {
throw new NotAuthorizedException(errorResponse());
}
return null;
}