Java Code Examples for org.apache.neethi.Assertion#getName()

The following examples show how to use org.apache.neethi.Assertion#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IssuedTokenBuilder.java    From steady with Apache License 2.0 6 votes vote down vote up
private void processAlternative(List<Assertion> assertions, IssuedToken parent) {
    QName name;

    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (SPConstants.REQUIRE_DERIVED_KEYS.equals(name.getLocalPart())) {
            parent.setDerivedKeys(true);
        } else if (SPConstants.REQUIRE_EXTERNAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireExternalReference(true);
        } else if (SPConstants.REQUIRE_INTERNAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireInternalReference(true);
        }
    }

}
 
Example 2
Source File: IssuedTokenBuilder.java    From steady with Apache License 2.0 6 votes vote down vote up
private void processAlternative(List<Assertion> assertions, IssuedToken parent) {
    QName name;

    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (SPConstants.REQUIRE_DERIVED_KEYS.equals(name.getLocalPart())) {
            parent.setDerivedKeys(true);
        } else if (SPConstants.REQUIRE_EXTERNAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireExternalReference(true);
        } else if (SPConstants.REQUIRE_INTERNAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireInternalReference(true);
        }
    }

}
 
Example 3
Source File: NegotiationUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
static Assertion getAddressingPolicy(AssertionInfoMap aim, boolean optional) {
    Collection<AssertionInfo> lst = aim.get(MetadataConstants.USING_ADDRESSING_2004_QNAME);
    Assertion assertion = null;
    if (null != lst && !lst.isEmpty()) {
        assertion = lst.iterator().next().getAssertion();
    }
    if (assertion == null) {
        lst = aim.get(MetadataConstants.USING_ADDRESSING_2005_QNAME);
        if (null != lst && !lst.isEmpty()) {
            assertion = lst.iterator().next().getAssertion();
        }
    }
    if (assertion == null) {
        lst = aim.get(MetadataConstants.USING_ADDRESSING_2006_QNAME);
        if (null != lst && !lst.isEmpty()) {
            assertion = lst.iterator().next().getAssertion();
        }
    }
    if (assertion == null) {
        return new PrimitiveAssertion(MetadataConstants.USING_ADDRESSING_2006_QNAME,
                                      optional);
    } else if (optional) {
        return new PrimitiveAssertion(assertion.getName(),
                                      optional);            
    }
    return assertion;
}
 
Example 4
Source File: SupportingTokens12Builder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void processAlternative(List<Assertion> assertions, SupportingToken supportingToken) {
    
    for (Assertion primitive : assertions) {
        QName qname = primitive.getName();

        if (SP12Constants.ALGORITHM_SUITE.equals(qname)) {
            supportingToken.setAlgorithmSuite((AlgorithmSuite) primitive);

        } else if (SP12Constants.SIGNED_PARTS.equals(qname)) {
            supportingToken
                    .setSignedParts((SignedEncryptedParts) primitive);

        } else if (SP12Constants.SIGNED_ELEMENTS.equals(qname)) {
            supportingToken
                    .setSignedElements((SignedEncryptedElements) primitive);

        } else if (SP12Constants.ENCRYPTED_PARTS.equals(qname)) {
            supportingToken
                    .setEncryptedParts((SignedEncryptedParts) primitive);

        } else if (SP12Constants.ENCRYPTED_ELEMENTS.equals(qname)) {
            supportingToken
                    .setEncryptedElements((SignedEncryptedElements) primitive);

        } else if (primitive instanceof Token) {
            supportingToken.addToken((Token) primitive);
            ((Token)primitive).setSupportingToken(supportingToken);
        }
    }
}
 
Example 5
Source File: SupportingTokens12Builder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void processAlternative(List<Assertion> assertions, SupportingToken supportingToken) {
    
    for (Assertion primitive : assertions) {
        QName qname = primitive.getName();

        if (SP12Constants.ALGORITHM_SUITE.equals(qname)) {
            supportingToken.setAlgorithmSuite((AlgorithmSuite) primitive);

        } else if (SP12Constants.SIGNED_PARTS.equals(qname)) {
            supportingToken
                    .setSignedParts((SignedEncryptedParts) primitive);

        } else if (SP12Constants.SIGNED_ELEMENTS.equals(qname)) {
            supportingToken
                    .setSignedElements((SignedEncryptedElements) primitive);

        } else if (SP12Constants.ENCRYPTED_PARTS.equals(qname)) {
            supportingToken
                    .setEncryptedParts((SignedEncryptedParts) primitive);

        } else if (SP12Constants.ENCRYPTED_ELEMENTS.equals(qname)) {
            supportingToken
                    .setEncryptedElements((SignedEncryptedElements) primitive);

        } else if (primitive instanceof Token) {
            supportingToken.addToken((Token) primitive);
            ((Token)primitive).setSupportingToken(supportingToken);
        }
    }
}
 
Example 6
Source File: SupportingTokensBuilder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void processAlternative(List<Assertion> assertions, SupportingToken supportingToken) {

        for (Assertion primitive : assertions) {
            QName qname = primitive.getName();
            String localName = qname.getLocalPart();
            
            if (SPConstants.ALGO_SUITE.equals(localName)) {
                supportingToken.setAlgorithmSuite((AlgorithmSuite)primitive);

            } else if (SPConstants.SIGNED_PARTS.equals(localName)) {
                supportingToken.setSignedParts((SignedEncryptedParts)primitive);

            } else if (SPConstants.SIGNED_ELEMENTS.equals(localName)) {
                supportingToken.setSignedElements((SignedEncryptedElements)primitive);

            } else if (SPConstants.ENCRYPTED_PARTS.equals(localName)) {
                supportingToken.setEncryptedParts((SignedEncryptedParts)primitive);

            } else if (SPConstants.ENCRYPTED_ELEMENTS.equals(localName)) {
                supportingToken.setEncryptedElements((SignedEncryptedElements)primitive);

            } else if (primitive instanceof Token) {
                supportingToken.addToken((Token)primitive);
                ((Token)primitive).setSupportingToken(supportingToken);
            }
        }
    }
 
Example 7
Source File: NegotiationUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
static Assertion getAddressingPolicy(AssertionInfoMap aim, boolean optional) {
    Collection<AssertionInfo> lst = aim.get(MetadataConstants.USING_ADDRESSING_2004_QNAME);
    Assertion assertion = null;
    if (null != lst && !lst.isEmpty()) {
        assertion = lst.iterator().next().getAssertion();
    }
    if (assertion == null) {
        lst = aim.get(MetadataConstants.USING_ADDRESSING_2005_QNAME);
        if (null != lst && !lst.isEmpty()) {
            assertion = lst.iterator().next().getAssertion();
        }
    }
    if (assertion == null) {
        lst = aim.get(MetadataConstants.USING_ADDRESSING_2006_QNAME);
        if (null != lst && !lst.isEmpty()) {
            assertion = lst.iterator().next().getAssertion();
        }
    }
    if (assertion == null) {
        return new PrimitiveAssertion(MetadataConstants.USING_ADDRESSING_2006_QNAME,
                                      optional);
    } else if (optional) {
        return new PrimitiveAssertion(assertion.getName(),
                                      optional);            
    }
    return assertion;
}
 
Example 8
Source File: PolicyInterceptorProviderRegistryImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public List<Interceptor<? extends Message>>
getInterceptorsForAlternative(Collection<? extends Assertion> alternative,
                              boolean out, boolean fault) {

    List<Interceptor<? extends Message>> interceptors = new ArrayList<>();
    for (Assertion a : alternative) {
        if (a.isOptional()) {
            continue;
        }
        QName qn = a.getName();
        interceptors.addAll(getInterceptorsForAssertion(qn, out, fault));
    }
    return interceptors;
}
 
Example 9
Source File: SupportingTokens12Builder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void processAlternative(List<Assertion> assertions, SupportingToken supportingToken) {
    
    for (Assertion primitive : assertions) {
        QName qname = primitive.getName();

        if (SP12Constants.ALGORITHM_SUITE.equals(qname)) {
            supportingToken.setAlgorithmSuite((AlgorithmSuite) primitive);

        } else if (SP12Constants.SIGNED_PARTS.equals(qname)) {
            supportingToken
                    .setSignedParts((SignedEncryptedParts) primitive);

        } else if (SP12Constants.SIGNED_ELEMENTS.equals(qname)) {
            supportingToken
                    .setSignedElements((SignedEncryptedElements) primitive);

        } else if (SP12Constants.ENCRYPTED_PARTS.equals(qname)) {
            supportingToken
                    .setEncryptedParts((SignedEncryptedParts) primitive);

        } else if (SP12Constants.ENCRYPTED_ELEMENTS.equals(qname)) {
            supportingToken
                    .setEncryptedElements((SignedEncryptedElements) primitive);

        } else if (primitive instanceof Token) {
            supportingToken.addToken((Token) primitive);
            ((Token)primitive).setSupportingToken(supportingToken);
        }
    }
}
 
Example 10
Source File: SupportingTokensBuilder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void processAlternative(List<Assertion> assertions, SupportingToken supportingToken) {

        for (Assertion primitive : assertions) {
            QName qname = primitive.getName();
            String localName = qname.getLocalPart();
            
            if (SPConstants.ALGO_SUITE.equals(localName)) {
                supportingToken.setAlgorithmSuite((AlgorithmSuite)primitive);

            } else if (SPConstants.SIGNED_PARTS.equals(localName)) {
                supportingToken.setSignedParts((SignedEncryptedParts)primitive);

            } else if (SPConstants.SIGNED_ELEMENTS.equals(localName)) {
                supportingToken.setSignedElements((SignedEncryptedElements)primitive);

            } else if (SPConstants.ENCRYPTED_PARTS.equals(localName)) {
                supportingToken.setEncryptedParts((SignedEncryptedParts)primitive);

            } else if (SPConstants.ENCRYPTED_ELEMENTS.equals(localName)) {
                supportingToken.setEncryptedElements((SignedEncryptedElements)primitive);

            } else if (primitive instanceof Token) {
                supportingToken.addToken((Token)primitive);
                ((Token)primitive).setSupportingToken(supportingToken);
            }
        }
    }
 
Example 11
Source File: SymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternatives(List<Assertion> assertions,
                                 SymmetricBinding symmetricBinding, SPConstants consts) {
    QName name;
    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            symmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            symmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            symmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.PROTECTION_TOKEN.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionToken((ProtectionToken)assertion);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            symmetricBinding.setEntireHeadersAndBodySignatures(true);
        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            symmetricBinding.setSignatureProtection(true);
        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            symmetricBinding.setTokenProtection(true);
        } 
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:SymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}
 
Example 12
Source File: X509TokenBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternative(List<Assertion> assertions, X509Token parent, SPConstants consts) {
    QName name;

    for (Assertion assertion : assertions) {
        name = assertion.getName();
        
        if (!consts.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireKeyIdentifierReference(true);

        } else if (SPConstants.REQUIRE_ISSUER_SERIAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireIssuerSerialReference(true);

        } else if (SPConstants.REQUIRE_EMBEDDED_TOKEN_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireEmbeddedTokenReference(true);

        } else if (SPConstants.REQUIRE_THUMBPRINT_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireThumbprintReference(true);

        } else if (SPConstants.WSS_X509_V1_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V1_TOKEN10);

        } else if (SPConstants.WSS_X509_V1_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V1_TOKEN11);

        } else if (SPConstants.WSS_X509_V3_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V3_TOKEN10);

        } else if (SPConstants.WSS_X509_V3_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V3_TOKEN11);

        } else if (SPConstants.WSS_X509_PKCS7_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKCS7_TOKEN10);

        } else if (SPConstants.WSS_X509_PKCS7_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKCS7_TOKEN11);

        } else if (SPConstants.WSS_X509_PKI_PATH_V1_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKI_PATH_V1_TOKEN10);

        } else if (SPConstants.WSS_X509_PKI_PATH_V1_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKI_PATH_V1_TOKEN11);
        }
    }
}
 
Example 13
Source File: SymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternatives(List<Assertion> assertions,
                                 SymmetricBinding symmetricBinding, SPConstants consts) {
    QName name;
    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            symmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            symmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            symmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.PROTECTION_TOKEN.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionToken((ProtectionToken)assertion);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            symmetricBinding.setEntireHeadersAndBodySignatures(true);
        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            symmetricBinding.setSignatureProtection(true);
        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            symmetricBinding.setTokenProtection(true);
        } 
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:SymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}
 
Example 14
Source File: AsymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternative(List<Assertion> assertions, 
                                AsymmetricBinding asymmetricBinding,
                                SPConstants consts) {

    QName name;

    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.INITIATOR_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorToken((InitiatorToken)assertion);
            
        } else if (SPConstants.INITIATOR_SIGNATURE_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorSignatureToken((InitiatorSignatureToken)assertion);
            
        } else if (SPConstants.INITIATOR_ENCRYPTION_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorEncryptionToken(
                (InitiatorEncryptionToken)assertion);                
            
        } else if (SPConstants.RECIPIENT_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientToken((RecipientToken)assertion);

        } else if (SPConstants.RECIPIENT_SIGNATURE_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientSignatureToken((RecipientSignatureToken)assertion);

        } else if (SPConstants.RECIPIENT_ENCRYPTION_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientEncryptionToken((RecipientEncryptionToken)assertion);

        } else if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            asymmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            asymmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            asymmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            asymmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            asymmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            asymmetricBinding.setSignatureProtection(true);

        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            asymmetricBinding.setTokenProtection(true);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            asymmetricBinding.setEntireHeadersAndBodySignatures(true);
        }
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:AsymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}
 
Example 15
Source File: AsymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternative(List<Assertion> assertions, 
                                AsymmetricBinding asymmetricBinding,
                                SPConstants consts) {

    QName name;

    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.INITIATOR_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorToken((InitiatorToken)assertion);
            
        } else if (SPConstants.INITIATOR_SIGNATURE_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorSignatureToken((InitiatorSignatureToken)assertion);
            
        } else if (SPConstants.INITIATOR_ENCRYPTION_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorEncryptionToken(
                (InitiatorEncryptionToken)assertion);                
            
        } else if (SPConstants.RECIPIENT_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientToken((RecipientToken)assertion);

        } else if (SPConstants.RECIPIENT_SIGNATURE_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientSignatureToken((RecipientSignatureToken)assertion);

        } else if (SPConstants.RECIPIENT_ENCRYPTION_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientEncryptionToken((RecipientEncryptionToken)assertion);

        } else if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            asymmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            asymmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            asymmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            asymmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            asymmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            asymmetricBinding.setSignatureProtection(true);

        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            asymmetricBinding.setTokenProtection(true);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            asymmetricBinding.setEntireHeadersAndBodySignatures(true);
        }
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:AsymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}
 
Example 16
Source File: X509TokenBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternative(List<Assertion> assertions, X509Token parent, SPConstants consts) {
    QName name;

    for (Assertion assertion : assertions) {
        name = assertion.getName();
        
        if (!consts.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireKeyIdentifierReference(true);

        } else if (SPConstants.REQUIRE_ISSUER_SERIAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireIssuerSerialReference(true);

        } else if (SPConstants.REQUIRE_EMBEDDED_TOKEN_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireEmbeddedTokenReference(true);

        } else if (SPConstants.REQUIRE_THUMBPRINT_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireThumbprintReference(true);

        } else if (SPConstants.WSS_X509_V1_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V1_TOKEN10);

        } else if (SPConstants.WSS_X509_V1_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V1_TOKEN11);

        } else if (SPConstants.WSS_X509_V3_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V3_TOKEN10);

        } else if (SPConstants.WSS_X509_V3_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V3_TOKEN11);

        } else if (SPConstants.WSS_X509_PKCS7_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKCS7_TOKEN10);

        } else if (SPConstants.WSS_X509_PKCS7_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKCS7_TOKEN11);

        } else if (SPConstants.WSS_X509_PKI_PATH_V1_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKI_PATH_V1_TOKEN10);

        } else if (SPConstants.WSS_X509_PKI_PATH_V1_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKI_PATH_V1_TOKEN11);
        }
    }
}
 
Example 17
Source File: SymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternatives(List<Assertion> assertions,
                                 SymmetricBinding symmetricBinding, SPConstants consts) {
    QName name;
    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            symmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            symmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            symmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.PROTECTION_TOKEN.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionToken((ProtectionToken)assertion);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            symmetricBinding.setEntireHeadersAndBodySignatures(true);
        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            symmetricBinding.setSignatureProtection(true);
        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            symmetricBinding.setTokenProtection(true);
        } 
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:SymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}
 
Example 18
Source File: AsymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternative(List<Assertion> assertions, 
                                AsymmetricBinding asymmetricBinding,
                                SPConstants consts) {

    QName name;

    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.INITIATOR_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorToken((InitiatorToken)assertion);
            
        } else if (SPConstants.INITIATOR_SIGNATURE_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorSignatureToken((InitiatorSignatureToken)assertion);
            
        } else if (SPConstants.INITIATOR_ENCRYPTION_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setInitiatorEncryptionToken(
                (InitiatorEncryptionToken)assertion);                
            
        } else if (SPConstants.RECIPIENT_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientToken((RecipientToken)assertion);

        } else if (SPConstants.RECIPIENT_SIGNATURE_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientSignatureToken((RecipientSignatureToken)assertion);

        } else if (SPConstants.RECIPIENT_ENCRYPTION_TOKEN.equals(name.getLocalPart())) {
            asymmetricBinding.setRecipientEncryptionToken((RecipientEncryptionToken)assertion);

        } else if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            asymmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            asymmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            asymmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            asymmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            asymmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            asymmetricBinding.setSignatureProtection(true);

        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            asymmetricBinding.setTokenProtection(true);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            asymmetricBinding.setEntireHeadersAndBodySignatures(true);
        }
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:AsymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}
 
Example 19
Source File: X509TokenBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternative(List<Assertion> assertions, X509Token parent, SPConstants consts) {
    QName name;

    for (Assertion assertion : assertions) {
        name = assertion.getName();
        
        if (!consts.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireKeyIdentifierReference(true);

        } else if (SPConstants.REQUIRE_ISSUER_SERIAL_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireIssuerSerialReference(true);

        } else if (SPConstants.REQUIRE_EMBEDDED_TOKEN_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireEmbeddedTokenReference(true);

        } else if (SPConstants.REQUIRE_THUMBPRINT_REFERENCE.equals(name.getLocalPart())) {
            parent.setRequireThumbprintReference(true);

        } else if (SPConstants.WSS_X509_V1_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V1_TOKEN10);

        } else if (SPConstants.WSS_X509_V1_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V1_TOKEN11);

        } else if (SPConstants.WSS_X509_V3_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V3_TOKEN10);

        } else if (SPConstants.WSS_X509_V3_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_V3_TOKEN11);

        } else if (SPConstants.WSS_X509_PKCS7_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKCS7_TOKEN10);

        } else if (SPConstants.WSS_X509_PKCS7_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKCS7_TOKEN11);

        } else if (SPConstants.WSS_X509_PKI_PATH_V1_TOKEN10.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKI_PATH_V1_TOKEN10);

        } else if (SPConstants.WSS_X509_PKI_PATH_V1_TOKEN11.equals(name.getLocalPart())) {
            parent.setTokenVersionAndType(SPConstants.WSS_X509_PKI_PATH_V1_TOKEN11);
        }
    }
}
 
Example 20
Source File: SymmetricBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
private void processAlternatives(List<Assertion> assertions,
                                 SymmetricBinding symmetricBinding, SPConstants consts) {
    QName name;
    boolean foundAlgorithmSuite = false;
    for (Assertion assertion : assertions) {
        name = assertion.getName();

        if (!consts.getNamespace().equals(name.getNamespaceURI())
            && !SP12Constants.INSTANCE.getNamespace().equals(name.getNamespaceURI())) {
            continue;
        }

        if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
            foundAlgorithmSuite = true;
            symmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);

        } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
            symmetricBinding.setLayout((Layout)assertion);

        } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
            symmetricBinding.setIncludeTimestamp(true);

        } else if (SPConstants.PROTECTION_TOKEN.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionToken((ProtectionToken)assertion);

        } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.EncryptBeforeSigning);

        } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
            symmetricBinding.setProtectionOrder(SPConstants.ProtectionOrder.SignBeforeEncrypting);

        } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
            symmetricBinding.setEntireHeadersAndBodySignatures(true);
        } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
            symmetricBinding.setSignatureProtection(true);
        } else if (SPConstants.PROTECT_TOKENS.equals(name.getLocalPart())) {
            symmetricBinding.setTokenProtection(true);
        } 
    }
    
    if (!foundAlgorithmSuite && consts != SP11Constants.INSTANCE) {
        throw new IllegalArgumentException(
            "sp:SymmetricBinding/wsp:Policy/sp:AlgorithmSuite must have a value"
        );
    }
}