Package org.apache.wss4j.policy.model

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


    // See https://issues.apache.org/jira/browse/WSS-222
    protected void verifySignatureAlgorithms(Document signedDoc, AssertionInfoMap aim) throws Exception {
        final AssertionInfo assertInfo = aim.get(SP12Constants.ASYMMETRIC_BINDING).iterator().next();
        assertNotNull(assertInfo);
       
        final AsymmetricBinding binding = (AsymmetricBinding) assertInfo.getAssertion();
        final String expectedSignatureMethod = binding.getAlgorithmSuite().getAsymmetricSignature();
        final String expectedDigestAlgorithm =
            binding.getAlgorithmSuite().getAlgorithmSuiteType().getDigest();
        final String expectedCanonAlgorithm  = binding.getAlgorithmSuite().getC14n().getValue();
           
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        final NamespaceContext nsContext = this.getNamespaceContext();
        xpath.setNamespaceContext(nsContext);
View Full Code Here


        if (transAis != null) {
            TransportBinding binding = (TransportBinding)transAis.getAssertion();
            new StaxTransportBindingHandler(
                securityProperties, msg, binding, outboundSecurityContext).handleBinding();
        } else if (asymAis != null) {
            AsymmetricBinding binding = (AsymmetricBinding)asymAis.getAssertion();
            new StaxAsymmetricBindingHandler(
                securityProperties, msg, binding, outboundSecurityContext).handleBinding();
        } else if (symAis != null) {
            SymmetricBinding binding = (SymmetricBinding)symAis.getAssertion();
            new StaxSymmetricBindingHandler(
View Full Code Here

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

        int count = 0;
        while (alternativeIterator.hasNext()) {
            List<Assertion> alternative = alternativeIterator.next();
            assertEquals(1, alternative.size());
            assertTrue(alternative.get(0) instanceof AsymmetricBinding);
            AsymmetricBinding asymmetricBinding = (AsymmetricBinding) alternative.get(0);
            assertFalse(asymmetricBinding.isNormalized());
            assertTrue(asymmetricBinding.isIgnorable());
            assertTrue(asymmetricBinding.isOptional());
            assertEquals(Constants.TYPE_ASSERTION, asymmetricBinding.getType());
            assertEquals(SP12Constants.ASYMMETRIC_BINDING, asymmetricBinding.getName());
            assertNotNull(asymmetricBinding.getInitiatorEncryptionToken());
            assertNotNull(asymmetricBinding.getInitiatorSignatureToken());
            assertNull(asymmetricBinding.getInitiatorToken());
            assertNotNull(asymmetricBinding.getRecipientEncryptionToken());
            assertNotNull(asymmetricBinding.getRecipientSignatureToken());
            assertNull(asymmetricBinding.getRecipientToken());
            assertNotNull(asymmetricBinding.getAlgorithmSuite());
            assertNotNull(asymmetricBinding.getLayout());
            assertEquals(AbstractSymmetricAsymmetricBinding.ProtectionOrder.EncryptBeforeSigning, asymmetricBinding.getProtectionOrder());
            assertTrue(asymmetricBinding.isEncryptSignature());
            assertTrue(asymmetricBinding.isIncludeTimestamp());
            assertTrue(asymmetricBinding.isOnlySignEntireHeadersAndBody());
            assertTrue(asymmetricBinding.isProtectTokens());
            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();
        AsymmetricBinding asymmetricBinding = (AsymmetricBinding) policyComponentIterator.next();
        assertTrue(asymmetricBinding.isNormalized());
        assertTrue(asymmetricBinding.isIgnorable());
        assertFalse(asymmetricBinding.isOptional());
        assertEquals(Constants.TYPE_ASSERTION, asymmetricBinding.getType());
        assertEquals(SP12Constants.ASYMMETRIC_BINDING, asymmetricBinding.getName());
        assertNotNull(asymmetricBinding.getInitiatorEncryptionToken());
        assertNotNull(asymmetricBinding.getInitiatorSignatureToken());
        assertNull(asymmetricBinding.getInitiatorToken());
        assertNotNull(asymmetricBinding.getRecipientEncryptionToken());
        assertNotNull(asymmetricBinding.getRecipientSignatureToken());
        assertNull(asymmetricBinding.getRecipientToken());
        assertNotNull(asymmetricBinding.getAlgorithmSuite());
        assertNotNull(asymmetricBinding.getLayout());
        assertEquals(AbstractSymmetricAsymmetricBinding.ProtectionOrder.EncryptBeforeSigning, asymmetricBinding.getProtectionOrder());
        assertTrue(asymmetricBinding.isEncryptSignature());
        assertTrue(asymmetricBinding.isIncludeTimestamp());
        assertTrue(asymmetricBinding.isOnlySignEntireHeadersAndBody());
        assertTrue(asymmetricBinding.isProtectTokens());
    }
View Full Code Here

       
        if (!transAis.isEmpty()) {
            TransportBinding binding = (TransportBinding)transAis.iterator().next().getAssertion();
            new StaxTransportBindingHandler(getProperties(), msg, binding, outboundTokens).handleBinding();
        } else if (!asymAis.isEmpty()) {
            AsymmetricBinding binding = (AsymmetricBinding)asymAis.iterator().next().getAssertion();
            new StaxAsymmetricBindingHandler(getProperties(), msg, binding, outboundTokens).handleBinding();
        } else if (!symAis.isEmpty()) {
            SymmetricBinding binding = (SymmetricBinding)symAis.iterator().next().getAssertion();
            new StaxSymmetricBindingHandler(getProperties(), msg, binding, outboundTokens).handleBinding();
        } else {
View Full Code Here

    // See https://issues.apache.org/jira/browse/WSS-222
    protected void verifySignatureAlgorithms(Document signedDoc, AssertionInfoMap aim) throws Exception {
        final AssertionInfo assertInfo = aim.get(SP12Constants.ASYMMETRIC_BINDING).iterator().next();
        assertNotNull(assertInfo);
       
        final AsymmetricBinding binding = (AsymmetricBinding) assertInfo.getAssertion();
        final String expectedSignatureMethod = binding.getAlgorithmSuite().getAsymmetricSignature();
        final String expectedDigestAlgorithm =
            binding.getAlgorithmSuite().getAlgorithmSuiteType().getDigest();
        final String expectedCanonAlgorithm  = binding.getAlgorithmSuite().getC14n().getValue();
           
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        final NamespaceContext nsContext = this.getNamespaceContext();
        xpath.setNamespaceContext(nsContext);
View Full Code Here

                break;
            }
        }
       
        for (AssertionInfo ai : ais) {
            AsymmetricBinding binding = (AsymmetricBinding)ai.getAssertion();
            ai.setAsserted(true);

            // Check the protection order
            if (!checkProtectionOrder(binding, aim, ai, results)) {
                continue;
View Full Code Here

        Policy policy = policyBuilder.getPolicy(this.getResourceAsStream(policyName));
        AssertionInfoMap aim = new AssertionInfoMap(policy);

        AssertionInfo assertInfo = aim.get(SP12Constants.ASYMMETRIC_BINDING).iterator().next();

        AsymmetricBinding binding = (AsymmetricBinding) assertInfo.getAssertion();

        // set Signature Algorithm to RSA SHA-256
        binding.getAlgorithmSuite().setAsymmetricSignature(rsaSha2SigMethod);

        String sigMethod = binding.getAlgorithmSuite().getAsymmetricSignature();

        assertNotNull(sigMethod);
        assertEquals(rsaSha2SigMethod, sigMethod);
    }
View Full Code Here

        if (transAis != null) {
            TransportBinding binding = (TransportBinding)transAis.getAssertion();
            new StaxTransportBindingHandler(
                securityProperties, msg, binding, outboundSecurityContext).handleBinding();
        } else if (asymAis != null) {
            AsymmetricBinding binding = (AsymmetricBinding)asymAis.getAssertion();
            new StaxAsymmetricBindingHandler(
                securityProperties, msg, binding, outboundSecurityContext).handleBinding();
        } else if (symAis != null) {
            SymmetricBinding binding = (SymmetricBinding)symAis.getAssertion();
            new StaxSymmetricBindingHandler(
View Full Code Here

       
        if (!transAis.isEmpty()) {
            TransportBinding binding = (TransportBinding)transAis.iterator().next().getAssertion();
            new StaxTransportBindingHandler(securityProperties, msg, binding, outboundTokens).handleBinding();
        } else if (!asymAis.isEmpty()) {
            AsymmetricBinding binding = (AsymmetricBinding)asymAis.iterator().next().getAssertion();
            new StaxAsymmetricBindingHandler(securityProperties, msg, binding, outboundTokens).handleBinding();
        } else if (!symAis.isEmpty()) {
            SymmetricBinding binding = (SymmetricBinding)symAis.iterator().next().getAssertion();
            new StaxSymmetricBindingHandler(securityProperties, msg, binding, outboundTokens).handleBinding();
        } else {
View Full Code Here

TOP

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

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.