Java Code Examples for org.apache.ws.security.WSConstants#WSS_SAML_KI_VALUE_TYPE

The following examples show how to use org.apache.ws.security.WSConstants#WSS_SAML_KI_VALUE_TYPE . 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: AbstractBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Create a SecurityTokenReference to point to a SAML Assertion
 * @param doc The owner Document instance
 * @param id The Assertion ID
 * @param saml1 Whether the Assertion is a SAML1 or SAML2 Assertion
 * @param useDirectReferenceToAssertion whether to refer directly to the assertion or not
 * @return a SecurityTokenReference to a SAML Assertion
 */
private SecurityTokenReference createSTRForSamlAssertion(
    Document doc,
    String id,
    boolean saml1,
    boolean useDirectReferenceToAssertion
) {
    SecurityTokenReference secRefSaml = new SecurityTokenReference(doc);
    String secRefID = wssConfig.getIdAllocator().createSecureId("STR-", secRefSaml);
    secRefSaml.setID(secRefID);

    if (useDirectReferenceToAssertion) {
        org.apache.ws.security.message.token.Reference ref = 
            new org.apache.ws.security.message.token.Reference(doc);
        ref.setURI("#" + id);
        if (saml1) {
            ref.setValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        secRefSaml.setReference(ref);
    } else {
        Element keyId = doc.createElementNS(WSConstants.WSSE_NS, "wsse:KeyIdentifier");
        String valueType = null;
        if (saml1) {
            valueType = WSConstants.WSS_SAML_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            valueType = WSConstants.WSS_SAML2_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        keyId.setAttributeNS(
            null, "ValueType", valueType
        );
        keyId.appendChild(doc.createTextNode(id));
        Element elem = secRefSaml.getElement();
        elem.appendChild(keyId);
    }
    return secRefSaml;
}
 
Example 2
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Create a SecurityTokenReference to point to a SAML Assertion
 * @param doc The owner Document instance
 * @param id The Assertion ID
 * @param saml1 Whether the Assertion is a SAML1 or SAML2 Assertion
 * @param useDirectReferenceToAssertion whether to refer directly to the assertion or not
 * @return a SecurityTokenReference to a SAML Assertion
 */
private SecurityTokenReference createSTRForSamlAssertion(
    Document doc,
    String id,
    boolean saml1,
    boolean useDirectReferenceToAssertion
) {
    SecurityTokenReference secRefSaml = new SecurityTokenReference(doc);
    String secRefID = wssConfig.getIdAllocator().createSecureId("STR-", secRefSaml);
    secRefSaml.setID(secRefID);

    if (useDirectReferenceToAssertion) {
        org.apache.ws.security.message.token.Reference ref = 
            new org.apache.ws.security.message.token.Reference(doc);
        ref.setURI("#" + id);
        if (saml1) {
            ref.setValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        secRefSaml.setReference(ref);
    } else {
        Element keyId = doc.createElementNS(WSConstants.WSSE_NS, "wsse:KeyIdentifier");
        String valueType = null;
        if (saml1) {
            valueType = WSConstants.WSS_SAML_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            valueType = WSConstants.WSS_SAML2_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        keyId.setAttributeNS(
            null, "ValueType", valueType
        );
        keyId.appendChild(doc.createTextNode(id));
        Element elem = secRefSaml.getElement();
        elem.appendChild(keyId);
    }
    return secRefSaml;
}
 
Example 3
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Create a SecurityTokenReference to point to a SAML Assertion
 * @param doc The owner Document instance
 * @param id The Assertion ID
 * @param saml1 Whether the Assertion is a SAML1 or SAML2 Assertion
 * @param useDirectReferenceToAssertion whether to refer directly to the assertion or not
 * @return a SecurityTokenReference to a SAML Assertion
 */
private SecurityTokenReference createSTRForSamlAssertion(
    Document doc,
    String id,
    boolean saml1,
    boolean useDirectReferenceToAssertion
) {
    SecurityTokenReference secRefSaml = new SecurityTokenReference(doc);
    String secRefID = wssConfig.getIdAllocator().createSecureId("STR-", secRefSaml);
    secRefSaml.setID(secRefID);

    if (useDirectReferenceToAssertion) {
        org.apache.ws.security.message.token.Reference ref = 
            new org.apache.ws.security.message.token.Reference(doc);
        ref.setURI("#" + id);
        if (saml1) {
            ref.setValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        secRefSaml.setReference(ref);
    } else {
        Element keyId = doc.createElementNS(WSConstants.WSSE_NS, "wsse:KeyIdentifier");
        String valueType = null;
        if (saml1) {
            valueType = WSConstants.WSS_SAML_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            valueType = WSConstants.WSS_SAML2_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        keyId.setAttributeNS(
            null, "ValueType", valueType
        );
        keyId.appendChild(doc.createTextNode(id));
        Element elem = secRefSaml.getElement();
        elem.appendChild(keyId);
    }
    return secRefSaml;
}
 
Example 4
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Create a SecurityTokenReference to point to a SAML Assertion
 * @param doc The owner Document instance
 * @param id The Assertion ID
 * @param saml1 Whether the Assertion is a SAML1 or SAML2 Assertion
 * @param useDirectReferenceToAssertion whether to refer directly to the assertion or not
 * @return a SecurityTokenReference to a SAML Assertion
 */
private SecurityTokenReference createSTRForSamlAssertion(
    Document doc,
    String id,
    boolean saml1,
    boolean useDirectReferenceToAssertion
) {
    SecurityTokenReference secRefSaml = new SecurityTokenReference(doc);
    String secRefID = wssConfig.getIdAllocator().createSecureId("STR-", secRefSaml);
    secRefSaml.setID(secRefID);

    if (useDirectReferenceToAssertion) {
        org.apache.ws.security.message.token.Reference ref = 
            new org.apache.ws.security.message.token.Reference(doc);
        ref.setURI("#" + id);
        if (saml1) {
            ref.setValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        secRefSaml.setReference(ref);
    } else {
        Element keyId = doc.createElementNS(WSConstants.WSSE_NS, "wsse:KeyIdentifier");
        String valueType = null;
        if (saml1) {
            valueType = WSConstants.WSS_SAML_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
        } else {
            valueType = WSConstants.WSS_SAML2_KI_VALUE_TYPE;
            secRefSaml.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        }
        keyId.setAttributeNS(
            null, "ValueType", valueType
        );
        keyId.appendChild(doc.createTextNode(id));
        Element elem = secRefSaml.getElement();
        elem.appendChild(keyId);
    }
    return secRefSaml;
}