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

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


        Element supportingToken,
        Bus bus,
        String endpointAddress,
        String context
    ) throws Exception {
        STSClient stsClient = new STSClient(bus);
        stsClient.setWsdlLocation(
            "https://localhost:" + STSPORT + "/SecurityTokenService/TransportSoap12?wsdl"
        );
        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_Soap12_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.ENCRYPT_PROPERTIES, "clientKeystore.properties");
        properties.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey");

        if (PUBLIC_KEY_KEYTYPE.equals(keyType)) {
            properties.put(SecurityConstants.STS_TOKEN_USERNAME, "myclientkey");
            properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "clientKeystore.properties");
            stsClient.setUseCertificateForConfirmationKeyInfo(true);
        }
        if (supportingToken != null) {
            stsClient.setOnBehalfOf(supportingToken);
        }
        if (context != null) {
            stsClient.setContext(context);
        }

        stsClient.setProperties(properties);
        stsClient.setTokenType(tokenType);
        stsClient.setKeyType(keyType);
        stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");

        return stsClient.requestSecurityToken(endpointAddress);
    }
View Full Code Here

        // Make a successful invocation
        doubleIt(transportSaml1Port, 25);
       
        // Change the STSClient so that it can no longer find the STS
        BindingProvider p = (BindingProvider)transportSaml1Port;
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, new STSClient(bus));
       
        // This should succeed as the token is cached
        doubleIt(transportSaml1Port, 30);
       
        // This should fail as the cached token is manually removed
View Full Code Here

        // Make a successful invocation
        doubleIt(transportSaml1Port, 25);
       
        // Change the STSClient so that it can no longer find the STS
        BindingProvider p = (BindingProvider)transportSaml1Port;
        p.getRequestContext().put(SecurityConstants.STS_CLIENT, new STSClient(bus));
       
        // This should fail as it can't get the token
        try {
            doubleIt(transportSaml1Port, 35);
            fail("Expected failure");
View Full Code Here

        String tokenType,
        String keyType,
        Bus bus,
        String endpointAddress
    ) throws Exception {
        STSClient stsClient = new STSClient(bus);
        stsClient.setWsdlLocation("https://localhost:" + STSPORT + "/SecurityTokenService/Transport?wsdl");
        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"
        );

        if (PUBLIC_KEY_KEYTYPE.equals(keyType)) {
            properties.put(SecurityConstants.STS_TOKEN_USERNAME, "myservicekey");
            properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "serviceKeystore.properties");
            stsClient.setUseCertificateForConfirmationKeyInfo(true);
        }

        stsClient.setProperties(properties);
        stsClient.setTokenType(tokenType);
        stsClient.setKeyType(keyType);
        stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");

        return stsClient.requestSecurityToken(endpointAddress);
    }
View Full Code Here

            } catch (Exception ex) {
                ex.printStackTrace();
            }
            if ("standalone".equals(System.getProperty("sts.deployment"))) {
                Map<String, Object> context = ((BindingProvider)transportPort).getRequestContext();
                STSClient stsClient = (STSClient)context.get(SecurityConstants.STS_CLIENT);
                if (stsClient != null) {
                    String location = stsClient.getWsdlLocation();
                    if (location.contains("8080")) {
                        stsClient.setWsdlLocation(
                            location.replace("8080", IntermediaryTransformationCachingTest.STSPORT2)
                        );
                    } else if (location.contains("8443")) {
                        stsClient.setWsdlLocation(
                            location.replace("8443", IntermediaryTransformationCachingTest.STSPORT)
                        );
                    }
                }
            }
        }
        Principal pr = wsc.getUserPrincipal();
       
        Assert.assertNotNull("Principal must not be null", pr);
        Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
        Assert.assertEquals("Princiapl must be alice", "alice", pr.getName());
       
        // Disable the STSClient after the first invocation
        if (i > 0) {
            BindingProvider p = (BindingProvider)transportPort;
            STSClient stsClient = new STSClient(null);
            stsClient.setOnBehalfOf(new ReceivedTokenCallbackHandler());
            p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
        }
       
        i++;
        return transportPort.doubleIt(numberToDouble);
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.