Examples of STSClient


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

        Dispatch<DOMSource> dispatch =
            service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
        updateAddressPort(dispatch, test.getPort());
       
        // Setup STSClient
        STSClient stsClient = createDispatchSTSClient(bus);
        String wsdlLocation = "http://localhost:" + test.getStsPort() + "/SecurityTokenService/UT?wsdl";
        stsClient.setWsdlLocation(wsdlLocation);
       
        // Creating a DOMSource Object for the request
        DOMSource request = createDOMRequest();
       
        // Make a successful request
View Full Code Here

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

        Dispatch<DOMSource> dispatch =
            service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD, new AddressingFeature());
        updateAddressPort(dispatch, test.getPort());
       
        // Setup STSClient
        STSClient stsClient = createDispatchSTSClient(bus);
        String wsdlLocation = "http://localhost:" + test.getStsPort() + "/SecurityTokenService/UT?wsdl";
        stsClient.setWsdlLocation(wsdlLocation);
       
        // Creating a DOMSource Object for the request
        DOMSource request = createDOMRequest();
       
        // Make a successful request
View Full Code Here

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

        requestDoc.appendChild(root);
        return new DOMSource(requestDoc);
    }
   
    private STSClient createDispatchSTSClient(Bus bus) {
        STSClient stsClient = new STSClient(bus);
        stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
        stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UT_Port");
       
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("ws-security.username", "alice");
        properties.put("ws-security.callback-handler",
                       "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
        properties.put("ws-security.encryption.username", "mystskey");
        properties.put("ws-security.encryption.properties", "clientKeystore.properties");
        properties.put("ws-security.is-bsp-compliant", "false");
        stsClient.setProperties(properties);
       
        return stsClient;
    }
View Full Code Here

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

        Dispatch<DOMSource> dispatch =
            service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
        updateAddressPort(dispatch, test.getPort());
       
        // Setup STSClient
        STSClient stsClient = createDispatchSTSClient(bus);
        String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
        stsClient.setWsdlLocation(wsdlLocation);
       
        // Creating a DOMSource Object for the request
        DOMSource request = createDOMRequest();
       
        // Make a successful request
View Full Code Here

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

        Dispatch<DOMSource> dispatch =
            service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
        updateAddressPort(dispatch, test.getPort());
       
        // Setup STSClient
        STSClient stsClient = createDispatchSTSClient(bus);
        String location = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport";
        stsClient.setLocation(location);
        stsClient.setPolicy("classpath:/org/apache/cxf/systest/sts/issuer/sts-transport-policy.xml");
       
        // Creating a DOMSource Object for the request
        DOMSource request = createDOMRequest();
       
        // Make a successful request
View Full Code Here

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

        requestDoc.appendChild(root);
        return new DOMSource(requestDoc);
    }
   
    private STSClient createDispatchSTSClient(Bus bus) {
        STSClient stsClient = new STSClient(bus);
        stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
        stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port");
       
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("ws-security.username", "alice");
        properties.put("ws-security.callback-handler",
                       "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
        properties.put("ws-security.sts.token.username", "myclientkey");
        properties.put("ws-security.sts.token.properties", "clientKeystore.properties");
        properties.put("ws-security.sts.token.usecert", "true");
        stsClient.setProperties(properties);
       
        return stsClient;
    }
View Full Code Here

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

    }
   
    private SecurityToken requestSecurityToken(
        Bus bus, String wsdlLocation, boolean enableEntropy
    ) throws Exception {
        STSClient stsClient = new STSClient(bus);
        stsClient.setWsdlLocation(wsdlLocation);
        stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
        stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port");

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(SecurityConstants.USERNAME, "alice");
        properties.put(
            SecurityConstants.CALLBACK_HANDLER,
            "org.apache.cxf.systest.sts.common.CommonCallbackHandler"
        );
        properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "serviceKeystore.properties");

        stsClient.setProperties(properties);
        stsClient.setSecureConv(true);
        stsClient.setRequiresEntropy(enableEntropy);
        stsClient.setKeySize(128);
        stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");

        return stsClient.requestSecurityToken("http://localhost:8081/doubleit/services/doubleitsymmetric");
    }
View Full Code Here

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

            message.getExchange().remove(SecurityConstants.TOKEN);
            NegotiationUtils.getTokenStore(message).remove(tok.getId());
           
            // If the user has explicitly disabled Renewing then we can't renew a token,
            // so just get a new one
            STSClient client = STSUtils.getClient(message, "sts", itok);
            if (!client.isAllowRenewing()) {
                return issueToken(message, aim, 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 {
                    Map<String, Object> ctx = client.getRequestContext();
                    mapSecurityProps(message, ctx);
               
                    client.setMessage(message);

                    if (maps != null) {
                        client.setAddressingNamespace(maps.getNamespaceURI());
                    }
                   
                    client.setTrust(getTrust10(aim));
                    client.setTrust(getTrust13(aim));
                   
                    client.setTemplate(itok.getRequestSecurityTokenTemplate());
                    return client.renewSecurityToken(tok);
                } 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);
                }
            }
        }
View Full Code Here

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

        private SecurityToken issueToken(
             Message message,
             AssertionInfoMap aim,
             IssuedToken itok
        ) {
            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);
                    }
                    storeDelegationTokens(
                        message, secToken, onBehalfOfToken, actAsToken, appliesTo, enableAppliesTo
                    );
                    return secToken;
                } 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);
                }
            }
        }
View Full Code Here

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

                if (tokId != null) {
                    tok = NegotiationUtils.getTokenStore(m2).getToken(tokId);
                }
            }

            STSClient client = STSUtils.getClient(m2, "sct");
            AddressingProperties maps =
                (AddressingProperties)message
                    .get("javax.xml.ws.addressing.context.inbound");
            if (maps == null) {
                maps = (AddressingProperties)m2
                    .get("javax.xml.ws.addressing.context");
            }
           
            synchronized (client) {
                try {
                    SecureConversationTokenInterceptorProvider
                        .setupClient(client, message, aim, itok, true);

                    if (maps != null) {
                        client.setAddressingNamespace(maps.getNamespaceURI());
                    }
                   
                    client.cancelSecurityToken(tok);
                    NegotiationUtils.getTokenStore(m2).remove(tok.getId());
                    m2.setContextualProperty(SecurityConstants.TOKEN, null);
                } 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.setLocation(null);
                    client.setAddressingNamespace(null);
                }
            }

        }
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.