KEYCLOAK-13713 Define a write method for XMLGregorianCalendar attributes
This commit is contained in:
parent
f30395d535
commit
b4127bb7d7
1 changed files with 18 additions and 0 deletions
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue