Search in sources :

Example 1 with KeyInfoConfirmationDataType

use of org.keycloak.dom.saml.v2.assertion.KeyInfoConfirmationDataType in project keycloak by keycloak.

the class BaseWriter method write.

private void write(SubjectConfirmationDataType subjectConfirmationData) throws ProcessingException {
    StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.SUBJECT_CONFIRMATION_DATA.get(), ASSERTION_NSURI.get());
    // Let us look at attributes
    String inResponseTo = subjectConfirmationData.getInResponseTo();
    if (StringUtil.isNotNull(inResponseTo)) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.IN_RESPONSE_TO.get(), inResponseTo);
    }
    XMLGregorianCalendar notBefore = subjectConfirmationData.getNotBefore();
    if (notBefore != null) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.NOT_BEFORE.get(), notBefore.toString());
    }
    XMLGregorianCalendar notOnOrAfter = subjectConfirmationData.getNotOnOrAfter();
    if (notOnOrAfter != null) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.NOT_ON_OR_AFTER.get(), notOnOrAfter.toString());
    }
    String recipient = subjectConfirmationData.getRecipient();
    if (StringUtil.isNotNull(recipient)) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.RECIPIENT.get(), recipient);
    }
    String address = subjectConfirmationData.getAddress();
    if (StringUtil.isNotNull(address)) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.ADDRESS.get(), address);
    }
    if (subjectConfirmationData instanceof KeyInfoConfirmationDataType) {
        KeyInfoConfirmationDataType kicd = (KeyInfoConfirmationDataType) subjectConfirmationData;
        KeyInfoType keyInfo = (KeyInfoType) kicd.getAnyType();
        StaxWriterUtil.writeKeyInfo(writer, keyInfo);
    /*
             * if (keyInfo.getContent() == null || keyInfo.getContent().size() == 0) throw new
             * ProcessingException(ErrorCodes.WRITER_INVALID_KEYINFO_NULL_CONTENT); StaxUtil.writeStartElement(this.writer,
             * WSTrustConstants.XMLDSig.DSIG_PREFIX, WSTrustConstants.XMLDSig.KEYINFO, WSTrustConstants.XMLDSig.DSIG_NS);
             * StaxUtil.writeNameSpace(this.writer, WSTrustConstants.XMLDSig.DSIG_PREFIX, WSTrustConstants.XMLDSig.DSIG_NS); //
             * write the keyInfo content. Object content = keyInfo.getContent().get(0); if (content instanceof Element) {
             * Element element = (Element) keyInfo.getContent().get(0); StaxUtil.writeDOMNode(this.writer, element); } else if
             * (content instanceof X509DataType) { X509DataType type = (X509DataType) content; if (type.getDataObjects().size()
             * == 0) throw new ProcessingException(ErrorCodes.WRITER_NULL_VALUE + "X509Data");
             * StaxUtil.writeStartElement(this.writer, WSTrustConstants.XMLDSig.DSIG_PREFIX, WSTrustConstants.XMLDSig.X509DATA,
             * WSTrustConstants.XMLDSig.DSIG_NS); Object obj = type.getDataObjects().get(0); if (obj instanceof Element) {
             * Element element = (Element) obj; StaxUtil.writeDOMElement(this.writer, element); } else if (obj instanceof
             * X509CertificateType) { X509CertificateType cert = (X509CertificateType) obj;
             * StaxUtil.writeStartElement(this.writer, WSTrustConstants.XMLDSig.DSIG_PREFIX, WSTrustConstants.XMLDSig.X509CERT,
             * WSTrustConstants.XMLDSig.DSIG_NS); StaxUtil.writeCharacters(this.writer, new
             * String(cert.getEncodedCertificate())); StaxUtil.writeEndElement(this.writer); }
             * StaxUtil.writeEndElement(this.writer); } StaxUtil.writeEndElement(this.writer);
             */
    }
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) KeyInfoConfirmationDataType(org.keycloak.dom.saml.v2.assertion.KeyInfoConfirmationDataType) KeyInfoType(org.keycloak.dom.xmlsec.w3.xmldsig.KeyInfoType)

Example 2 with KeyInfoConfirmationDataType

use of org.keycloak.dom.saml.v2.assertion.KeyInfoConfirmationDataType in project keycloak by keycloak.

the class SAMLAssertionFactory method createSubjectConfirmation.

/**
 * <p>
 * Creates a {@code SubjectConfirmationType} object with the specified values.
 * </p>
 *
 * @param nameID the identifier of the confirmation.
 * @param confirmationMethod a {@code String} representing the confirmation method.
 * @param keyInfoData the {@code KeyInfoConfirmationDataType} instance that contains the proof of possession key.
 *
 * @return the constructed {@code SubjectConfirmationType} instance.
 */
public static SubjectConfirmationType createSubjectConfirmation(NameIDType nameID, String confirmationMethod, KeyInfoConfirmationDataType keyInfoData) {
    SubjectConfirmationType subjectConfirmation = new SubjectConfirmationType();
    subjectConfirmation.setNameID(nameID);
    subjectConfirmation.setMethod(confirmationMethod);
    subjectConfirmation.setSubjectConfirmationData(keyInfoData);
    return subjectConfirmation;
}
Also used : SubjectConfirmationType(org.keycloak.dom.saml.v2.assertion.SubjectConfirmationType)

Example 3 with KeyInfoConfirmationDataType

use of org.keycloak.dom.saml.v2.assertion.KeyInfoConfirmationDataType in project keycloak by keycloak.

the class SAMLAssertionFactory method createKeyInfoConfirmation.

/**
 * <p>
 * Creates a {@code KeyInfoConfirmationDataType} with the specified {@code KeyInfoType}.
 * </p>
 *
 * @param keyInfo the {@code KeyInfoType} object that wraps the proof-of-possession token.
 *
 * @return the constructed {@code KeyInfoConfirmationDataType} instance.
 */
public static KeyInfoConfirmationDataType createKeyInfoConfirmation(KeyInfoType keyInfo) {
    KeyInfoConfirmationDataType type = new KeyInfoConfirmationDataType();
    type.setAnyType(keyInfo);
    return type;
}
Also used : KeyInfoConfirmationDataType(org.keycloak.dom.saml.v2.assertion.KeyInfoConfirmationDataType)

Aggregations

KeyInfoConfirmationDataType (org.keycloak.dom.saml.v2.assertion.KeyInfoConfirmationDataType)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 SubjectConfirmationType (org.keycloak.dom.saml.v2.assertion.SubjectConfirmationType)1 KeyInfoType (org.keycloak.dom.xmlsec.w3.xmldsig.KeyInfoType)1