use of org.apache.ws.security.message.token.BinarySecurity in project OpenAM by OpenRock.
the class OpenAMSessionTokenServerInterceptor method validateToken.
/**
* @param tokenElement the BinarySecurityToken representing the OpenAMSessionToken. The OpenAM session id is the text
* content of this Element.
* @return a List with a single WSSecurityEngineResult with information concerning the successful validation.
* @throws WSSecurityException if the OpenAM session cannot be validated successfully.
*/
private List<WSSecurityEngineResult> validateToken(Element tokenElement) throws WSSecurityException {
final boolean bspComliant = true;
final BinarySecurity bst = new BinarySecurity(tokenElement, bspComliant);
bst.setValueType(AMSTSConstants.AM_SESSION_TOKEN_ASSERTION_BST_VALUE_TYPE);
final X509Certificate[] certs = null;
WSSecurityEngineResult result = new WSSecurityEngineResult(WSConstants.BST, bst, certs);
try {
final String sessionId = tokenElement.getTextContent();
final Principal principal = principalFromSession.getPrincipalFromSession(sessionId);
//because we are dealing with an OpenAM session which was not created as part of TokenValidation, but
//rather pre-existed this validation, it should not be invalidated.
threadLocalAMTokenCache.cacheSessionIdForContext(ValidationInvocationContext.SOAP_SECURITY_POLICY, sessionId, false);
result.put(WSSecurityEngineResult.TAG_VALIDATED_TOKEN, Boolean.TRUE);
result.put(WSSecurityEngineResult.TAG_PRINCIPAL, principal);
} catch (TokenValidationException e) {
throw new WSSecurityException(e.getMessage(), e);
}
return Collections.singletonList(result);
}
Aggregations