use of org.apache.cxf.sts.token.delegation.TokenDelegationResponse in project OpenAM by OpenRock.
the class DefaultTokenDelegationHandler method isDelegationAllowed.
@Override
public TokenDelegationResponse isDelegationAllowed(TokenDelegationParameters tokenParameters) {
final TokenDelegationResponse tokenDelegationResponse = new TokenDelegationResponse();
tokenDelegationResponse.setDelegationAllowed(tokenParameters.getTokenPrincipal() != null);
return tokenDelegationResponse;
}
use of org.apache.cxf.sts.token.delegation.TokenDelegationResponse in project OpenAM by OpenRock.
the class CustomDelegationHandlerWrapper method isDelegationAllowed.
@Override
public TokenDelegationResponse isDelegationAllowed(TokenDelegationParameters tokenParameters) {
final TokenDelegationResponse tokenDelegationResponse = customHandler.isDelegationAllowed(tokenParameters);
if (tokenDelegationResponse.isDelegationAllowed()) {
final Map<String, Object> additionalProperties = tokenDelegationResponse.getAdditionalProperties();
if ((additionalProperties != null) && additionalProperties.get(AMSTSConstants.CUSTOM_DELEGATION_HANDLER_AM_SESSION_ID) instanceof String) {
boolean invalidateInterimSession = true;
Object invalidateSessionObject = additionalProperties.get(AMSTSConstants.CUSTOM_DELEGATION_HANDLER_INVALIDATE_AM_SESSION);
if (invalidateSessionObject instanceof Boolean) {
invalidateInterimSession = (Boolean) invalidateSessionObject;
}
try {
threadLocalAMTokenCache.cacheSessionIdForContext(ValidationInvocationContext.SOAP_TOKEN_DELEGATION, (String) additionalProperties.get(AMSTSConstants.CUSTOM_DELEGATION_HANDLER_AM_SESSION_ID), invalidateInterimSession);
} catch (TokenValidationException e) {
throw new AMSTSRuntimeException(e.getCode(), e.getMessage(), e);
}
} else {
if (!delegationValidatorsSpecified) {
String message = "In a custom TokenDelegationHandler, the delegated token is allowed, no delegation " + "validators have been specified, and the AM Session Id was not specified in the " + "DelegationHandlerResponse#getAdditionalProperties keyed by " + AMSTSConstants.CUSTOM_DELEGATION_HANDLER_AM_SESSION_ID + ". This means the " + "TokenGenerationService cannot issue an assertion corresponding to the delegated token.";
logger.error(message);
throw new AMSTSRuntimeException(ResourceException.UNAVAILABLE, message);
}
}
}
return tokenDelegationResponse;
}
use of org.apache.cxf.sts.token.delegation.TokenDelegationResponse in project ddf by codice.
the class BSTDelegationHandler method isDelegationAllowed.
public TokenDelegationResponse isDelegationAllowed(TokenDelegationParameters tokenParameters) {
TokenDelegationResponse response = new TokenDelegationResponse();
ReceivedToken delegateTarget = tokenParameters.getToken();
response.setToken(delegateTarget);
Object token = delegateTarget.getToken();
if (token instanceof BinarySecurityTokenType) {
response.setDelegationAllowed(true);
}
return response;
}
use of org.apache.cxf.sts.token.delegation.TokenDelegationResponse in project ddf by codice.
the class TestBSTDelegationHandler method testDelegationNotAllowed.
@Test
public void testDelegationNotAllowed() {
UsernameTokenType binarySecurityTokenType = new UsernameTokenType();
ReceivedToken receivedToken = mock(ReceivedToken.class);
when(receivedToken.getToken()).thenReturn(binarySecurityTokenType);
TokenDelegationParameters tokenDelegationParameters = mock(TokenDelegationParameters.class);
when(tokenDelegationParameters.getToken()).thenReturn(receivedToken);
BSTDelegationHandler bstDelegationHandler = new BSTDelegationHandler();
TokenDelegationResponse response = bstDelegationHandler.isDelegationAllowed(tokenDelegationParameters);
assertEquals(false, response.isDelegationAllowed());
}
use of org.apache.cxf.sts.token.delegation.TokenDelegationResponse in project ddf by codice.
the class X509DelegationHandler method isDelegationAllowed.
public TokenDelegationResponse isDelegationAllowed(TokenDelegationParameters tokenParameters) {
TokenDelegationResponse response = new TokenDelegationResponse();
ReceivedToken delegateTarget = tokenParameters.getToken();
response.setToken(delegateTarget);
Object token = delegateTarget.getToken();
if (token instanceof BinarySecurityTokenType) {
response.setDelegationAllowed(true);
}
return response;
}
Aggregations