45 if (obj.getClass().getName().startsWith(
"org.keycloak.dom.saml")) {
46 ByteArrayOutputStream bos =
new ByteArrayOutputStream();
49 if (obj instanceof ResponseType) {
50 ResponseType responseType = (ResponseType) obj;
51 SAMLResponseWriter samlWriter =
new SAMLResponseWriter(StaxUtil.getXMLStreamWriter(bos));
52 samlWriter.write(responseType,
true);
53 }
else if (obj instanceof AssertionType) {
54 AssertionType assertion = (AssertionType) obj;
55 SAMLAssertionWriter samlWriter =
new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(bos));
56 samlWriter.write(assertion,
true);
57 }
else if (obj instanceof AuthnStatementType) {
58 AuthnStatementType authnStatement = (AuthnStatementType) obj;
59 SAMLAssertionWriter samlWriter =
new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(bos));
60 samlWriter.write(authnStatement,
true);
62 throw new IllegalArgumentException(
"Don't know how to serialize object of type " + obj.getClass().getName());
64 }
catch (ProcessingException pe) {
65 throw new RuntimeException(pe);
68 return new String(bos.toByteArray(), GeneralConstants.SAML_CHARSET);
70 return super.serialize(obj);