Package org.picketlink.identity.federation.core.wstrust.STSClientConfig

Examples of org.picketlink.identity.federation.core.wstrust.STSClientConfig.Builder


    protected STSClient getSTSClient() {
        /*
         * Builder builder = new Builder(this.stsConfigurationFile); STSClient client = new STSClient(builder.build());
         */

        Builder builder = null;
        STSClient client = null;
        if (rawOptions.containsKey(STS_CONFIG_FILE)) {
            builder = new Builder(this.stsConfigurationFile);
            client = STSClientFactory.getInstance(maxClientsInPool).create(initialNumberOfClients, builder.build());
        } else {
            builder = new Builder();
            builder.endpointAddress((String) rawOptions.get(ENDPOINT_ADDRESS));
            builder.portName((String) rawOptions.get(PORT_NAME)).serviceName((String) rawOptions.get(SERVICE_NAME));
            builder.username((String) rawOptions.get(USERNAME_KEY)).password((String) rawOptions.get(PASSWORD_KEY));

            String passwordString = (String) rawOptions.get(PASSWORD_KEY);
            if (passwordString != null && passwordString.startsWith(PicketLinkFederationConstants.PASS_MASK_PREFIX)) {
                // password is masked
                String salt = (String) rawOptions.get(PicketLinkFederationConstants.SALT);
                if (StringUtil.isNullOrEmpty(salt))
                    throw logger.optionNotSet("Salt");

                String iCount = (String) rawOptions.get(PicketLinkFederationConstants.ITERATION_COUNT);
                if (StringUtil.isNullOrEmpty(iCount))
                    throw logger.optionNotSet("Iteration Count");

                int iterationCount = Integer.parseInt(iCount);
                try {
                    builder.password(StringUtil.decode(passwordString, salt, iterationCount));
                } catch (Exception e) {
                    throw logger.unableToDecodePasswordError(passwordString);
                }
            }
            client = STSClientFactory.getInstance(maxClientsInPool).create(initialNumberOfClients, builder.build());
        }

        // if the login module options map still contains any properties, assume they are for configuring the connection
        // to the STS and set them in the Dispatch request context.
        if (!this.options.isEmpty()) {
View Full Code Here


     * @return true If the login was successful otherwise false.
     * @throws LoginException If an error occurs while trying to perform the authentication.
     */
    public boolean login() throws LoginException {
        try {
            final Builder builder = createBuilder();
            if (useOptionsCredentials) {
                useCredentialsFromOptions(builder, options);
            } else if (isUseFirstPass()) {
                useCredentialsFromSharedState(builder);
            } else {
                useCredentialsFromCallback(builder);
            }

            if (passwordStacking)
                setPasswordStackingCredentials(builder);

            final STSClient stsClient = createWSTrustClient(builder.build());

            final Element token = invokeSTS(stsClient);

            if (token == null) {
                // Throw an exception as returing false only says that this login module should be ignored.
View Full Code Here

     */
    protected Builder createBuilder() {
        if (options.containsKey(STS_CONFIG_FILE)) {
            return new STSClientConfig.Builder(getRequiredOption(getOptions(), STS_CONFIG_FILE));
        } else {
            Builder builder = new Builder();
            builder.endpointAddress((String) options.get(ENDPOINT_ADDRESS));
            builder.portName((String) options.get(PORT_NAME)).serviceName((String) options.get(SERVICE_NAME));
            builder.username((String) options.get(USERNAME_KEY)).password((String) options.get(PASSWORD_KEY));

            builder.setBatch(isBatch);

            String passwordString = (String) options.get(PASSWORD_KEY);
            if (passwordString != null && passwordString.startsWith(PicketLinkFederationConstants.PASS_MASK_PREFIX)) {
                // password is masked
                String salt = (String) options.get(PicketLinkFederationConstants.SALT);
                if (StringUtil.isNullOrEmpty(salt))
                    throw logger.optionNotSet("Salt");

                String iCount = (String) options.get(PicketLinkFederationConstants.ITERATION_COUNT);
                if (StringUtil.isNullOrEmpty(iCount))
                    throw logger.optionNotSet("Iteration Count");

                int iterationCount = Integer.parseInt(iCount);
                try {
                    builder.password(StringUtil.decode(passwordString, salt, iterationCount));
                } catch (Exception e) {
                    throw logger.unableToDecodePasswordError("Unable to decode password:" + passwordString);
                }
            }
            return builder;
View Full Code Here

     */
    public static final String WSP_APPIESTO = "wspAppliesTo";

    @Override
    protected Builder createBuilder() {
        Builder builder = super.createBuilder();
        builder.wsaIssuer((String) options.get(WSA_ISSUER));
        builder.wspAppliesTo((String) options.get(WSP_APPIESTO));
        return builder;
    }
View Full Code Here

            Principal principal = sc.getUtil().getUserPrincipal();
            String credential = (String) sc.getUtil().getCredential();
            // look for the properties file in the classpath
            if (builder == null) {
                if (propertiesFile != null) {
                    builder = new Builder(propertiesFile);
                } else
                    throw logger.optionNotSet("propertiesFile");
            }
            WSTrustClient client = new WSTrustClient(builder.getServiceName(), builder.getPortName(),
                    builder.getEndpointAddress(), new SecurityInfo(principal.getName(), credential));
View Full Code Here

    final String endpointAddress = "http://localhost:8080/picketlink-sts/PicketLinkSTS";
    final String username = "admin";
    final String password = "admin";

    public void testBuild() {
        final Builder builder = new STSClientConfig.Builder();
        final STSClientConfig config = builder.serviceName(serviceName).portName(portName).endpointAddress(endpointAddress)
                .username(username).password(password).build();
        assertAllProperties(config);
    }
View Full Code Here

                .username(username).password(password).build();
        assertAllProperties(config);
    }

    public void testBuildFromConfigPropertiesFile() {
        final Builder builder = new STSClientConfig.Builder("wstrust/sts-client.properties");
        assertAllProperties(builder.build());
    }
View Full Code Here

        final Builder builder = new STSClientConfig.Builder("wstrust/sts-client.properties");
        assertAllProperties(builder.build());
    }

    public void testBuildFromConfigPropertiesFileOverridePassword() {
        final Builder builder = new STSClientConfig.Builder("wstrust/sts-client.properties");
        assertAllProperties(builder.build());

        final String overriddenPassword = "newPassword";
        builder.password(overriddenPassword);
        final STSClientConfig config = builder.build();
        assertEquals(overriddenPassword, config.getPassword());
    }
View Full Code Here

        if (endpointURIs.length == 0)
            throw logger.nullArgumentError("At least one endpoint URI must be provided");

        // create an STSClient for each endpointURI.
        this.clients = new STSClient[endpointURIs.length];
        Builder builder = new STSClientConfig.Builder();
        builder.serviceName(serviceName).portName(port).username(secInfo.username).password(secInfo.passwd);

        int index = 0;
        for (String endpointURI : endpointURIs) {
            builder.endpointAddress(endpointURI);
            this.clients[index++] = STSClientFactory.getInstance().create(builder.build());
        }

    }
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.core.wstrust.STSClientConfig.Builder

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.