Package org.apache.neethi.builders.xml

Examples of org.apache.neethi.builders.xml.XmlPrimtiveAssertion


    }

    private void processElements(List policyComponents,
            SandeshaPolicyBean propertyBean) {

        XmlPrimtiveAssertion xmlPrimtiveAssertion;

        for (Iterator iterator = policyComponents.iterator(); iterator
                .hasNext();) {
            xmlPrimtiveAssertion = (XmlPrimtiveAssertion) iterator.next();
            OMElement element = xmlPrimtiveAssertion.getValue();
            String name = element.getLocalName();

            if (Sandesha2Constants.Assertions.ELEM_ACK_INTERVAL.equals(name)) {
                propertyBean.setAcknowledgementInterval(Long.parseLong(element
                        .getText().trim()));
View Full Code Here


    }

    private void processElements(List policyComponents,
            SandeshaPolicyBean propertyBean) {

        XmlPrimtiveAssertion xmlPrimtiveAssertion;

        for (Iterator iterator = policyComponents.iterator(); iterator
                .hasNext();) {
            xmlPrimtiveAssertion = (XmlPrimtiveAssertion) iterator.next();
            OMElement element = xmlPrimtiveAssertion.getValue();
            String name = element.getLocalName();

            if (Sandesha2Constants.Assertions.ELEM_ACK_INTERVAL.equals(name)) {
                propertyBean.setAcknowledgementInterval(Long.parseLong(element
                        .getText().trim()));
View Full Code Here

    }
   
    private void processAlternative(List assertions, TransportToken parent) {
       
        for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
            XmlPrimtiveAssertion primtive = (XmlPrimtiveAssertion) iterator.next();
            QName qname = primtive.getName();
           
            if (SP12Constants.HTTPS_TOKEN.equals(qname)) {
                HttpsToken httpsToken = new HttpsToken(SPConstants.SP_V12);
               
                OMElement element = primtive.getValue().getFirstChildWithName(SPConstants.POLICY);
               
                if (element != null) {

                    if (element.getFirstChildWithName(SP12Constants.REQUIRE_CLIENT_CERTIFICATE) != null) {
                        httpsToken.setRequireClientCertificate(true);
View Full Code Here

                Collection policyComponents = policy.getPolicyComponents();

                handlePolicyComponents(relayConfiguration, policyComponents);
            } else if (topLevelAssertionObject instanceof XmlPrimtiveAssertion) {

                XmlPrimtiveAssertion tlxa = (XmlPrimtiveAssertion) topLevelAssertionObject;

                QName qName = tlxa.getName();

                // validating the relay assertion
                if (!qName.equals(RelayConstants.RELAY_ASSERSION_QNAME)) {
                    return false;
                }

                Policy rpc = PolicyEngine.getPolicy(tlxa.getValue());

                for (Object configAssertion : rpc.getPolicyComponents()) {
                    // Validating the relay policy
                    if (!(configAssertion instanceof Policy)) {
                        return false;
                    }

                    Policy cachingPolicy = (Policy) configAssertion;
                    List childAssertionsList = cachingPolicy.getPolicyComponents();

                    for (Object configData : childAssertionsList) {
                        if (!(configData instanceof All)) {
                            handleException("Unexpected relay " +
                                    "policy, \"wsp:All\" expected");
                        }

                        All all = (All) configData;
                        List configDataList = all.getPolicyComponents();
                        for (Object configDtaObject : configDataList) {
                            if (!(configDtaObject instanceof XmlPrimtiveAssertion)) {
                                // invalid relay policy
                                handleException("Unexpected relay policy " +
                                        "assertion for the relay module");

                            }
                            XmlPrimtiveAssertion assertion
                                    = (XmlPrimtiveAssertion) configDtaObject;

                            if (assertion.getName().equals(
                                    RelayConstants.INCLUDE_HIDDEN_SERVICES_QNAME)) {
                                String value = assertion.getValue().getText();
                                relayConfiguration.setIncludeHiddenServices(
                                        Boolean.parseBoolean(value));
                            }

                            if (assertion.getName().equals(
                                    RelayConstants.BUILDERS_QNAME) &&
                                    assertion.getValue() != null) {
                                processBuilders(assertion.getValue(), relayConfiguration);
                            }

                            if (assertion.getName().equals(
                                    RelayConstants.SERVICES_QNAME) &&
                                    assertion.getValue() != null) {
                                processServices(assertion.getValue(), relayConfiguration);
                            }
                        }
                    }
                }
            } else {
View Full Code Here

     * @return an <code>XmlPrimtiveAssertion</code> array containing the four caching assertions.
     */
    public XmlPrimtiveAssertion[] retrieveConfigPrimitiveAssertions(
            Policy cachingPolicyComponent) {
        XmlPrimtiveAssertion[] assertionArr = new XmlPrimtiveAssertion[4];
        XmlPrimtiveAssertion primitiveAssertion;
        QName assertionName;
        for (Object policyObject : cachingPolicyComponent.getPolicyComponents()) {
            if (policyObject instanceof Policy) {
                for (Object allObject : ((Policy) policyObject).getPolicyComponents()) {
                    if (allObject instanceof All) {
                        for (Object assertionObject : ((All) allObject).getPolicyComponents()) {
                            if (assertionObject instanceof XmlPrimtiveAssertion) {
                                primitiveAssertion = (XmlPrimtiveAssertion) assertionObject;
                                if ((assertionName = primitiveAssertion.getName()).equals(
                                        CachingComponentConstants.XML_IDENTIFIER_QNAME)) {
                                    assertionArr[0] = primitiveAssertion;
                                } else if (assertionName.equals(
                                        CachingComponentConstants.CACHE_EXPIRATION_TIME_QNAME)) {
                                    assertionArr[1] = primitiveAssertion;
View Full Code Here

                    Object object = iterator.next();
                    if (object instanceof List) {
                        List list = (List) object;
                        for (Object assertObj : list) {
                            if (assertObj instanceof XmlPrimtiveAssertion) {
                                XmlPrimtiveAssertion primitiveAssertion = (XmlPrimtiveAssertion)
                                        assertObj;
                                if (primitiveAssertion.getName().equals(CachingComponentConstants
                                        .CACHING_ASSERTION_QNAME)) {
                                    return new Policy[]{PolicyEngine
                                            .getPolicy(primitiveAssertion.getValue()), parentPolicy};
                                }

                            }
                        }
                    }
View Full Code Here

                All all = (All) topLevelAssertionObject;
                handlePolicyComponents(cacheConfig, all.getPolicyComponents());
            } else if (topLevelAssertionObject instanceof XmlPrimtiveAssertion) {
                // Validating the policy

                XmlPrimtiveAssertion topLevelXmlPrimtiveAssertion
                        = (XmlPrimtiveAssertion) topLevelAssertionObject;
                QName qName = topLevelXmlPrimtiveAssertion.getName();
                // validating the Caching assertion
                if (qName.equals(CachingConstants.CACHING_ASSERTION_QNAME)) {

                    Policy cachingPolicyComponent
                            = PolicyEngine.getPolicy(topLevelXmlPrimtiveAssertion.getValue());
                    List assertionList = cachingPolicyComponent.getPolicyComponents();
                    for (Iterator configDataAssertionIterator = assertionList.iterator();
                         configDataAssertionIterator.hasNext();) {

                        Object aConfigDataAssertionObject = configDataAssertionIterator.next();
                        // Validating the caching policy
                        if (aConfigDataAssertionObject instanceof Policy) {

                            long expireTime;
                            DigestGenerator digestGenerator;
                            int maxMessageSize;
                            int maxCacheSize;

                            Policy cachingPolicy = (Policy) aConfigDataAssertionObject;
                            List childAssertionsList = cachingPolicy.getPolicyComponents();
                            for (Iterator childAssertionSIterator = childAssertionsList
                                    .iterator(); childAssertionSIterator.hasNext();) {

                                Object configData = childAssertionSIterator.next();
                                if (configData instanceof All) {

                                    All all = (All) configData;
                                    List configDataList = all.getPolicyComponents();
                                    for (Iterator configIterator = configDataList
                                            .iterator(); configIterator.hasNext();) {

                                        Object configDtaObject = configIterator.next();
                                        if (configDtaObject instanceof XmlPrimtiveAssertion) {

                                            XmlPrimtiveAssertion cachingPrimtiveAssertion
                                                    = (XmlPrimtiveAssertion) configDtaObject;
                                            //todo : break the processing
                                            // Is Identifier specified?
                                            if (cachingPrimtiveAssertion.getName().equals(
                                                    CachingConstants.CACHING_XML_IDENTIFIER_QNAME)) {

                                                String value
                                                        = cachingPrimtiveAssertion.getValue()
                                                        .getText();
                                                try {

                                                    // Loading the class using Reflection
                                                    digestGenerator = (DigestGenerator)
                                                            Class.forName(value).newInstance();
                                                    cacheConfig.setDigestGenerator(digestGenerator);

                                                } catch (ClassNotFoundException e) {

                                                    handleException("Unable to find the " +
                                                            "DigestGenerator implementation \"" +
                                                            value + "\"", e);

                                                } catch (IllegalAccessException e) {

                                                    handleException("Unable to load the " +
                                                            "DigestGenerator implementation \"" +
                                                            value + "\"", e);

                                                } catch (InstantiationException e) {

                                                    handleException("Unable to instantiate the " +
                                                            "DigestGenerator implementation \"" +
                                                            value + "\"", e);

                                                }
                                            }

                                            // Is expiration time specified?
                                            if (cachingPrimtiveAssertion.getName().equals(
                                                    CachingConstants.CACHE_EXPIRATION_TIME_QNAME) &&
                                                    cachingPrimtiveAssertion.getValue() != null) {

                                                expireTime = Long.parseLong(
                                                        cachingPrimtiveAssertion
                                                                .getValue().getText());
                                                cacheConfig.setTimeout(expireTime);
                                            }

                                            // Is max message size specified?
                                            if (cachingPrimtiveAssertion.getName().equals(
                                                    CachingConstants.MAX_MESSAGE_SIZE_QNAME) &&
                                                    cachingPrimtiveAssertion.getValue() != null) {

                                                maxMessageSize = Integer.parseInt(
                                                        cachingPrimtiveAssertion
                                                                .getValue().getText());
                                                cacheConfig.setMaxMessageSize(maxMessageSize);
                                            }

                                            // Is max cache size specified?
                                            if (cachingPrimtiveAssertion.getName().equals(
                                                    CachingConstants.MAX_CACHE_SIZE_QNAME) &&
                                                    cachingPrimtiveAssertion.getValue() != null) {

                                                maxCacheSize = Integer.parseInt(
                                                        cachingPrimtiveAssertion
                                                                .getValue().getText());
                                                cacheConfig.setMaxCacheSize(maxCacheSize);
                                            }

                                        } else {
View Full Code Here

            if (object instanceof List) {
                List list = (List) object;
                for (Iterator it = list.iterator(); it.hasNext();) {
                    Object assertObj = it.next();
                    if (assertObj instanceof XmlPrimtiveAssertion) {
                        XmlPrimtiveAssertion primitiveAssertion = (XmlPrimtiveAssertion)
                                assertObj;
                        QName qName = primitiveAssertion.getName();

                        if (qName == null) {
                            handleException("Invalid Throttle Policy - QName of the " +
                                    "assertion cannot be null.");
                        }
                        // top policy must contains ThrottleAssertion
                        Policy throttlePolicy = PolicyEngine.
                                getPolicy(primitiveAssertion.getValue());
                        if (ThrottleConstants.THROTTLE_ASSERTION_QNAME.equals(qName)) {
                            return ThrottlePolicyProcessor.processPolicy(throttlePolicy);
                        } else if (forceRoot.equals(qName)) {
                            return buildThrottle(throttlePolicy);
                        } else {
View Full Code Here

                if (assertList != null) {
                    for (Iterator assertIterator =
                            assertList.iterator(); assertIterator.hasNext();) {
                        Object ca = assertIterator.next();
                        if (ca instanceof XmlPrimtiveAssertion) {
                            XmlPrimtiveAssertion id = (XmlPrimtiveAssertion) ca;
                            configuration = createThrottleConfiguration(id, throttle);
                            if (configuration == null) {
                                handleException("Invalid throttle - Throttle configuration " +
                                        "cannot be created from given policy");
                            }

                            if (configuration.getType() == ThrottleConstants.IP_BASE) {
                                //create a caller context for ip based throttle
                                callerConfiguration = CallerConfigurationFactory.
                                        createCallerConfiguration(
                                                ThrottleConstants.IP_BASE);
                            } else if (configuration.getType() == ThrottleConstants.DOMAIN_BASE) {
                                //create a caller context for ip based throttle
                                callerConfiguration = CallerConfigurationFactory.
                                        createCallerConfiguration(
                                                ThrottleConstants.DOMAIN_BASE);
                            } else {
                                handleException("Invalid throttle type - Only" +
                                        " support IP and DOMAIN as types ");
                            }
                            if (callerConfiguration != null) {
                                OMElement element = id.getValue();

                                // Name of the policy assertion
                                String name = element.getLocalName();
                                // Value of the policy assertion
                                String value = element.getText();

                                // If Value and Name  are null,
                                // then it is a invalid policy configuration
                                if (name == null || value == null) {
                                    handleException("Either Value or" +
                                            " Name of the policy cannot be null");
                                } else if (name.equals(ThrottleConstants.ID_PARAMETER_NAME)) {

                                    if (!value.equals("")) {
                                        callerConfiguration.setID(value);
                                    } else {
                                        handleException("Value of ID cannot find " +
                                                "- invalid configuration");
                                    }
                                } else {
                                    handleException("Undefined policy property for" +
                                            " throttle - Expect ID  ");
                                }
                            }


                        } else if (ca instanceof Policy) {
                            policy = (Policy) ca;
                        }
                    }
                }
                if (callerConfiguration != null) {
                    if (policy != null) {
                        fillCallerConfiguration(policy, callerConfiguration);
                        configuration.addCallerConfiguration(callerConfiguration);
                    }

                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Couldn't find a callerConfiguration for a throttle" +
                                " configuration for an one caller  ");
                    }
                }

            } else if (object instanceof XmlPrimtiveAssertion) {

                XmlPrimtiveAssertion xmlPrimitiveAssertion = (XmlPrimtiveAssertion) object;
                OMElement element = xmlPrimitiveAssertion.getValue();
                // Name of the policy assertion
                String name = element.getLocalName();
                //Value of the policy assertion
                String value = element.getText();
View Full Code Here

    private static void fillCallerConfiguration(Policy policy, CallerConfiguration callerConfiguration) throws ThrottleException {
        List list = policy.getPolicyComponents();
        for (Iterator iterator = list.iterator(); iterator.hasNext();) {
            Object object = iterator.next();

            XmlPrimtiveAssertion primitiveAssertion = (XmlPrimtiveAssertion) object;
            OMElement element = primitiveAssertion.getValue();
            // Name of the policy assertion
            String name = element.getLocalName();
            if (name.equals(
                    ThrottleConstants.ALLOW_PARAMETER_NAME)) {

                callerConfiguration.setAccessState(
                        ThrottleConstants.ACCESS_ALLOWED);

            } else if (name.equals(
                    ThrottleConstants.DENY_PARAMETER_NAME)) {

                callerConfiguration.setAccessState(
                        ThrottleConstants.ACCESS_DENIED);

            } else if (name.equals(
                    ThrottleConstants.CONTROL_PARAMETER_NAME)) {

                callerConfiguration.setAccessState(
                        ThrottleConstants.ACCESS_CONTROLLED);
                OMElement controlElement = primitiveAssertion.getValue();
                if (controlElement == null) {
                    handleException("Invalid throttle configuration - " +
                            "Control assertion cannot be empty");
                }
View Full Code Here

TOP

Related Classes of org.apache.neethi.builders.xml.XmlPrimtiveAssertion

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.