Search in sources :

Example 46 with TokenProviderParameters

use of org.apache.cxf.sts.token.provider.TokenProviderParameters in project cxf by apache.

the class ValidateJWTTransformationTest method createProviderParameters.

private TokenProviderParameters createProviderParameters(String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler) throws WSSecurityException {
    TokenProviderParameters parameters = new TokenProviderParameters();
    TokenRequirements tokenRequirements = new TokenRequirements();
    tokenRequirements.setTokenType(tokenType);
    parameters.setTokenRequirements(tokenRequirements);
    KeyRequirements keyRequirements = new KeyRequirements();
    keyRequirements.setKeyType(keyType);
    parameters.setKeyRequirements(keyRequirements);
    parameters.setPrincipal(new CustomTokenPrincipal("alice"));
    // Mock up message context
    MessageImpl msg = new MessageImpl();
    WrappedMessageContext msgCtx = new WrappedMessageContext(msg);
    parameters.setMessageContext(msgCtx);
    parameters.setAppliesToAddress("http://dummy-service.com/dummy");
    // Add STSProperties object
    StaticSTSProperties stsProperties = new StaticSTSProperties();
    stsProperties.setSignatureCrypto(crypto);
    stsProperties.setSignatureUsername(signatureUsername);
    stsProperties.setCallbackHandler(callbackHandler);
    stsProperties.setIssuer("STS");
    parameters.setStsProperties(stsProperties);
    parameters.setEncryptionProperties(new EncryptionProperties());
    return parameters;
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) TokenRequirements(org.apache.cxf.sts.request.TokenRequirements) WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) EncryptionProperties(org.apache.cxf.sts.service.EncryptionProperties) KeyRequirements(org.apache.cxf.sts.request.KeyRequirements) StaticSTSProperties(org.apache.cxf.sts.StaticSTSProperties) MessageImpl(org.apache.cxf.message.MessageImpl) TokenProviderParameters(org.apache.cxf.sts.token.provider.TokenProviderParameters)

Example 47 with TokenProviderParameters

use of org.apache.cxf.sts.token.provider.TokenProviderParameters in project cxf by apache.

the class ValidateJWTUnitTest method createJWT.

private TokenProviderResponse createJWT() throws WSSecurityException {
    TokenProvider tokenProvider = new JWTTokenProvider();
    TokenProviderParameters providerParameters = createProviderParameters(JWTTokenProvider.JWT_TOKEN_TYPE);
    assertTrue(tokenProvider.canHandleToken(JWTTokenProvider.JWT_TOKEN_TYPE));
    TokenProviderResponse providerResponse = tokenProvider.createToken(providerParameters);
    assertTrue(providerResponse != null);
    assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId() != null);
    return providerResponse;
}
Also used : TokenProvider(org.apache.cxf.sts.token.provider.TokenProvider) JWTTokenProvider(org.apache.cxf.sts.token.provider.jwt.JWTTokenProvider) TokenProviderResponse(org.apache.cxf.sts.token.provider.TokenProviderResponse) JWTTokenProvider(org.apache.cxf.sts.token.provider.jwt.JWTTokenProvider) TokenProviderParameters(org.apache.cxf.sts.token.provider.TokenProviderParameters)

Example 48 with TokenProviderParameters

use of org.apache.cxf.sts.token.provider.TokenProviderParameters in project cxf by apache.

the class ValidateSCTUnitTest method createSCT.

private TokenProviderResponse createSCT() throws WSSecurityException {
    TokenProvider sctTokenProvider = new SCTProvider();
    TokenProviderParameters providerParameters = createProviderParameters(STSUtils.TOKEN_TYPE_SCT_05_12);
    assertTrue(sctTokenProvider.canHandleToken(STSUtils.TOKEN_TYPE_SCT_05_12));
    TokenProviderResponse providerResponse = sctTokenProvider.createToken(providerParameters);
    assertTrue(providerResponse != null);
    assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId() != null);
    return providerResponse;
}
Also used : TokenProvider(org.apache.cxf.sts.token.provider.TokenProvider) SCTProvider(org.apache.cxf.sts.token.provider.SCTProvider) TokenProviderResponse(org.apache.cxf.sts.token.provider.TokenProviderResponse) TokenProviderParameters(org.apache.cxf.sts.token.provider.TokenProviderParameters)

Example 49 with TokenProviderParameters

use of org.apache.cxf.sts.token.provider.TokenProviderParameters in project cxf by apache.

the class SCTCancellerTest method createProviderParameters.

private TokenProviderParameters createProviderParameters(String tokenType) throws WSSecurityException {
    TokenProviderParameters parameters = new TokenProviderParameters();
    TokenRequirements tokenRequirements = new TokenRequirements();
    tokenRequirements.setTokenType(tokenType);
    parameters.setTokenRequirements(tokenRequirements);
    KeyRequirements keyRequirements = new KeyRequirements();
    parameters.setKeyRequirements(keyRequirements);
    parameters.setTokenStore(tokenStore);
    parameters.setPrincipal(new CustomTokenPrincipal("alice"));
    // Mock up message context
    MessageImpl msg = new MessageImpl();
    WrappedMessageContext msgCtx = new WrappedMessageContext(msg);
    parameters.setMessageContext(msgCtx);
    parameters.setAppliesToAddress("http://dummy-service.com/dummy");
    // Add STSProperties object
    StaticSTSProperties stsProperties = new StaticSTSProperties();
    Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties());
    stsProperties.setSignatureCrypto(crypto);
    stsProperties.setSignatureUsername("mystskey");
    stsProperties.setCallbackHandler(new PasswordCallbackHandler());
    stsProperties.setIssuer("STS");
    parameters.setStsProperties(stsProperties);
    parameters.setEncryptionProperties(new EncryptionProperties());
    return parameters;
}
Also used : CustomTokenPrincipal(org.apache.wss4j.common.principal.CustomTokenPrincipal) Crypto(org.apache.wss4j.common.crypto.Crypto) TokenRequirements(org.apache.cxf.sts.request.TokenRequirements) WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) PasswordCallbackHandler(org.apache.cxf.sts.common.PasswordCallbackHandler) EncryptionProperties(org.apache.cxf.sts.service.EncryptionProperties) KeyRequirements(org.apache.cxf.sts.request.KeyRequirements) StaticSTSProperties(org.apache.cxf.sts.StaticSTSProperties) MessageImpl(org.apache.cxf.message.MessageImpl) TokenProviderParameters(org.apache.cxf.sts.token.provider.TokenProviderParameters)

Example 50 with TokenProviderParameters

use of org.apache.cxf.sts.token.provider.TokenProviderParameters in project cxf by apache.

the class SCTCancellerTest method getSecurityContextToken.

private TokenProviderResponse getSecurityContextToken() throws Exception {
    TokenProvider sctTokenProvider = new SCTProvider();
    TokenProviderParameters providerParameters = createProviderParameters(STSUtils.TOKEN_TYPE_SCT_05_12);
    return sctTokenProvider.createToken(providerParameters);
}
Also used : TokenProvider(org.apache.cxf.sts.token.provider.TokenProvider) SCTProvider(org.apache.cxf.sts.token.provider.SCTProvider) TokenProviderParameters(org.apache.cxf.sts.token.provider.TokenProviderParameters)

Aggregations

TokenProviderParameters (org.apache.cxf.sts.token.provider.TokenProviderParameters)73 TokenRequirements (org.apache.cxf.sts.request.TokenRequirements)39 TokenProviderResponse (org.apache.cxf.sts.token.provider.TokenProviderResponse)35 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)32 KeyRequirements (org.apache.cxf.sts.request.KeyRequirements)28 EncryptionProperties (org.apache.cxf.sts.service.EncryptionProperties)28 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)26 MessageImpl (org.apache.cxf.message.MessageImpl)26 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)26 Element (org.w3c.dom.Element)23 SAMLTokenProvider (org.apache.cxf.sts.token.provider.SAMLTokenProvider)22 TokenProvider (org.apache.cxf.sts.token.provider.TokenProvider)21 ReceivedToken (org.apache.cxf.sts.request.ReceivedToken)14 PasswordCallbackHandler (org.apache.cxf.sts.common.PasswordCallbackHandler)12 Crypto (org.apache.wss4j.common.crypto.Crypto)12 JWTTokenProvider (org.apache.cxf.sts.token.provider.jwt.JWTTokenProvider)10 JAXBElement (javax.xml.bind.JAXBElement)9 ArrayList (java.util.ArrayList)7 Claim (org.apache.cxf.rt.security.claims.Claim)7 ClaimCollection (org.apache.cxf.rt.security.claims.ClaimCollection)7