Package org.apache.cxf.ws.security.trust

Examples of org.apache.cxf.ws.security.trust.STSClient


                        if (tokId != null) {
                            tok = getTokenStore(message).getToken(tokId);
                        }
                    }
                    if (tok == null) {
                        STSClient client = getClient(message);
                        AddressingProperties maps =
                            (AddressingProperties)message
                                .get("javax.xml.ws.addressing.context.outbound");
                        if (maps == null) {
                            maps = (AddressingProperties)message
                                .get("javax.xml.ws.addressing.context");
                        }
                        synchronized (client) {
                            try {
                                client.setTrust(getTrust10(aim));
                                client.setTrust(getTrust13(aim));
                                client.setTemplate(itok.getRstTemplate());
                                if (maps == null) {
                                    tok = client.requestSecurityToken();
                                } else {
                                    String s = message
                                        .getContextualProperty(Message.ENDPOINT_ADDRESS).toString();
                                    client.setAddressingNamespace(maps.getNamespaceURI());
                                    tok = client.requestSecurityToken(s);
                                }
                            } catch (RuntimeException e) {
                                throw e;
                            } catch (Exception e) {
                                throw new Fault(e);
                            } finally {
                                client.setTrust((Trust10)null);
                                client.setTrust((Trust13)null);
                                client.setTemplate(null);
                                client.setAddressingNamespace(null);
                            }
                        }
                    } else {
                        //renew token?
                    }
View Full Code Here


                if (isRequestor(message)) {
                    IssuedToken itok = (IssuedToken)ais.iterator().next().getAssertion();
                   
                    SecurityToken tok = retrieveCachedToken(message);
                    if (tok == null) {
                        STSClient client = STSUtils.getClient(message, "sts", itok);
                        AddressingProperties maps =
                            (AddressingProperties)message
                                .get("javax.xml.ws.addressing.context.outbound");
                        if (maps == null) {
                            maps = (AddressingProperties)message
                                .get("javax.xml.ws.addressing.context");
                        }
                        synchronized (client) {
                            try {
                                // Transpose ActAs/OnBehalfOf info from original request to the STS client.
                                Object token =
                                    message.getContextualProperty(SecurityConstants.STS_TOKEN_ACT_AS);
                                if (token != null) {
                                    client.setActAs(token);
                                }
                                token =
                                    message.getContextualProperty(SecurityConstants.STS_TOKEN_ON_BEHALF_OF);
                                if (token != null) {
                                    client.setOnBehalfOf(token);
                                }
                                Map<String, Object> ctx = client.getRequestContext();
                                mapSecurityProps(message, ctx);
                           
                                Object o = message.getContextualProperty(SecurityConstants.STS_APPLIES_TO);
                                String appliesTo = o == null ? null : o.toString();
                                appliesTo = appliesTo == null
                                    ? message.getContextualProperty(Message.ENDPOINT_ADDRESS).toString()
                                        : appliesTo;
                                boolean enableAppliesTo = client.isEnableAppliesTo();
                               
                                client.setMessage(message);
                                Element onBehalfOfToken = client.getOnBehalfOfToken();
                                Element actAsToken = client.getActAsToken();
                               
                                SecurityToken secToken =
                                    handleDelegation(
                                        message, onBehalfOfToken, actAsToken, appliesTo, enableAppliesTo
                                    );
                                if (secToken == null) {
                                    secToken = getTokenFromSTS(message, client, aim, maps, itok, appliesTo);
                                }
                                tok = secToken;
                                storeDelegationTokens(
                                    message, tok, onBehalfOfToken, actAsToken, appliesTo, enableAppliesTo
                                );
                            } catch (RuntimeException e) {
                                throw e;
                            } catch (Exception e) {
                                throw new Fault(e);
                            } finally {
                                client.setTrust((Trust10)null);
                                client.setTrust((Trust13)null);
                                client.setTemplate(null);
                                client.setAddressingNamespace(null);
                            }
                        }
                    } else {
                        tok = renewToken(message, aim, itok, tok);
                    }
View Full Code Here

       
        samlPort.doubleIt(25);
    }
   
    private static void updateSTSPort(BindingProvider p, String port) {
        STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
        if (stsClient != null) {
            String location = stsClient.getWsdlLocation();
            if (location.contains("8080")) {
                stsClient.setWsdlLocation(location.replace("8080", port));
            } else if (location.contains("8443")) {
                stsClient.setWsdlLocation(location.replace("8443", port));
            }
        }
    }
View Full Code Here

       
        // Now sleep to expire the token
        Thread.sleep(8 * 1000);
       
        BindingProvider p = (BindingProvider)transportPort;
        STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
        stsClient.setTtl(300);
       
        // The IssuedTokenInterceptorProvider should renew the token
        doubleIt(transportPort, 30);
    }
View Full Code Here

       
        // Now sleep to expire the token
        Thread.sleep(8 * 1000);
       
        BindingProvider p = (BindingProvider)transportPort;
        STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
        stsClient.setTtl(300);
       
        try {
            // The IssuedTokenInterceptorProvider should renew the token - but it should fail on
            // lack of Proof-of-Possession
            doubleIt(transportPort, 30);
View Full Code Here

       
        // Now sleep to expire the token
        Thread.sleep(8 * 1000);
       
        BindingProvider p = (BindingProvider)transportPort;
        STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
        stsClient.setTtl(300);
       
        // The IssuedTokenInterceptorProvider should renew the token
        doubleIt(transportPort, 30);
    }
View Full Code Here

            "ws-security.username", "alice"
        );
        doubleIt(bearerPort, 25);
       
        // Change the STSClient so that it can no longer find the STS
        STSClient stsClient = new STSClient(bus);
        stsClient.setOnBehalfOf(new WSSUsernameCallbackHandler());
        BindingProvider p = (BindingProvider)bearerPort;
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
       
        // This invocation should be successful as the token is cached
        doubleIt(bearerPort, 25);
       
        //
        // Proxy no. 2
        //
        DoubleItPortType bearerPort2 =
            service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(bearerPort2, PORT);
        if (standalone) {
            TokenTestUtils.updateSTSPort((BindingProvider)bearerPort2, STSPORT2);
        }
       
        // Change the STSClient so that it can no longer find the STS
        stsClient = new STSClient(bus);
        stsClient.setOnBehalfOf(new WSSUsernameCallbackHandler());
        p = (BindingProvider)bearerPort2;
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
       
        // This should fail as the cache is not being used
        try {
View Full Code Here

        } catch (Exception ex) {
            //
        }
       
        // Change the STSClient so that it can no longer find the STS
        STSClient stsClient = new STSClient(bus);
        stsClient.setOnBehalfOf(new WSSUsernameCallbackHandler());
        BindingProvider p = (BindingProvider)bearerPort;
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
       
        // Make a successful invocation
        ((BindingProvider)bearerPort).getRequestContext().put(
View Full Code Here

            "http://localhost:" + PORT + "/doubleit/services/doubleitasymmetricnew2"
        );
        doubleIt(bearerPort, 25);
       
        // Change the STSClient so that it can no longer find the STS
        STSClient stsClient = new STSClient(bus);
        stsClient.setOnBehalfOf(new WSSUsernameCallbackHandler());
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
       
        // Make a successful invocation - should work as token is cached
        ((BindingProvider)bearerPort).getRequestContext().put(
            "ws-security.username", "alice"
View Full Code Here

        ((BindingProvider)bearerPort).getRequestContext().put(
            "ws-security.username", "alice"
        );
        // Disable appliesTo
        BindingProvider p = (BindingProvider)bearerPort;
        STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
        stsClient.setEnableAppliesTo(false);
        doubleIt(bearerPort, 25);
       
        // Change the STSClient so that it can no longer find the STS
        stsClient = new STSClient(bus);
        stsClient.setOnBehalfOf(new WSSUsernameCallbackHandler());
        stsClient.setEnableAppliesTo(false);
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
       
        // This should work
        doubleIt(bearerPort, 25);
       
View Full Code Here

TOP

Related Classes of org.apache.cxf.ws.security.trust.STSClient

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.