Package org.apache.wss4j.policy.model

Examples of org.apache.wss4j.policy.model.Layout


        };
    }

    @Override
    public boolean assertEvent(SecurityEvent securityEvent) throws WSSPolicyException {
        Layout layout = (Layout) getAssertion();
        switch (layout.getLayoutType()) {
            case Strict:
                //todo
                break;
            case Lax:
                //todo?
                break;
            case LaxTsFirst:
                if (occuredEvents.isEmpty() &&
                        !WSSecurityEventConstants.Timestamp.equals(securityEvent.getSecurityEventType())) {
                    setAsserted(false);
                    setErrorMessage("Policy enforces " + layout.getLayoutType() + " but " +
                            securityEvent.getSecurityEventType() + " occured first");
                }
                break;
            case LaxTsLast:
                if (occuredEvents.contains(WSSecurityEventConstants.Timestamp)) {
                    setAsserted(false);
                    setErrorMessage("Policy enforces " + layout.getLayoutType() + " but " +
                            securityEvent.getSecurityEventType() + " occured last");
                }
                break;
        }
        occuredEvents.add(securityEvent.getSecurityEventType());
View Full Code Here


        final Element nestedPolicyElement = SPUtils.getFirstPolicyChildElement(element);
        if (nestedPolicyElement == null) {
            throw new IllegalArgumentException("sp:Layout must have an inner wsp:Policy element");
        }
        final Policy nestedPolicy = factory.getPolicyEngine().getPolicy(nestedPolicyElement);
        Layout layout = new Layout(
                spVersion,
                nestedPolicy
        );
        layout.setOptional(SPUtils.isOptional(element));
        layout.setIgnorable(SPUtils.isIgnorable(element));
        return layout;
    }
View Full Code Here

        int count = 0;
        while (alternativeIterator.hasNext()) {
            List<Assertion> alternative = alternativeIterator.next();
            assertEquals(1, alternative.size());
            assertTrue(alternative.get(0) instanceof Layout);
            Layout layout = (Layout) alternative.get(0);
            assertFalse(layout.isNormalized());
            assertTrue(layout.isIgnorable());
            assertTrue(layout.isOptional());
            assertEquals(Constants.TYPE_ASSERTION, layout.getType());
            assertEquals(SP12Constants.LAYOUT, layout.getName());
            count++;
        }
        assertEquals(1, count);

        policy = policy.normalize(true);
        serializedPolicy = serializePolicy(policy);
        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);

        alternativeIterator = policy.getAlternatives();
        List<Assertion> alternative = alternativeIterator.next();
        assertEquals(0, alternative.size());

        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
        assertEquals(1, policyComponents.size());
        PolicyOperator policyOperator = (PolicyOperator) policyComponents.get(0);
        policyComponents = policyOperator.getPolicyComponents();
        assertEquals(2, policyComponents.size());
        All all = (All) policyComponents.get(0);
        List<PolicyComponent> policyComponentsAll = all.getAssertions();
        assertEquals(0, policyComponentsAll.size());

        all = (All) policyComponents.get(1);
        policyComponentsAll = all.getAssertions();
        assertEquals(1, policyComponentsAll.size());

        Iterator<PolicyComponent> policyComponentIterator = policyComponentsAll.iterator();
        Layout layout = (Layout) policyComponentIterator.next();
        assertTrue(layout.isNormalized());
        assertTrue(layout.isIgnorable());
        assertFalse(layout.isOptional());
        assertEquals(Constants.TYPE_ASSERTION, layout.getType());
        assertEquals(SP12Constants.LAYOUT, layout.getName());
    }
View Full Code Here

        };
    }

    @Override
    public boolean assertEvent(SecurityEvent securityEvent) throws WSSPolicyException {
        Layout layout = (Layout) getAssertion();
        switch (layout.getLayoutType()) {
            case Strict:
                //todo
                break;
            case Lax:
                //todo?
                break;
            case LaxTsFirst:
                if (occuredEvents.isEmpty() &&
                        !WSSecurityEventConstants.Timestamp.equals(securityEvent.getSecurityEventType())) {
                    setAsserted(false);
                    setErrorMessage("Policy enforces " + layout.getLayoutType() + " but " +
                            securityEvent.getSecurityEventType() + " occured first");
                }
                break;
            case LaxTsLast:
                if (occuredEvents.contains(WSSecurityEventConstants.Timestamp)) {
                    setAsserted(false);
                    setErrorMessage("Policy enforces " + layout.getLayoutType() + " but " +
                            securityEvent.getSecurityEventType() + " occured last");
                }
                break;
        }
        occuredEvents.add(securityEvent.getSecurityEventType());
View Full Code Here

            return false;
        }
        assertPolicy(aim, SPConstants.INCLUDE_TIMESTAMP);
       
        // Check the Layout
        Layout layout = binding.getLayout();
        LayoutPolicyValidator layoutValidator = new LayoutPolicyValidator(results, signedResults);
        if (!layoutValidator.validatePolicy(layout)) {
            String error = "Layout does not match the requirements";
            notAssertPolicy(aim, layout, error);
            ai.setNotAsserted(error);
View Full Code Here

        }
    }
   
    protected void configureLayout(AssertionInfoMap aim) {
        Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.LAYOUT);
        Layout layout = null;
        for (AssertionInfo ai : ais) {
            layout = (Layout)ai.getAssertion();
            Collection<AssertionInfo> layoutTypeAis = aim.get(layout.getName());
            if (layoutTypeAis != null) {
                for (AssertionInfo layoutAi : layoutTypeAis) {
                    layoutAi.setAsserted(true);
                }
            }
            ai.setAsserted(true);
        }
        if (layout != null && layout.getLayoutType() != null) {
            assertPolicy(new QName(layout.getName().getNamespaceURI(), layout.getLayoutType().name()));
        }
       
        if (!timestampAdded) {
            return;
        }
       
        Map<String, Object> config = getProperties();
        boolean timestampLast =
            layout != null && layout.getLayoutType() == LayoutType.LaxTsLast;
       
        if (config.containsKey(ConfigurationConstants.ACTION)) {
            String action = (String)config.get(ConfigurationConstants.ACTION);
            if (timestampLast) {
                config.put(ConfigurationConstants.ACTION,
View Full Code Here

                continue;
            }
            assertPolicy(aim, SPConstants.INCLUDE_TIMESTAMP);
           
            // Check the Layout
            Layout layout = binding.getLayout();
            LayoutPolicyValidator layoutValidator = new LayoutPolicyValidator(results, signedResults);
            if (!layoutValidator.validatePolicy(layout)) {
                String error = "Layout does not match the requirements";
                notAssertPolicy(aim, binding.getLayout(), error);
                ai.setNotAsserted(error);
View Full Code Here

        }
    }
   
    protected void configureLayout(AssertionInfoMap aim) {
        Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.LAYOUT);
        Layout layout = null;
        for (AssertionInfo ai : ais) {
            layout = (Layout)ai.getAssertion();
            Collection<AssertionInfo> layoutTypeAis = aim.get(layout.getName());
            if (layoutTypeAis != null) {
                for (AssertionInfo layoutAi : layoutTypeAis) {
                    layoutAi.setAsserted(true);
                }
            }
            ai.setAsserted(true);
        }
        if (layout != null && layout.getLayoutType() != null) {
            assertPolicy(new QName(layout.getName().getNamespaceURI(), layout.getLayoutType().name()));
        }
       
        if (!timestampAdded) {
            return;
        }
       
        boolean timestampLast =
            layout != null && layout.getLayoutType() == LayoutType.LaxTsLast;
       
        WSSConstants.Action actionToPerform = WSSConstants.TIMESTAMP;
        List<WSSConstants.Action> actionList = properties.getActions();
        if (timestampLast) {
            actionList.add(0, actionToPerform);
View Full Code Here

        Message message, 
        List<WSSecurityEngineResult> results,
        List<WSSecurityEngineResult> signedResults
    ) {
        for (AssertionInfo ai : ais) {
            Layout layout = (Layout)ai.getAssertion();
            ai.setAsserted(true);
           
            if (!validatePolicy(layout, results, signedResults)) {
                String error = "Layout does not match the requirements";
                ai.setNotAsserted(error);
View Full Code Here

        }
    }
   
    protected void configureLayout(AssertionInfoMap aim) {
        Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.LAYOUT);
        Layout layout = null;
        for (AssertionInfo ai : ais) {
            layout = (Layout)ai.getAssertion();
            Collection<AssertionInfo> layoutTypeAis = aim.get(layout.getName());
            if (layoutTypeAis != null) {
                for (AssertionInfo layoutAi : layoutTypeAis) {
                    layoutAi.setAsserted(true);
                }
            }
            ai.setAsserted(true);
        }
        if (layout != null && layout.getLayoutType() != null) {
            assertPolicy(new QName(layout.getName().getNamespaceURI(), layout.getLayoutType().name()));
        }
       
        if (!timestampAdded) {
            return;
        }
       
        boolean timestampLast =
            layout != null && layout.getLayoutType() == LayoutType.LaxTsLast;
       
        WSSConstants.Action actionToPerform = WSSConstants.TIMESTAMP;
        List<WSSConstants.Action> actionList = properties.getActions();
        if (timestampLast) {
            actionList.add(0, actionToPerform);
View Full Code Here

TOP

Related Classes of org.apache.wss4j.policy.model.Layout

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.