Examples of TokenStore


Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

        updateAddressPort(port, PORT);
       
        port.doubleIt(25);

        Client client = ClientProxy.getClient(port);
        TokenStore tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // We expect 1 token
        assertEquals(tokenStore.getTokenIdentifiers().size(), 1);
       
        // Second invocation
        port = service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        port.doubleIt(35);

        client = ClientProxy.getClient(port);
        tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // There should now be 2 tokens as both proxies share the same TokenStore
        assertEquals(tokenStore.getTokenIdentifiers().size(), 2);
       
        ((java.io.Closeable)port).close();
        bus.shutdown(true);
    }
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

        );
       
        port.doubleIt(25);

        Client client = ClientProxy.getClient(port);
        TokenStore tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // We expect 1 token
        assertEquals(tokenStore.getTokenIdentifiers().size(), 1);
       
        // Second invocation
        port = service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        ((BindingProvider)port).getRequestContext().put(
            SecurityConstants.CACHE_IDENTIFIER, "proxy2"
        );
        ((BindingProvider)port).getRequestContext().put(
            SecurityConstants.CACHE_CONFIG_FILE, "client/per-proxy-cache.xml"
        );
       
        port.doubleIt(35);

        client = ClientProxy.getClient(port);
        tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // We expect 1 token
        assertEquals(tokenStore.getTokenIdentifiers().size(), 1);
       
        ((java.io.Closeable)port).close();
        bus.shutdown(true);
    }
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

        Client client = ClientProxy.getClient(transportSaml2Port);
        Endpoint ep = client.getEndpoint();
        String id = "1234";
        ep.getEndpointInfo().setProperty(TokenStore.class.getName(), new MemoryTokenStore());
        ep.getEndpointInfo().setProperty(SecurityConstants.TOKEN_ID, id);
        TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());

        SAMLParms samlParms = new SAMLParms();
        samlParms.setCallbackHandler(new Saml2CallbackHandler());
        AssertionWrapper assertion = new AssertionWrapper(samlParms);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Element assertionElement = assertion.toDOM(db.newDocument());
       
        SecurityToken tok = new SecurityToken(id);
        tok.setTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        tok.setToken(assertionElement);
        store.add(tok);
       
        doubleIt(transportSaml2Port, 50);
       
        ((java.io.Closeable)transportSaml2Port).close();
        bus.shutdown(true);
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

    }
   
    protected final TokenStore getTokenStore() {
        EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
        synchronized (info) {
            TokenStore tokenStore = (TokenStore)message.getContextualProperty(TokenStore.class.getName());
            if (tokenStore == null) {
                tokenStore = (TokenStore)info.getProperty(TokenStore.class.getName());
            }
            if (tokenStore == null) {
                tokenStore = new MemoryTokenStore();
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

    }

    protected TokenStore getTokenStore(SoapMessage message) {
        EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
        synchronized (info) {
            TokenStore tokenStore =
                (TokenStore)message.getContextualProperty(TokenStore.class.getName());
            if (tokenStore == null) {
                tokenStore = (TokenStore)info.getProperty(TokenStore.class.getName());
            }
            return tokenStore;
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

    }
   
    static final TokenStore createTokenStore(Message message) {
        EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
        synchronized (info) {
            TokenStore tokenStore = (TokenStore)message.getContextualProperty(TokenStore.class.getName());
            if (tokenStore == null) {
                tokenStore = (TokenStore)info.getProperty(TokenStore.class.getName());
            }
            if (tokenStore == null) {
                tokenStore = new MemoryTokenStore();
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

            }
            return tokenStore;
        }
    }
    static final TokenStore getTokenStore(Message message) {
        TokenStore tokenStore = (TokenStore)message.getContextualProperty(TokenStore.class.getName());
        if (tokenStore == null) {
            tokenStore = createTokenStore(message);
        }
        return tokenStore;
    }
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

            Element onBehalfOfToken,
            Element actAsToken,
            String appliesTo,
            boolean enableAppliesTo
        ) throws Exception {
            TokenStore tokenStore = getTokenStore(message);
            String key = appliesTo;
            if (!enableAppliesTo || key == null || "".equals(key)) {
                key = ASSOCIATED_TOKEN;
            }
            // See if the token corresponding to the OnBehalfOf Token is stored in the cache
            // and if it points to an issued token
            if (onBehalfOfToken != null) {
                String id = getIdFromToken(onBehalfOfToken);
                SecurityToken cachedToken = tokenStore.getToken(id);
                if (cachedToken != null) {
                    Properties properties = cachedToken.getProperties();
                    if (properties != null && properties.containsKey(key)) {
                        String associatedToken = properties.getProperty(key);
                        SecurityToken issuedToken = tokenStore.getToken(associatedToken);
                        if (issuedToken != null) {
                            return issuedToken;
                        }
                    }
                }
            }
           
            // See if the token corresponding to the ActAs Token is stored in the cache
            // and if it points to an issued token
            if (actAsToken != null) {
                String id = getIdFromToken(actAsToken);
                SecurityToken cachedToken = tokenStore.getToken(id);
                if (cachedToken != null) {
                    Properties properties = cachedToken.getProperties();
                    if (properties != null && properties.containsKey(key)) {
                        String associatedToken = properties.getProperty(key);
                        SecurityToken issuedToken = tokenStore.getToken(associatedToken);
                        if (issuedToken != null) {
                            return issuedToken;
                        }
                    }
                }
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

            boolean enableAppliesTo
        ) throws Exception {
            if (issuedToken == null) {
                return;
            }
            TokenStore tokenStore = getTokenStore(message);
            String key = appliesTo;
            if (!enableAppliesTo || key == null || "".equals(key)) {
                key = ASSOCIATED_TOKEN;
            }
            if (onBehalfOfToken != null) {
                String id = getIdFromToken(onBehalfOfToken);
                SecurityToken cachedToken = tokenStore.getToken(id);
                if (cachedToken == null) {
                    cachedToken = new SecurityToken(id);
                    cachedToken.setToken(onBehalfOfToken);
                }
                Properties properties = cachedToken.getProperties();
                if (properties == null) {
                    properties = new Properties();
                    cachedToken.setProperties(properties);
                }
                properties.put(key, issuedToken.getId());
                tokenStore.add(cachedToken);
            }
            if (actAsToken != null) {
                String id = getIdFromToken(actAsToken);
                SecurityToken cachedToken = tokenStore.getToken(id);
                if (cachedToken == null) {
                    cachedToken = new SecurityToken(id);
                    cachedToken.setToken(actAsToken);
                }
                Properties properties = cachedToken.getProperties();
                if (properties == null) {
                    properties = new Properties();
                    cachedToken.setProperties(properties);
                }
                properties.put(key, issuedToken.getId());
                tokenStore.add(cachedToken);
            }
        }
View Full Code Here

Examples of org.apache.cxf.ws.security.tokenstore.TokenStore

   
   
    static final TokenStore getTokenStore(Message message) {
        EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
        synchronized (info) {
            TokenStore tokenStore = (TokenStore)message.getContextualProperty(TokenStore.class.getName());
            if (tokenStore == null) {
                tokenStore = (TokenStore)info.getProperty(TokenStore.class.getName());
            }
            if (tokenStore == null) {
                tokenStore = new MemoryTokenStore();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.