public String mockAssertionEncoded(Assertion assertion) throws Exception { AssertionMarshaller marshaller = new AssertionMarshaller(); Element plaintextElement = marshaller.marshall(assertion); String serializedElement = XMLHelper.nodeToString(plaintextElement); return Base64.encodeBase64URLSafeString(serializedElement.getBytes("utf-8")); }
String getAssertionXml(Assertion assertion) { try { AssertionMarshaller marshaller = new AssertionMarshaller(); Element plaintextElement = marshaller.marshall(assertion); String serializedElement = XMLHelper.nodeToString(plaintextElement); return serializedElement; } catch(Exception e) { } return null; }
/** * {@inheritDoc} */ @Override public String saml2AssertionToFormattedString(Assertion assertion) { Element saml2AssertionElement = null; String saml2AssertionString = null; try { if(assertion !=null){ saml2AssertionElement = assertionMarshaller.marshall(assertion); } if(saml2AssertionElement !=null) { saml2AssertionString = XMLHelper.prettyPrintXML(saml2AssertionElement); } }catch(MarshallingException e){ String message ="saml2AssertionToUnFormattedString(Assertion), Marshalling failed"; logger.error(message,e); } return saml2AssertionString; }
/** * {@inheritDoc} */ @Override public String saml2AssertionToUnFormattedString(Assertion assertion) { Element saml2AssertionElement = null; String saml2AssertionString = null; try { if(assertion != null) { saml2AssertionElement = assertionMarshaller.marshall(assertion); if(saml2AssertionElement != null) { saml2AssertionString = XMLHelper.nodeToString(saml2AssertionElement); }else{ saml2AssertionString ="AssertionElement is null! "; logger.error(saml2AssertionString); } }else{ saml2AssertionString ="Assertion is null! "; logger.error(saml2AssertionString); } }catch(MarshallingException e){ saml2AssertionString ="saml2AssertionToUnFormattedString(Assertion), Marshalling failed"; logger.error(saml2AssertionString,e); } return saml2AssertionString; }
Element plaintextElement = marshaller.marshall(assertion); String originalAssertionString = XMLHelper.nodeToString(plaintextElement);