use of org.keycloak.dom.saml.v2.protocol.AuthnContextComparisonType in project keycloak by keycloak.
the class SAMLRequestWriter method write.
/**
* Write a {@code RequestedAuthnContextType} to stream
*
* @param requestedAuthnContextType
*
* @throws ProcessingException
*/
public void write(RequestedAuthnContextType requestedAuthnContextType) throws ProcessingException {
StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.REQUESTED_AUTHN_CONTEXT.get(), PROTOCOL_NSURI.get());
AuthnContextComparisonType comparison = requestedAuthnContextType.getComparison();
if (comparison != null) {
StaxUtil.writeAttribute(writer, JBossSAMLConstants.COMPARISON.get(), comparison.value());
}
List<String> authnContextClassRef = requestedAuthnContextType.getAuthnContextClassRef();
if (authnContextClassRef != null && !authnContextClassRef.isEmpty()) {
for (String classRef : authnContextClassRef) {
StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.AUTHN_CONTEXT_CLASS_REF.get(), ASSERTION_NSURI.get());
StaxUtil.writeNameSpace(writer, ASSERTION_PREFIX, ASSERTION_NSURI.get());
StaxUtil.writeCharacters(writer, classRef);
StaxUtil.writeEndElement(writer);
}
}
List<String> authnContextDeclRef = requestedAuthnContextType.getAuthnContextDeclRef();
if (authnContextDeclRef != null && !authnContextDeclRef.isEmpty()) {
for (String declRef : authnContextDeclRef) {
StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.AUTHN_CONTEXT_DECL_REF.get(), ASSERTION_NSURI.get());
StaxUtil.writeNameSpace(writer, ASSERTION_PREFIX, ASSERTION_NSURI.get());
StaxUtil.writeCharacters(writer, declRef);
StaxUtil.writeEndElement(writer);
}
}
StaxUtil.writeEndElement(writer);
StaxUtil.flush(writer);
}
Aggregations