Package org.apache.rampart.policy.model

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


                Properties kerberosProperties = new Properties();
                kerberosProperties.setProperty(KerberosConfig.SERVICE_PRINCIPLE_NAME,
                        kerberosConfigurations.getServicePrincipleName());

                KerberosConfig kerberosConfig = new KerberosConfig();
                kerberosConfig.setProp(kerberosProperties);

                // Set system wide kerberos configurations

                String carbonConfig = CarbonUtils.getCarbonConfigDirPath();
                if (carbonConfig != null) {
View Full Code Here


    protected WSSecKerberosToken getKerberosTokenBuilder(RampartMessageData rmd, Token token)
            throws RampartException {

        RampartPolicyData rpd = rmd.getPolicyData();
        KerberosConfig krbConfig = rpd.getRampartConfig().getKerberosConfig();

        if (krbConfig == null || krbConfig.getProp() == null) {
            throw new RampartException("noKerberosConfigDefined");
        }

        WSSecKerberosToken krb = new WSSecKerberosToken();
        krb.setWsConfig(rmd.getConfig());

        log.debug("Token inclusion: " + token.getInclusion());

        RampartUtil.setKeyIdentifierType(rmd, krb, token);

        String user = null;
        String passwordFromConfig = null;
        String clientPricipal = null;
        String servicePrincipal = null;
        String password = null;
        String service = null;

        clientPricipal = (String) rmd.getMsgContext().getProperty(
                KerberosConfig.CLIENT_PRINCIPLE_NAME);
        servicePrincipal = (String) rmd.getMsgContext().getProperty(
                KerberosConfig.SERVICE_PRINCIPLE_NAME);

        if (clientPricipal == null || servicePrincipal == null) {
            // Get the user from kerberos configuration
            user = krbConfig.getProp().getProperty(KerberosConfig.CLIENT_PRINCIPLE_NAME);
            passwordFromConfig = krbConfig.getProp().getProperty(
                    KerberosConfig.CLIENT_PRINCIPLE_PASSWORD);
            if (passwordFromConfig == null) {
                passwordFromConfig = krbConfig.getProp().getProperty(
                        KerberosConfig.SERVICE_PRINCIPLE_PASSWORD);
            }

            // If kerberos user is not present, use user property as Alias
            if (user == null) {
                user = rpd.getRampartConfig().getUser();
            }

            if (user != null && !"".equals(user)) {
                log.debug("User : " + user);

                // Get the password
                CallbackHandler handler = RampartUtil.getPasswordCB(rmd);

                if (handler != null) {
                    WSPasswordCallback[] cb = { new WSPasswordCallback(user,
                            WSPasswordCallback.KERBEROS_TOKEN) };
                    try {
                        handler.handle(cb);
                        if (cb[0].getPassword() != null && !"".equals(cb[0].getPassword())) {
                            password = cb[0].getPassword();
                            log.debug("Password : " + password);
                        } else {
                            password = passwordFromConfig;
                        }
                    } catch (IOException e) {
                        throw new RampartException("errorInGettingPasswordForUser",
                                new String[] { user }, e);
                    } catch (UnsupportedCallbackException e) {
                        throw new RampartException("errorInGettingPasswordForUser",
                                new String[] { user }, e);
                    }
                } else {
                    password = passwordFromConfig;
                }

            }
            service = krbConfig.getProp().getProperty(KerberosConfig.SERVICE_PRINCIPLE_NAME);
        } else {
            user = clientPricipal;
            service = servicePrincipal;
        }
View Full Code Here

                    } else {
                        if (encrTok != null) {
                            byte[] secret = encrTok.getSecret();
                            int factor = 0;
                            if (rmd.getPolicyData().getRampartConfig() != null) {
                                KerberosConfig config = null;
                                String fac = null;
                                config = rmd.getPolicyData().getRampartConfig().getKerberosConfig();
                                if ((fac = config.getProp().getProperty(
                                        KerberosConfig.KDC_DES_AES_FACTOR)) != null) {
                                    try {
                                        factor = Integer.parseInt(fac);
                                    } catch (Exception e) {
                                        factor = 0;
View Full Code Here

            } else if (callbacks[i] instanceof WSParameterCallback) {
                WSParameterCallback para = (WSParameterCallback) callbacks[i];
                if (para.getProperty() == WSParameterCallback.KDC_DES_AES_FACTOR) {
                    if (config != null) {
                        KerberosConfig krbConfig = config.getKerberosConfig();
                        int factor = 0;
                        String fac = null;
                        if (krbConfig != null
                                && (fac = krbConfig.getProp().getProperty(
                                        KerberosConfig.KDC_DES_AES_FACTOR)) != null) {
                            try {
                                factor = Integer.parseInt(fac);
                            } catch (Exception e) {
                                factor = 0;
                            }
                        }
                        para.setIntValue(factor);
                    }
                } else if (para.getProperty() == WSParameterCallback.SERVICE_PRINCIPLE_PASSWORD) {
                    if (config != null) {
                        KerberosConfig krbConfig = config.getKerberosConfig();
                        String password = null;
                        if (krbConfig != null
                                && (password = krbConfig.getProp().getProperty(
                                        KerberosConfig.SERVICE_PRINCIPLE_PASSWORD)) != null) {
                            para.setStringValue(password);
                        }
                    }
                }
View Full Code Here

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

        KerberosConfig krbConfig = new KerberosConfig();
        Properties properties = new Properties();
        OMElement childElement;
        OMAttribute name;
        String value;
        String attrName;

        for (Iterator iterator = element.getChildElements(); iterator.hasNext();) {
            childElement = (OMElement) iterator.next();
            QName prop = new QName(RampartConfig.NS, KerberosConfig.PROPERTY_LN);
            if (prop.equals(childElement.getQName())) {
                name = childElement.getAttribute(new QName(KerberosConfig.PROPERTY_NAME_ATTR));
                value = childElement.getText();
                attrName = name.getAttributeValue();
                // TODO: Need to get rid of these system properties.
                if (attrName != null
                        && (attrName.startsWith("java.") || attrName.startsWith("javax."))) {
                    // setting the jsse properties to the vm
                    System.setProperty(attrName.trim(), value.trim());
                }
                properties.put(attrName.trim(), value.trim());
            }
        }
        krbConfig.setProp(properties);
        return krbConfig;
    }
View Full Code Here

        }
       
        childElement = element.getFirstChildWithName(new QName(
                RampartConfig.NS, RampartConfig.KERBEROS_CONFIG));
        if (childElement != null) {                            
            KerberosConfig krbConfig = (KerberosConfig)new KerberosConfigBuilder().
                                      build(childElement,
                                      factory);
            rampartConfig.setKerberosConfig(krbConfig);
           
        }
View Full Code Here

        return property.replaceAll("(\\$\\{resources.dir\\})", resourcePath);
    }

    private static KerberosConfig getKerberosConfigs(WSRequestHostObject wsRequest, NativeObject configs)
            throws CarbonException {
        KerberosConfig kerberosConfig = new KerberosConfig();
        Properties properties = new Properties();
        Object[] objects = NativeObject.getPropertyIds(configs);
        for (Object object : objects) {
            if (object instanceof String) {
                String property = (String) object;
                Object value = configs.get(property, configs);
                if (value instanceof String) {
                    properties.setProperty(property, filterProperty(wsRequest, (String) value));
                } else {
                    throw new CarbonException("Invalid config value for the property : " + property +
                            " in Kerberos Config");
                }
            } else {
                throw new CarbonException("Invalid property in Kerberos Config");
            }
        }
        kerberosConfig.setProp(properties);
        return kerberosConfig;

    }
View Full Code Here

        crypto = config.getStsCryptoConfig();
        if (crypto != null) {
            filterCryptoConfig(wsRequest, crypto);
        }

        KerberosConfig kerberosConfig = config.getKerberosConfig();
        if (kerberosConfig != null) {
            Properties properties = kerberosConfig.getProp();
            for (String key : properties.stringPropertyNames()) {
                properties.setProperty(key, filterProperty(wsRequest, properties.getProperty(key)));
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.rampart.policy.model.KerberosConfig

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.