private void assertAllProperties(final STSClientConfig config) {
   assertEquals(serviceName, config.getServiceName());
   assertEquals(portName, config.getPortName());
   assertEquals(endpointAddress, config.getEndPointAddress());
   assertEquals(username, config.getUsername());
   assertEquals(password, config.getPassword());
 }
  public void testBuildFromConfigPropertiesFileOverridePassword() {
    final Builder builder = new STSClientConfig.Builder("wstrust/sts-client.properties");
    assertAllProperties(builder.build());

    final String overriddenPassword = "******";
    builder.password(overriddenPassword);
    final STSClientConfig config = builder.build();
    assertEquals(overriddenPassword, config.getPassword());
  }
    public JBWSTokenClient(STSClientConfig config) {
      super(config);
      requestType = config.getRequestType();

      try {
        this.dataTypefactory = DatatypeFactory.newInstance();
      } catch (DatatypeConfigurationException dce) {
        throw logger.wsTrustUnableToGetDataTypeFactory(dce);
      }
    }
    @SuppressWarnings("rawtypes")
    public JBWSTokenClient(STSClientConfig config, Map<String, ? super Object> options) {
      super(config);

      try {
        this.dataTypefactory = DatatypeFactory.newInstance();
      } catch (DatatypeConfigurationException dce) {
        throw logger.wsTrustUnableToGetDataTypeFactory(dce);
      }

      requestType = (String) options.get(STSClientConfig.REQUEST_TYPE);
      if (requestType == null) {
        requestType = config.getRequestType();
      }

      String soapBinding = (String) options.get(STSClientConfig.SOAP_BINDING);
      if (soapBinding != null) {
        setSoapBinding(soapBinding);
      }

      // Get pre-constructed Dispatch from super
      Dispatch<Source> dispatch = super.getDispatch();

      String overrideDispatchStr = (String) options.get("overrideDispatch");
      if (StringUtil.isNotNull(overrideDispatchStr)) {
        boolean bool = Boolean.valueOf(overrideDispatchStr);
        if (bool) {
          dispatch = new PicketLinkDispatch(dispatch, (String) options.get("endpointAddress"));
          String useWSSE = (String) options.get("useWSSE");
          if (StringUtil.isNotNull(useWSSE) && useWSSE.equalsIgnoreCase("true")) {
            ((PicketLinkDispatch) dispatch).setUseWSSE(true);
          }
        }
      }

      Binding binding = dispatch.getBinding();

      List<Handler> handlers = binding.getHandlerChain();

      String handlerStr = (String) options.get("handlerChain");

      if (StringUtil.isNotNull(handlerStr)) {
        List<String> tokens = StringUtil.tokenize(handlerStr);
        for (String token : tokens) {
          if (token.equalsIgnoreCase("binary")) {
            BinaryTokenHandler binaryTokenHandler = new BinaryTokenHandler();
            handlers.add(binaryTokenHandler);
          } else if (token.equalsIgnoreCase("saml2")) {
            SAML2Handler samlHandler = new SAML2Handler();
            handlers.add(samlHandler);
          } else if (token.equalsIgnoreCase("map")) {
            MapBasedTokenHandler mapBasedHandler = new MapBasedTokenHandler(options);
            handlers.add(mapBasedHandler);
          } else {
            ClassLoader cl = SecurityActions.getClassLoader(getClass());
            try {
              handlers.add((Handler) cl.loadClass(token).newInstance());
            } catch (Exception e) {
              throw logger.authUnableToInstantiateHandler(token, e);
            }
          }
        }
      }

      binding.setHandlerChain(handlers);

      setDispatch(dispatch);

      String securityDomainForFactory = (String) options.get("securityDomainForFactory");
      if (StringUtil.isNotNull(securityDomainForFactory)) {
        logger.trace("We got security domain for domain ssl factory = " + securityDomainForFactory);
        logger.trace("Setting it on the system property org.jboss.security.ssl.domain.name");

        String sslFactoryName = "org.jboss.security.ssl.JaasSecurityDomainSocketFactory";
        SecurityActions.setSystemProperty(
            "org.jboss.security.ssl.domain.name", securityDomainForFactory);
        // StubExt.PROPERTY_SOCKET_FACTORY
        dispatch.getRequestContext().put("org.jboss.ws.socketFactory", sslFactoryName);

        // If we are using PL Dispatch. Then we need to set the SSL Socket Factory
        if (dispatch instanceof PicketLinkDispatch) {
          ClassLoader cl = SecurityActions.getClassLoader(getClass());
          SSLSocketFactory socketFactory = null;
          if (cl != null) {
            try {
              Class<?> clazz = cl.loadClass(sslFactoryName);
              socketFactory = (SSLSocketFactory) clazz.newInstance();
            } catch (Exception e) {
              cl = SecurityActions.getContextClassLoader();
              try {
                Class<?> clazz = cl.loadClass(sslFactoryName);
                socketFactory = (SSLSocketFactory) clazz.newInstance();
              } catch (Exception e1) {
                throw logger.jbossWSUnableToCreateSSLSocketFactory(e1);
              }
            } finally {
              if (socketFactory != null) {
                ((PicketLinkDispatch) dispatch).setSSLSocketFactory(socketFactory);
              } else throw logger.jbossWSUnableToFindSSLSocketFactory();
            }
          } else {
            logger.trace(
                "Classloader is null. Unable to set the SSLSocketFactory on PicketLinkDispatch");
          }
        }
      }
    }