Examples of RampartConfig


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

        }
    }

    public static int getTimestampMaxSkew(RampartMessageData messageData) {

        RampartConfig rampartConfig = messageData.getPolicyData().getRampartConfig();
        if (rampartConfig != null) {
            String maxSkew = rampartConfig.getTimestampMaxSkew();
            int maxSkew_i = 0;
            if (maxSkew != null) {
                try {
                    maxSkew_i = Integer.parseInt(maxSkew);
                } catch (NumberFormatException e) {
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.USER_CERT_ALIAS_LN));
        if (childElement != null) {
            rampartConfig.setUserCertAlias(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.STS_ALIAS_LN));
        if (childElement != null) {
            rampartConfig.setStsAlias(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.POLICY_VALIDATOR_CB_CLASS_LN));
        if (childElement != null) {
            rampartConfig.setPolicyValidatorCbClass(childElement.getText().trim());
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.RAMPART_CONFIG_CB_CLASS_LN));
        if (childElement != null) {
            rampartConfig.setRampartConfigCbClass(childElement.getText().trim());
        }
                     
        // handle ssl config 
    childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.SSL_CONFIG));
        if (childElement != null) {                           
          SSLConfig sslConfig = (SSLConfig)new SSLConfigBuilder().
                                    build(childElement,
                                factory);
            rampartConfig.setSSLConfig(sslConfig);
           
        }
       
        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.ENCR_CRYPTO_LN));
        if (childElement != null) {
            rampartConfig.setEncrCryptoConfig((CryptoConfig) factory
                    .build(childElement.getFirstElement()));
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.STS_CRYPTO_LN));
        if (childElement != null) {
            rampartConfig.setStsCryptoConfig((CryptoConfig) factory
                    .build(childElement.getFirstElement()));
        }

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

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.TS_MAX_SKEW_LN));
        if (childElement != null) {
            rampartConfig.setTimestampMaxSkew(childElement.getText().trim());
        }
       
    childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.OPTIMISE_PARTS));
        if (childElement != null) {
          OptimizePartsConfig config = (OptimizePartsConfig)new OptimizePartsBuilder().
            build(childElement, factory);
          rampartConfig.setOptimizeParts(config);
        }

        return rampartConfig;
    }
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();
                    if(rampartConfig != null) {
                        /*
                         * Copy crypto info 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.setUserCertAlias(rc.getUserCertAlias());
                        rc.setEncryptionUser(rampartConfig.getEncryptionUser());
                        rc.setPwCbClass(rampartConfig.getPwCbClass());
                        rc.setSSLConfig(rampartConfig.getSSLConfig());
                       
                        this.servicePolicy.addAssertion(rc);
                    }
   
                    List it = (List)this.servicePolicy.getAlternatives().next();
View Full Code Here

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

            param.setName(WSHandlerConstants.PW_CALLBACK_REF);
            param.setValue(handler);
            service.addParameter(param);

            Properties props = getServerCryptoProperties(privateStore, trustedStores);
            RampartConfig rampartConfig = new RampartConfig();
            // rampartConfig.setTokenStoreClass(SimpleTokenStore.class.getName());
            populateRampartConfig(rampartConfig, props, kerberosConfig);
            Policy policy = loadPolicy(scenarioId, policyPath);

            if (rampartConfig != null) {
View Full Code Here

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

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

    RampartConfig rampartConfig = new RampartConfig();
    rampartConfig.setEncryptionUser("wso2carbon");
    rampartConfig.setUserCertAlias("wso2carbon");
    rampartConfig.setPwCbClass("org.wso2.carbon.registry.ws.client.registry.PWCBHandler");
    rampartConfig.setSigCryptoConfig(sigCryptoConfig);
    rampartConfig.setEncrCryptoConfig(encCryptoConfig);

    policy.addAssertion(rampartConfig);

    Options options = client.getOptions();
    options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, 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.USER_CERT_ALIAS_LN));
        if (childElement != null) {
            rampartConfig.setUserCertAlias(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.STS_ALIAS_LN));
        if (childElement != null) {
            rampartConfig.setStsAlias(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.POLICY_VALIDATOR_CB_CLASS_LN));
        if (childElement != null) {
            rampartConfig.setPolicyValidatorCbClass(childElement.getText().trim());
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.RAMPART_CONFIG_CB_CLASS_LN));
        if (childElement != null) {
            rampartConfig.setRampartConfigCbClass(childElement.getText().trim());
        }
                     
        // handle ssl config 
    childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.SSL_CONFIG));
        if (childElement != null) {                           
          SSLConfig sslConfig = (SSLConfig)new SSLConfigBuilder().
                                    build(childElement,
                                factory);
            rampartConfig.setSSLConfig(sslConfig);
           
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.KERBEROS_CONFIG));
        if (childElement != null) {                            
            KerberosConfig krbConfig = (KerberosConfig)new KerberosConfigBuilder().
                                      build(childElement,
                                      factory);
            rampartConfig.setKerberosConfig(krbConfig);
           
        }
       
        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.ENCR_CRYPTO_LN));
        if (childElement != null) {
            rampartConfig.setEncrCryptoConfig((CryptoConfig) factory
                    .build(childElement.getFirstElement()));
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.DEC_CRYPTO_LN));
        if (childElement != null) {
            rampartConfig.setDecCryptoConfig((CryptoConfig) factory
                    .build(childElement.getFirstElement()));
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.STS_CRYPTO_LN));
        if (childElement != null) {
            rampartConfig.setStsCryptoConfig((CryptoConfig) factory
                    .build(childElement.getFirstElement()));
        }

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

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

        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.NONCE_LIFE_TIME));
        if (childElement != null) {
            rampartConfig.setNonceLifeTime(childElement.getText().trim());
        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.TOKEN_STORE_CLASS_LN));
        if (childElement != null) {
            rampartConfig.setTokenStoreClass(childElement.getText().trim());
        }
       
    childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.OPTIMISE_PARTS));
        if (childElement != null) {
          OptimizePartsConfig config = (OptimizePartsConfig)new OptimizePartsBuilder().
            build(childElement, factory);
          rampartConfig.setOptimizeParts(config);
        }

        return rampartConfig;
    }
View Full Code Here

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

                // RampartConfig
               
                RampartConfigCallbackHandler rampartConfigCallbackHandler = RampartUtil
                        .getRampartConfigCallbackHandler(msgCtx, policyData);

                RampartConfig rampartConfig = policyData.getRampartConfig();

                // Get the Rampart Config callback Properties Map from message context and set it to Rampart Config
                Object callbackPropObj = msgContext.getProperty(RAMPART_CONFIG_CALLBACK_PROPERTIES);
                if (callbackPropObj != null && callbackPropObj instanceof Map) {
                    rampartConfig.setPropertyMap(
                            (Map<String, String>)msgContext.getProperty(RAMPART_CONFIG_CALLBACK_PROPERTIES));
                }
                if (rampartConfigCallbackHandler != null) {
                    rampartConfigCallbackHandler.update(rampartConfig);
                }
View Full Code Here

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

            return;
        }

        this.servicePolicy = this.policyData.getIssuerPolicy();

        RampartConfig rampartConfig = policyData.getRampartConfig();
        if (rampartConfig != null) {
            /*
            * Copy crypto info 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.setUserCertAlias(rc.getUserCertAlias());
            rc.setEncryptionUser(rampartConfig.getEncryptionUser());
            rc.setPwCbClass(rampartConfig.getPwCbClass());
            rc.setSSLConfig(rampartConfig.getSSLConfig());

            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);
        //TODO use a registry based callback handler
        rampartConfig.setPwCbClass("org.wso2.carbon.identity.base.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

    }

    private static void setRampartConfigs(WSRequestHostObject wsRequest, QName operationName)
            throws AxisFault, CarbonException {
        RampartConfig rampartConfig = null;
        boolean useUT = false;
        Policy policy = null;
        if (wsRequest.policy != null) {
            //user has specified a policy, use that one
            OMElement policyElement;
            OMNode node = wsRequest.policy.getAxiomFromXML();
            if (node instanceof OMElement) {
                policyElement = (OMElement) node;
            } else {
                throw new Error("INVALID_INPUT_EXCEPTION. Invalid input was : " + wsRequest.policy);
            }
            policy = PolicyEngine.getPolicy(policyElement);
            List list = (List) policy.getAlternatives().next();
            for (Object o : list) {
                if (o instanceof RampartConfig) {
                    rampartConfig = (RampartConfig) o;
                    filterRampartConfig(wsRequest, rampartConfig);
                    break;
                }
            }
        }
        if (wsRequest.rampartConfig != null) {
            if (rampartConfig == null) {
                rampartConfig = new RampartConfig();
                String property = getObjectProperty(wsRequest.rampartConfig, RampartConfig.USER_CERT_ALIAS_LN);
                if (property != null) {
                    rampartConfig.setUserCertAlias(property);
                }
                property = getObjectProperty(wsRequest.rampartConfig, RampartConfig.STS_ALIAS_LN);
                if (property != null) {
                    rampartConfig.setStsAlias(property);
                }
                property = getObjectProperty(wsRequest.rampartConfig, RampartConfig.ENCRYPTION_USER_LN);
                if (property != null) {
                    rampartConfig.setEncryptionUser(property);
                }

                Object obj = wsRequest.rampartConfig.get(RampartConfig.TS_TTL_LN, wsRequest.rampartConfig);
                if (obj instanceof Integer) {
                    rampartConfig.setTimestampTTL(Integer.toString((Integer) obj));
                } else if (obj instanceof String) {
                    rampartConfig.setTimestampTTL((String) obj);
                } else if (obj != null && !(obj instanceof Undefined) &&
                        !(obj instanceof UniqueTag)) {
                    throw new CarbonException("Invalid value for property '" + RampartConfig.TS_TTL_LN +
                            "' in rampart configuration");
                }

                obj = wsRequest.rampartConfig.get(RampartConfig.TS_MAX_SKEW_LN, wsRequest.rampartConfig);
                if (obj instanceof Integer) {
                    rampartConfig.setTimestampMaxSkew(Integer.toString((Integer) obj));
                } else if (obj instanceof String) {
                    rampartConfig.setTimestampMaxSkew((String) obj);
                } else if (obj != null && !(obj instanceof Undefined) &&
                        !(obj instanceof UniqueTag)) {
                    throw new CarbonException("Invalid value for property '" + RampartConfig.TS_MAX_SKEW_LN +
                            "' in rampart configuration");
                }

                obj = wsRequest.rampartConfig.get(RampartConfig.TS_PRECISION_IN_MS_LN, wsRequest.rampartConfig);
                if (obj instanceof Integer) {
                    rampartConfig.setTimestampPrecisionInMilliseconds(Integer.toString((Integer) obj));
                } else if (obj instanceof String) {
                    rampartConfig.setTimestampPrecisionInMilliseconds((String) obj);
                } else if (obj != null && !(obj instanceof Undefined) &&
                        !(obj instanceof UniqueTag)) {
                    throw new CarbonException("Invalid value for property '" + RampartConfig.TS_PRECISION_IN_MS_LN +
                            "' in rampart configuration");
                }

                //sets crypto configs
                Object cryptoObject = wsRequest.rampartConfig.get(RampartConfig.SIG_CRYPTO_LN, wsRequest.rampartConfig);
                if (cryptoObject instanceof NativeObject) {
                    rampartConfig.setSigCryptoConfig(getCryptoConfig(wsRequest, (NativeObject) cryptoObject));
                }
                cryptoObject = wsRequest.rampartConfig.get(RampartConfig.ENCR_CRYPTO_LN, wsRequest.rampartConfig);
                if (cryptoObject instanceof NativeObject) {
                    rampartConfig.setEncrCryptoConfig(getCryptoConfig(wsRequest, (NativeObject) cryptoObject));
                }
                cryptoObject = wsRequest.rampartConfig.get(RampartConfig.DEC_CRYPTO_LN, wsRequest.rampartConfig);
                if (cryptoObject instanceof NativeObject) {
                    rampartConfig.setEncrCryptoConfig(getCryptoConfig(wsRequest, (NativeObject) cryptoObject));
                }
                cryptoObject = wsRequest.rampartConfig.get(RampartConfig.STS_CRYPTO_LN, wsRequest.rampartConfig);
                if (cryptoObject instanceof NativeObject) {
                    rampartConfig.setSigCryptoConfig(getCryptoConfig(wsRequest, (NativeObject) cryptoObject));
                }

                Object kerberosConfig = wsRequest.rampartConfig.get(RampartConfig.KERBEROS_CONFIG, wsRequest.rampartConfig);
                if (kerberosConfig instanceof NativeObject) {
                    rampartConfig.setKerberosConfig(getKerberosConfigs(wsRequest, (NativeObject) kerberosConfig));
                }
            }

            PasswordCallbackHandler passwordCallbackHandler = new PasswordCallbackHandler();
            wsRequest.sender.getAxisService().addParameter(WSHandlerConstants.PW_CALLBACK_REF,
                    passwordCallbackHandler);
            String property = getObjectProperty(wsRequest.rampartConfig, RampartConfig.USER_LN);
            if (property != null) {
                rampartConfig.setUser(property);
                useUT = true;
            }
            property = getObjectProperty(wsRequest.rampartConfig, "userPassword");
            if (property != null) {
                passwordCallbackHandler.setUserPassword(property);
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.