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);
}
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;
}
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;
}
Aggregations