Package org.apache.neethi

Examples of org.apache.neethi.Policy


        final Document originalDoc = this.readDocument("wsse-request-clean.xml");
       
        final Element outPolicyElement =
                this.readDocument(policyDoc).getDocumentElement();
      
        final Policy outPolicy = this.policyBuilder.getPolicy(outPolicyElement);
        final AssertionInfoMap aim = new AssertionInfoMap(outPolicy);
       
        final Document signedDoc = this.runOutInterceptorAndValidate(
                originalDoc, outPolicy, Arrays.asList(SP12Constants.ASYMMETRIC_BINDING), null);
       
View Full Code Here


    private void runOutInterceptorAndValidateSamlTokenAttached(String policyDoc) throws Exception {
        // create the request message
        final Document document = this.readDocument("wsse-request-clean.xml");
        final Element outPolicyElement =
            this.readDocument(policyDoc).getDocumentElement();
        final Policy policy = this.policyBuilder.getPolicy(outPolicyElement);
       
        AssertionInfoMap aim = new AssertionInfoMap(policy);       
        SoapMessage msg = this.getOutSoapMessageForDom(document, aim);
       
        // add an "issued" assertion into the message exchange
View Full Code Here

                        // forget about this attachment
                        continue;
                    }
                    attachment.setDomainExpressions(des);                   
                } else if (PolicyConstants.isPolicyElem(qn)) {
                    Policy p = builder.getPolicy((Element)nd);
                    if (null != attachment.getPolicy()) {
                        p = p.merge(attachment.getPolicy());
                    }
                    attachment.setPolicy(p);
                } else if (PolicyConstants.isPolicyRefElem(qn)) {
                    PolicyReference ref = builder.getPolicyReference((Element)nd);
                    if (null != ref) {  
                        Policy p = resolveReference(ref, doc);
                        if (null != attachment.getPolicy()) {
                            p = p.merge(attachment.getPolicy());
                        }
                        attachment.setPolicy(p);
                    }                   
                } // TODO: wsse:Security child element
            }
View Full Code Here

    }
   
    @Test
    public void testUpdatePolicyWithEmptyAll() {
       
        Policy emptyPolicy = new Policy();
        emptyPolicy.addPolicyComponent(new All());
        emptyPolicy.addPolicyComponent(new All());
        doTestUpdateWithEmptyPolicy(emptyPolicy);
    }
View Full Code Here

            attachments.add(attachment);
        }
    }
   
    Policy resolveReference(PolicyReference ref, Document doc) {
        Policy p = null;
        if (isExternal(ref)) {
            p = resolveExternal(ref, doc.getBaseURI());
        } else {
            p = resolveLocal(ref, doc);
        }
View Full Code Here

    }
   
    Policy resolveLocal(PolicyReference ref, Document doc) {
        String relativeURI = ref.getURI().substring(1);
        String absoluteURI = doc.getBaseURI() + ref.getURI();
        Policy resolved = registry.lookup(absoluteURI);
        if (null != resolved) {
            return resolved;
        }
        ReferenceResolver resolver = new LocalDocumentReferenceResolver(doc, builder);
        resolved = resolver.resolveReference(relativeURI);
View Full Code Here

    }
   
    @Test
    public void testUpdatePolicyWithEmptyExactlyOneAndAll() {
       
        Policy emptyPolicy = new Policy();
        PolicyOperator exactlyOne = new ExactlyOne();
        exactlyOne.addPolicyComponent(new All());
        exactlyOne.addPolicyComponent(new All());
        emptyPolicy.addPolicyComponent(exactlyOne);
        emptyPolicy.addPolicyComponent(new All());
        emptyPolicy.addPolicyComponent(new All());
        doTestUpdateWithEmptyPolicy(emptyPolicy);
    }   
View Full Code Here

        emptyPolicy.addPolicyComponent(new All());
        doTestUpdateWithEmptyPolicy(emptyPolicy);
    }   
   
    private void doTestUpdateWithEmptyPolicy(Policy emptyPolicy) {
        Policy p1 = new Policy();
        QName aqn1 = new QName("http://x.y.z", "a");
        p1.addAssertion(mockAssertion(aqn1, 5, true));
       
        EndpointPolicyImpl epi = new TestEndpointPolicy();
        control.replay();
       
        epi.setPolicy((Policy)p1.normalize(true));
               
        Policy ep = epi.updatePolicy(emptyPolicy).getPolicy();
       
        List<ExactlyOne> pops =
            CastUtils.cast(ep.getPolicyComponents(), ExactlyOne.class);
        assertEquals("New policy must have 1 top level policy operator", 1, pops.size());
        List<All> alts =
            CastUtils.cast(pops.get(0).getPolicyComponents(), All.class);
        assertEquals("1 alternatives should be available", 1, alts.size());
       
View Full Code Here

            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

        InitiatorToken initiatorToken = new InitiatorToken(consts, builder);
        initiatorToken.setOptional(PolicyConstants.isOptional(element));

        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
        policy = (Policy)policy.normalize(builder.getPolicyRegistry(), false);

        for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
            processAlternative((List)iterator.next(), initiatorToken);
            break; // TODO process all the token that must be set ..
        }

        return initiatorToken;
View Full Code Here

            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
       
       
        ProtectionToken protectionToken = new ProtectionToken(consts, builder);

        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
        policy = (Policy)policy.normalize(builder.getPolicyRegistry(), false);

        for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
            processAlternative((List)iterator.next(), protectionToken);
            break; // since there should be only one alternative ..
        }

        return protectionToken;
View Full Code Here

TOP

Related Classes of org.apache.neethi.Policy

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.