use of org.apache.cxf.sts.token.provider.TokenProvider in project OpenAM by OpenRock.
the class TokenIssueOperationProvider method get.
public IssueOperation get() {
//TODO: migrate to throwing providers
try {
TokenIssueOperation tokenIssueOperation = new TokenIssueOperation();
/*
The STS will not encrypt the issued tokens - the TokenGenerationService already offers functionality to
encrypt issued SAML assertions.
*/
tokenIssueOperation.setEncryptIssuedToken(false);
tokenIssueOperation.setStsProperties(stsPropertiesMBean);
tokenIssueOperation.setTokenStore(tokenStore);
/*
Set the tokenValidators which will be called to validate the tokens presented as ActAs or OnBehalfOf
elements
*/
tokenIssueOperation.setTokenValidators(getDelegationTokenValidators());
/*
Set the TokenDelegationHandlers (either empty if this sts instance will not process ActAs or OnBehalfOf elements,
or with the DefaultTokenDelegationHandler, or with user-specified custom handlers.
*/
tokenIssueOperation.setDelegationHandlers(tokenDelegationHandlers);
List<TokenProvider> tokenProviders = new ArrayList<TokenProvider>();
for (TokenType tokenType : issueTokenTypes) {
tokenProviders.add(operationFactory.getTokenProvider(tokenType));
}
tokenIssueOperation.setTokenProviders(tokenProviders);
return new TokenIssueOperationWrapper(tokenIssueOperation, threadLocalAMTokenCache);
} catch (STSInitializationException e) {
logger.error("Exception caught initializing a IssueOperation: " + e, e);
throw new RuntimeException(e);
}
}
use of org.apache.cxf.sts.token.provider.TokenProvider in project OpenAM by OpenRock.
the class TokenIssueOperationProviderTest method testExceptionInitialization.
@Test(expectedExceptions = RuntimeException.class)
public void testExceptionInitialization() throws STSInitializationException {
TokenOperationFactory mockOperationFactory = mock(TokenOperationFactory.class);
TokenProvider mockProvider = mock(TokenProvider.class);
when(mockOperationFactory.getTokenProvider(any(TokenType.class))).thenThrow(STSInitializationException.class);
TokenIssueOperationProvider issueOperationProvider = Guice.createInjector(new MyModule(mockOperationFactory)).getInstance(TokenIssueOperationProvider.class);
issueOperationProvider.get();
}
use of org.apache.cxf.sts.token.provider.TokenProvider in project OpenAM by OpenRock.
the class TokenIssueOperationProviderTest method testDelegate.
@Test
public void testDelegate() throws STSInitializationException {
TokenOperationFactory mockOperationFactory = mock(TokenOperationFactory.class);
TokenProvider mockProvider = mock(TokenProvider.class);
when(mockOperationFactory.getTokenProvider(any(TokenType.class))).thenReturn(mockProvider);
TokenIssueOperationProvider issueOperationProvider = Guice.createInjector(new MyModule(mockOperationFactory)).getInstance(TokenIssueOperationProvider.class);
assertTrue(issueOperationProvider.get() instanceof TokenIssueOperationProvider.TokenIssueOperationWrapper);
}
Aggregations