diff --git a/saml-core/src/main/java/org/keycloak/saml/processing/core/saml/v2/writers/BaseWriter.java b/saml-core/src/main/java/org/keycloak/saml/processing/core/saml/v2/writers/BaseWriter.java index 14c130ab1b..878697cf0b 100755 --- a/saml-core/src/main/java/org/keycloak/saml/processing/core/saml/v2/writers/BaseWriter.java +++ b/saml-core/src/main/java/org/keycloak/saml/processing/core/saml/v2/writers/BaseWriter.java @@ -172,6 +172,8 @@ public class BaseWriter { writeStringAttributeValue((String) attributeValue); } else if (attributeValue instanceof NameIDType) { writeNameIDTypeAttributeValue((NameIDType) attributeValue); + } else if (attributeValue instanceof XMLGregorianCalendar) { + writeDateAttributeValue((XMLGregorianCalendar) attributeValue); } else throw logger.writerUnsupportedAttributeValueError(attributeValue.getClass().getName()); } else { @@ -203,6 +205,22 @@ public class BaseWriter { StaxUtil.writeEndElement(writer); } + public void writeDateAttributeValue(XMLGregorianCalendar attributeValue) throws ProcessingException { + StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.ATTRIBUTE_VALUE.get(), ASSERTION_NSURI.get()); + + StaxUtil.writeNameSpace(writer, JBossSAMLURIConstants.XSI_PREFIX.get(), JBossSAMLURIConstants.XSI_NSURI.get()); + StaxUtil.writeNameSpace(writer, "xs", JBossSAMLURIConstants.XMLSCHEMA_NSURI.get()); + StaxUtil.writeAttribute(writer, "xsi", JBossSAMLURIConstants.XSI_NSURI.get(), "type", "xs:" + attributeValue.getXMLSchemaType().getLocalPart()); + + if (attributeValue == null) { + StaxUtil.writeAttribute(writer, "xsi", JBossSAMLURIConstants.XSI_NSURI.get(), "nil", "true"); + } else { + StaxUtil.writeCharacters(writer, attributeValue.toString()); + } + + StaxUtil.writeEndElement(writer); + } + public void writeLocalizedNameType(LocalizedNameType localizedNameType, QName startElement) throws ProcessingException { StaxUtil.writeStartElement(writer, startElement.getPrefix(), startElement.getLocalPart(), startElement.getNamespaceURI());