Examples of RampartConfig


Examples of org.apache.rampart.policy.model.RampartConfig

          String keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password");
          String privateKeyAlias = serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
          String privateKeyPassword = serverConfig.getFirstProperty("Security.KeyStore.KeyPassword");

          //Populate Rampart Configuration
          RampartConfig rampartConfig = new RampartConfig();
          rampartConfig.setUser(privateKeyAlias);
          //TODO use a registry based callback handler
          rampartConfig.setPwCbClass("org.wso2.carbon.registry.ws.api.utils.InMemoryPasswordCallbackHandler");

          //Set the private key alias and private key password in the password callback handler
          InMemoryPasswordCallbackHandler.addUser(privateKeyAlias, privateKeyPassword);

          CryptoConfig sigCrypto = new CryptoConfig();
          Properties props = new Properties();
          sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin");
          props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", keyStoreType);
          props.setProperty("org.apache.ws.security.crypto.merlin.file", keyStore);
          props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", keyStorePassword);
          sigCrypto.setProp(props);

          rampartConfig.setSigCryptoConfig(sigCrypto);
          Policy policy = new Policy();
          policy.addAssertion(rampartConfig);
          return policy;

      }
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

    public Policy loadPolicy(String xmlPath, String clientKey) throws Exception {

        StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
        Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());

        RampartConfig rc = new RampartConfig();

        rc.setUser("admin");
        rc.setUserCertAlias("wso2carbon");
        rc.setEncryptionUser("wso2carbon");
        rc.setPwCbClass(SecurityClient.class.getName());

        CryptoConfig sigCryptoConfig = new CryptoConfig();
        sigCryptoConfig.setProvider("org.apache.ws.security.components.crypto.Merlin");

        Properties prop1 = new Properties();
        prop1.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
        prop1.put("org.apache.ws.security.crypto.merlin.file", clientKey);
        prop1.put("org.apache.ws.security.crypto.merlin.keystore.password", "wso2carbon");
        sigCryptoConfig.setProp(prop1);

        CryptoConfig encrCryptoConfig = new CryptoConfig();
        encrCryptoConfig.setProvider("org.apache.ws.security.components.crypto.Merlin");

        Properties prop2 = new Properties();
        prop2.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
        prop2.put("org.apache.ws.security.crypto.merlin.file", clientKey);
        prop2.put("org.apache.ws.security.crypto.merlin.keystore.password", "wso2carbon");
        encrCryptoConfig.setProp(prop2);

        rc.setSigCryptoConfig(sigCryptoConfig);
        rc.setEncrCryptoConfig(encrCryptoConfig);

        policy.addAssertion(rc);
        return policy;
    }
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

public class RampartConfigBuilder implements AssertionBuilder {

    public Assertion build(OMElement element, AssertionBuilderFactory factory)
            throws IllegalArgumentException {

        RampartConfig rampartConfig = new RampartConfig();

        OMElement childElement;

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.USER_LN));
        if (childElement != null) {
            rampartConfig.setUser(childElement.getText().trim());
        }

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.ENCRYPTION_USER_LN));
        if (childElement != null) {
            rampartConfig.setEncryptionUser(childElement.getText().trim());
        }

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.PW_CB_CLASS_LN));
        if (childElement != null) {
            rampartConfig.setPwCbClass(childElement.getText().trim());
        }

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.SIG_CRYPTO_LN));
        if (childElement != null) {
            rampartConfig.setSigCryptoConfig((CryptoConfig) factory
                    .build(childElement.getFirstElement()));
        }

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.TS_TTL_LN));
        if (childElement != null) {
            rampartConfig.setTimestampTTL(childElement.getText().trim());
        }

        return rampartConfig;
    }
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

    private void doEncryptBeforeSig(RampartMessageData rmd)
            throws RampartException {

        RampartPolicyData rpd = rmd.getPolicyData();
        Document doc = rmd.getDocument();
        RampartConfig config = rpd.getRampartConfig();

        /*
         * We need to hold on to these two element to use them as refence in the
         * case of encypting the signature
         */
 
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

    }
   

    public static int getTimeToLive(RampartMessageData messageData) {

        RampartConfig rampartConfig = messageData.getPolicyData().getRampartConfig();
        if(rampartConfig != null) {
        String ttl = rampartConfig.getTimestampTTL();
        int ttl_i = 0;
        if (ttl != null) {
            try {
                ttl_i = Integer.parseInt(ttl);
            } catch (NumberFormatException e) {
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

                        || WSSHandlerConstants.RSTR_ACTON_SCT.equals(msgContext.getWSAAction())) &&
                        this.policyData.getIssuerPolicy() != null) {
                   
                    this.servicePolicy = this.policyData.getIssuerPolicy();
                   
                    RampartConfig rampartConfig = policyData.getRampartConfig();
                    /*
                     * Copy crypto info from the into the new issuer policy
                     */
                    RampartConfig rc = new RampartConfig();
                    rc.setEncrCryptoConfig(rampartConfig.getEncrCryptoConfig());
                    rc.setSigCryptoConfig(rampartConfig.getSigCryptoConfig());
                    rc.setDecCryptoConfig(rampartConfig.getDecCryptoConfig());
                    rc.setUser(rampartConfig.getUser());
                    rc.setEncryptionUser(rampartConfig.getEncryptionUser());
                    rc.setPwCbClass(rampartConfig.getPwCbClass());
                   
                    this.servicePolicy.addAssertion(rc);
                   
                    List it = (List)this.servicePolicy.getAlternatives().next();
   
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

        String keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password");
        String privateKeyAlias = serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
        String privateKeyPassword = serverConfig.getFirstProperty("Security.KeyStore.KeyPassword");

        //Populate Rampart Configuration
        RampartConfig rampartConfig = new RampartConfig();
        rampartConfig.setUser(privateKeyAlias);
        rampartConfig.setPwCbClass("org.apache.stratos.tenant.mgt.services.InMemoryPasswordcallbackHandler");

        //Set the private key alias and private key password in the password callback handler
        InMemoryPasswordcallbackHandler.addUser(privateKeyAlias, privateKeyPassword);

        CryptoConfig sigCrypto = new CryptoConfig();
        Properties props = new Properties();
        sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin");
        props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", keyStoreType);
        props.setProperty("org.apache.ws.security.crypto.merlin.file", keyStore);
        props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", keyStorePassword);
        sigCrypto.setProp(props);

        rampartConfig.setSigCryptoConfig(sigCrypto);
        Policy policy = new Policy();
        policy.addAssertion(rampartConfig);

        return policy;
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

        org.apache.axis2.Constants.MODULE_ADDRESSING);
   
    System.out.println(Messages.getString("SignClient.6")); //$NON-NLS-1$

    // rampart configuration and policy loading
    RampartConfig rc = new RampartConfig();
    rc.setUser(Path.getString("SignClient.19")); //$NON-NLS-1$
    rc.setPwCbClass(PWCallback.class.getName());

    // signature configuration
    CryptoConfig sigCryptoConfig = new CryptoConfig();
    sigCryptoConfig.setProvider(Path.getString("SignClient.20")); //$NON-NLS-1$

    Properties prop1 = new Properties();
    try {
      prop1.load(new FileInputStream(Path.getString("SignClient.21") + File.separator + Path.getString("SignClient.22"))); //$NON-NLS-1$ //$NON-NLS-2$
    } catch (IOException e) { e.printStackTrace(); }

    sigCryptoConfig.setProp(prop1);

    // set configuration for Rampart
    rc.setSigCryptoConfig(sigCryptoConfig);
   
    // add rampart policies to scenario policies
    Policy policy = loadPolicy(scenarioNumber);
    policy.addAssertion(rc);
   
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

        org.apache.axis2.Constants.MODULE_ADDRESSING);

    System.out.println(Messages.getString("SignEncryptClient.6")); //$NON-NLS-1$

    // rampart configuration and policy loading
    RampartConfig rc = new RampartConfig();
    rc.setUser(Path.getString("SignEncryptClient.27")); //$NON-NLS-1$
    rc.setEncryptionUser(Path.getString("SignEncryptClient.26")); //$NON-NLS-1$
    rc.setPwCbClass(PWCallback.class.getName());

    // crypto configuration
    CryptoConfig sigCryptoConfig = new CryptoConfig();
    sigCryptoConfig.setProvider(Path.getString("SignEncryptClient.3")); //$NON-NLS-1$

    Properties prop1 = new Properties();
    try {
      prop1.load(new FileInputStream(Path.getString("SignEncryptClient.2") + File.separator + Path.getString("SignEncryptClient.1"))); //$NON-NLS-1$ //$NON-NLS-2$
    } catch (IOException e) { e.printStackTrace(); }

    sigCryptoConfig.setProp(prop1);

    // set configuration for Rampart. Same configuration for sign and encrypt
    rc.setSigCryptoConfig(sigCryptoConfig);
    rc.setEncrCryptoConfig(sigCryptoConfig);
   
    // add rampart policies to scenario policies
    Policy policy = loadPolicy(scenarioNumber);
    policy.addAssertion(rc);
   
View Full Code Here

Examples of org.apache.rampart.policy.model.RampartConfig

    }
   

    public static int getTimeToLive(RampartMessageData messageData) {

        RampartConfig rampartConfig = messageData.getPolicyData().getRampartConfig();
        if (rampartConfig != null) {
            String ttl = rampartConfig.getTimestampTTL();
            int ttl_i = 0;
            if (ttl != null) {
                try {
                    ttl_i = Integer.parseInt(ttl);
                } catch (NumberFormatException e) {
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.