Package org.apache.rahas.client

Examples of org.apache.rahas.client.STSClient


                return customTokeId;
            } else {
   
                Axis2Util.useDOOM(false);
               
                STSClient client = new STSClient(rmd.getMsgContext()
                        .getConfigurationContext());
                // Set request action
                client.setAction(action);
               
                client.setRstTemplate(rstTemplate);
       
                // Set crypto information
                Crypto crypto = RampartUtil.getSignatureCrypto(rmd.getPolicyData().getRampartConfig(),
                        rmd.getMsgContext().getAxisService().getClassLoader());
                CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
                client.setCryptoInfo(crypto, cbh);
       
                // Get service policy
                Policy servicePolicy = rmd.getServicePolicy();
       
                // Get service epr
                String servceEprAddress = rmd.getMsgContext()
                        .getOptions().getTo().getAddress();
       
                //If addressing version can be found set it
                Object addrVersionNs = msgContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
                if(addrVersionNs != null) {
                    client.setAddressingNs((String)addrVersionNs);
                }
               
                //Set soap version
                client.setSoapVersion(msgContext.getOptions().getSoapVersionURI());
               
                //Make the request
                org.apache.rahas.Token rst =
                    client.requestSecurityToken(servicePolicy,
                                                issuerEpr,
                                                issuerPolicy,
                                                servceEprAddress);
               
                //Add the token to token storage
View Full Code Here


                return customTokeId;
            } else {
   
                Axis2Util.useDOOM(false);
               
                STSClient client = new STSClient(rmd.getMsgContext()
                        .getConfigurationContext());
                // Set request action
                client.setAction(action);
               
                client.setVersion(rmd.getWstVersion());
               
                client.setRstTemplate(rstTemplate);
       
                // Set crypto information
                Crypto crypto = RampartUtil.getSignatureCrypto(rmd.getPolicyData().getRampartConfig(),
                        rmd.getMsgContext().getAxisService().getClassLoader());
                CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
                client.setCryptoInfo(crypto, cbh);
       
                // Get service policy
                Policy servicePolicy = rmd.getServicePolicy();
       
                // Get service epr
                String servceEprAddress = rmd.getMsgContext()
                        .getOptions().getTo().getAddress();
       
                //If addressing version can be found set it
                Object addrVersionNs = msgContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
                if(addrVersionNs != null) {
                    client.setAddressingNs((String)addrVersionNs);
                }
               
                Options options = new Options();
               
                options.setUserName(rmd.getMsgContext().getOptions().getUserName());
                options.setPassword(rmd.getMsgContext().getOptions().getPassword());
               
                if (msgContext.getProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER) != null) {
                    Protocol protocolHandler =
                        (Protocol)msgContext.getProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER);;
                    options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, protocolHandler);                
                }
               
                if (msgContext.getParameter(WSHandlerConstants.PW_CALLBACK_REF) != null ) {
                    Parameter pwCallback = msgContext.getParameter(WSHandlerConstants.PW_CALLBACK_REF);
                    client.addParameter(pwCallback);
                }
               
                client.setOptions(options);
               
                //Set soap version
                if (msgContext.isSOAP11()) {
                    client.setSoapVersion(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                } else {
                    client.setSoapVersion(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                }
               
               
                //Make the request
                org.apache.rahas.Token rst =
                    client.requestSecurityToken(servicePolicy,
                                                issuerEpr,
                                                issuerPolicy,
                                                servceEprAddress);
               
                //Add the token to token storage
View Full Code Here

        if (secConvTok != null) {

          Policy issuerPolicy = secConvTok.getBootstrapPolicy();
          issuerPolicy.addAssertion(rpd.getRampartConfig());

          STSClient client = new STSClient(message
              .getConfigurationContext());
          Options op = new Options();
          op.setProperty(SandeshaClientConstants.UNRELIABLE_MESSAGE,
              Constants.VALUE_TRUE);
          client.setOptions(op);
          client.setAction(action);
          client.setRstTemplate(rstTmpl);
          client.setCryptoInfo(RampartUtil.getEncryptionCrypto(rpd
              .getRampartConfig(), message.getAxisService()
              .getClassLoader()), RampartUtil.getPasswordCB(
              message, rpd));
          String address = message.getTo().getAddress();
          Token tok = client.requestSecurityToken(servicePolicy,
              address, issuerPolicy, null);

          tok.setState(Token.ISSUED);
          this.storage.add(tok);
View Full Code Here

    protected OMElement getRST(String appliesTo, String attrs) throws Exception {
        OMFactory factory = null;
        OMElement element = null;
        OMElement claims = null;
        STSClient client = null;
        String[] attributes = null;
        String requestType;

        if (attrs != null) {
            attributes = attrs.split(",");
        }

        requestType = TrustUtil.getWSTNamespaceForRSTRequestTye(RahasConstants.VERSION_05_12)
                + RahasConstants.REQ_TYPE_ISSUE;

        factory = OMAbstractFactory.getOMFactory();
        element = factory.createOMElement(Constants.RST_TEMPLATE);
        TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_12, element).setText(
                RahasConstants.TOK_TYPE_SAML_10);
        TrustUtil.createKeyTypeElement(RahasConstants.VERSION_05_12, element,
                RahasConstants.KEY_TYPE_SYMM_KEY);
        TrustUtil.createKeySizeElement(RahasConstants.VERSION_05_12, element, 256);

        if (attributes != null && attributes.length > 0) {
            claims = TrustUtil.createClaims(RahasConstants.VERSION_05_12, element,
                    "http://wso2.org");
            for (int i = 0; i < attributes.length; i++) {
                addClaimType(claims, attributes[i]);
            }
        }

        client = new STSClient(MessageContext.getCurrentMessageContext().getConfigurationContext());
        client.setVersion(RahasConstants.VERSION_05_12);
        client.setRstTemplate(element);
        return client.createIssueRequest(requestType, appliesTo);
    }
View Full Code Here

            String issuerEpr, String action, Policy issuerPolicy) throws RampartException {

        try {
            Axis2Util.useDOOM(false);
           
            STSClient client = new STSClient(rmd.getMsgContext()
                    .getConfigurationContext());
            // Set request action
            client.setAction(action);
           
            client.setRstTemplate(rstTemplate);
   
            // Set crypto information
            Crypto crypto = RampartUtil.getSignatureCrypto(rmd.getPolicyData().getRampartConfig(),
                    rmd.getMsgContext().getAxisService().getClassLoader());
            CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
            client.setCryptoInfo(crypto, cbh);
   
            // Get service policy
            Policy servicePolicy = rmd.getServicePolicy();
   
            // Get service epr
            String servceEprAddress = rmd.getMsgContext()
                    .getOptions().getTo().getAddress();
   
            //Make the request
            org.apache.rahas.Token rst =
                client.requestSecurityToken(servicePolicy,
                                            issuerEpr,
                                            issuerPolicy,
                                            servceEprAddress);
           
            //Add the token to token storage
View Full Code Here

                return customTokeId;
            } else {
   
                Axis2Util.useDOOM(false);
               
                STSClient client = new STSClient(rmd.getMsgContext()
                        .getConfigurationContext());
                // Set request action
                client.setAction(action);
               
                client.setVersion(rmd.getWstVersion());
               
                client.setRstTemplate(rstTemplate);
       
                // Set crypto information
                Crypto crypto = RampartUtil.getSignatureCrypto(rmd.getPolicyData().getRampartConfig(),
                        rmd.getMsgContext().getAxisService().getClassLoader());
                CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
                client.setCryptoInfo(crypto, cbh);
       
                // Get service policy
                Policy servicePolicy = rmd.getServicePolicy();
       
                // Get service epr
                String servceEprAddress = rmd.getMsgContext()
                        .getOptions().getTo().getAddress();
       
                //If addressing version can be found set it
                Object addrVersionNs = msgContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
                if(addrVersionNs != null) {
                    client.setAddressingNs((String)addrVersionNs);
                }
               
                Options options = new Options();
               
                options.setUserName(rmd.getMsgContext().getOptions().getUserName());
                options.setPassword(rmd.getMsgContext().getOptions().getPassword());
               
                if (msgContext.getProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER) != null) {
                    Protocol protocolHandler =
                        (Protocol)msgContext.getProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER);;
                    options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, protocolHandler);                
                }
               
                if (msgContext.getParameter(WSHandlerConstants.PW_CALLBACK_REF) != null ) {
                    Parameter pwCallback = msgContext.getParameter(WSHandlerConstants.PW_CALLBACK_REF);
                    client.addParameter(pwCallback);
                }
               
                client.setOptions(options);
               
                //Set soap version
                if (msgContext.isSOAP11()) {
                    client.setSoapVersion(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                } else {
                    client.setSoapVersion(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                }
               
               
                //Make the request
                org.apache.rahas.Token rst =
                    client.requestSecurityToken(servicePolicy,
                                                issuerEpr,
                                                issuerPolicy,
                                                servceEprAddress);
               
                //Add the token to token storage
View Full Code Here

      System.out.println("Usage: $java Client endpoint_address client_repo_path policy_xml_path");
    }

    ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], null);   
   
    STSClient stsClient = new STSClient(ctx);   
   
    stsClient.setRstTemplate(getRSTTemplate());
    String action = TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
    stsClient.setAction(action);
   
    Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample05/policy.xml"), "http://localhost:8080/axis2/services/STS", loadPolicy("sample05/sts_policy.xml"), null);
   
          System.out.println("\n############################# Requested Token ###################################\n");
          System.out.println(responseToken.getToken().toString());
   
          TokenStorage store = TrustUtil.getTokenStore(ctx);
View Full Code Here

      System.out.println("Usage: $java Client endpoint_address client_repo_path policy_xml_path");
    }

    ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], null);   
   
    STSClient stsClient = new STSClient(ctx);   
   
    stsClient.setRstTemplate(getRSTTemplate());
    String action = TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
    stsClient.setAction(action);
   
    Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample08/policy.xml"), "http://localhost:8080/axis2/services/STS", loadPolicy("sample08/sts_policy.xml"), null);
   
          System.out.println("\n############################# Requested SAML 2.0 Token ###################################\n");
          System.out.println(responseToken.getToken().toString());
    System.out.println("\n##########################################################################################\n");
                
View Full Code Here

      System.out.println("Usage: $java Client endpoint_address client_repo_path policy_xml_path");
    }

    ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], null);   
   
    STSClient stsClient = new STSClient(ctx);   
   
    stsClient.setRstTemplate(getRSTTemplate());
    String action = TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
    stsClient.setAction(action);
   
    Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample05/policy.xml"), "http://localhost:8080/axis2/services/STS", loadPolicy("sample05/sts_policy.xml"), null);
   
          System.out.println("\n############################# Requested Token ###################################\n");
          System.out.println(responseToken.getToken().toString());
   
          TokenStorage store = TrustUtil.getTokenStore(ctx);
View Full Code Here

        if (secConvTok != null) {

          Policy issuerPolicy = secConvTok.getBootstrapPolicy();
          issuerPolicy.addAssertion(rpd.getRampartConfig());

          STSClient client = new STSClient(message
              .getConfigurationContext());
          Options op = new Options();
          op.setProperty(SandeshaClientConstants.UNRELIABLE_MESSAGE,
              Constants.VALUE_TRUE);
          client.setOptions(op);
          client.setAction(action);
          client.setRstTemplate(rstTmpl);
          client.setCryptoInfo(RampartUtil.getEncryptionCrypto(rpd
              .getRampartConfig(), message.getAxisService()
              .getClassLoader()), RampartUtil.getPasswordCB(
              message, rpd));
          String address = message.getTo().getAddress();
          Token tok = client.requestSecurityToken(servicePolicy,
              address, issuerPolicy, null);

          tok.setState(Token.ISSUED);
          this.storage.add(tok);
View Full Code Here

TOP

Related Classes of org.apache.rahas.client.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.