Package org.apache.cxf.sts.token.provider

Examples of org.apache.cxf.sts.token.provider.SAMLTokenProvider


    public void testIssueSaml1TokenRealmA() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        SAMLTokenProvider provider = new SAMLTokenProvider();
        provider.setRealmMap(createRealms());
        providerList.add(provider);
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
View Full Code Here


    public void testIssueSaml1TokenRealmB() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        SAMLTokenProvider provider = new SAMLTokenProvider();
        provider.setRealmMap(createRealms());
        providerList.add(provider);
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
View Full Code Here

    public void testIssueSaml1TokenDefaultRealm() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        SAMLTokenProvider provider = new SAMLTokenProvider();
        provider.setRealmMap(createRealms());
        providerList.add(provider);
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
View Full Code Here

    }
   
    private Element createSAMLAssertion(
        String tokenType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler
    ) throws WSSecurityException {
        TokenProvider samlTokenProvider = new SAMLTokenProvider();
        TokenProviderParameters providerParameters =
            createProviderParameters(
                tokenType, STSConstants.BEARER_KEY_KEYTYPE, crypto, signatureUsername, callbackHandler
            );
        TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
        assertTrue(providerResponse != null);
        assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId() != null);
       
        return providerResponse.getToken();
    }
View Full Code Here

        validatorList.add(new UsernameTokenValidator());
        validateOperation.setTokenValidators(validatorList);

        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        providerList.add(new SAMLTokenProvider());
        validateOperation.setTokenProviders(providerList);
       
        // Add STSProperties object
        STSPropertiesMBean stsProperties = new StaticSTSProperties();
        Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties());
View Full Code Here

        validatorList.add(validator);
        validateOperation.setTokenValidators(validatorList);

        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        SAMLTokenProvider samlTokenProvider = new SAMLTokenProvider();
        providerList.add(samlTokenProvider);
        validateOperation.setTokenProviders(providerList);
       
        // Add STSProperties object
        STSPropertiesMBean stsProperties = new StaticSTSProperties();
        Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties());
        stsProperties.setEncryptionCrypto(crypto);
        stsProperties.setSignatureCrypto(crypto);
        stsProperties.setEncryptionUsername("myservicekey");
        stsProperties.setSignatureUsername("mystskey");
        stsProperties.setCallbackHandler(new PasswordCallbackHandler());
        stsProperties.setIssuer("STS");
        stsProperties.setRealmParser(new CustomRealmParser());
        stsProperties.setIdentityMapper(new CustomIdentityMapper());
        validateOperation.setStsProperties(stsProperties);
       
        // Mock up a request
        RequestSecurityTokenType request = new RequestSecurityTokenType();
        JAXBElement<String> tokenType =
            new JAXBElement<String>(
                QNameConstants.TOKEN_TYPE, String.class, WSConstants.WSS_SAML2_TOKEN_TYPE
            );
        request.getAny().add(tokenType);
       
        // Create a UsernameToken
        JAXBElement<UsernameTokenType> usernameTokenType = createUsernameToken("alice", "clarinet");
        ValidateTargetType validateTarget = new ValidateTargetType();
        validateTarget.setAny(usernameTokenType);
       
        JAXBElement<ValidateTargetType> validateTargetType =
            new JAXBElement<ValidateTargetType>(
                QNameConstants.VALIDATE_TARGET, ValidateTargetType.class, validateTarget
            );
        request.getAny().add(validateTargetType);
       
        // Mock up message context
        MessageImpl msg = new MessageImpl();
        WrappedMessageContext msgCtx = new WrappedMessageContext(msg);
        msgCtx.put(
            SecurityContext.class.getName(),
            createSecurityContext(new CustomTokenPrincipal("alice"))
        );
        msgCtx.put("url", "https");
        WebServiceContextImpl webServiceContext = new WebServiceContextImpl(msgCtx);
       
        // Validate a token - this will fail as the tokenProvider doesn't understand how to handle
        // realm "B"
        try {
            validateOperation.validate(request, webServiceContext);
        } catch (STSException ex) {
            // expected
        }
       
        samlTokenProvider.setRealmMap(getSamlRealms());
        RequestSecurityTokenResponseType response = validateOperation.validate(request, webServiceContext);
        assertTrue(validateResponse(response));
       
        // Test the generated token.
        Element assertion = null;
View Full Code Here

    public void testIssueSaml1Token() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        providerList.add(new SAMLTokenProvider());
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
        service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
View Full Code Here

    public void testIssueSaml2Token() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        providerList.add(new SAMLTokenProvider());
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
        service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
View Full Code Here

    public void testIssueSaml2AppliesToURIToken() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        providerList.add(new SAMLTokenProvider());
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
        service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
View Full Code Here

    public void testIssueMultipleSamlTokens() throws Exception {
        TokenIssueOperation issueOperation = new TokenIssueOperation();
       
        // Add Token Provider
        List<TokenProvider> providerList = new ArrayList<TokenProvider>();
        providerList.add(new SAMLTokenProvider());
        issueOperation.setTokenProviders(providerList);
       
        // Add Service
        ServiceMBean service = new StaticService();
        service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy"));
View Full Code Here

TOP

Related Classes of org.apache.cxf.sts.token.provider.SAMLTokenProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.