@@ -49,6 +49,37 @@ public static Document loadDocument(String xml) {
49
49
}
50
50
}
51
51
52
+ public static String buildXmlLogin (List <org .w3c .dom .Element > assertions , Document xmlDoc ){
53
+ //security meassure against assertion manipulation, it assures that every assertion to be used on the app has been signed and verified
54
+ org .w3c .dom .Element element = xmlDoc .getDocumentElement ();
55
+ Node response = element .cloneNode (false );
56
+
57
+ NodeList status = element .getElementsByTagNameNS (_saml_protocolNS , "Status" );
58
+ response .appendChild (status .item (0 ));
59
+
60
+ for (org .w3c .dom .Element elem : assertions ){
61
+ if (!elem .getLocalName ().equals ("Response" )){
62
+ Node node = elem .cloneNode (true );
63
+ response .appendChild (node );
64
+ }
65
+ }
66
+ return Encoding .elementToString ((org .w3c .dom .Element ) response );
67
+ }
68
+
69
+ public static String buildXmlLogout (List <org .w3c .dom .Element > assertions ){
70
+ if (assertions .isEmpty ())
71
+ {
72
+ return "" ;
73
+ }
74
+ org .w3c .dom .Element element = assertions .get (0 );
75
+ Node logoutResponse = element .cloneNode (false );
76
+ NodeList status = element .getElementsByTagNameNS (_saml_protocolNS , "Status" );
77
+ logoutResponse .appendChild (status .item (0 ));
78
+ NodeList issuer = element .getElementsByTagNameNS (_saml_assertionNS , "Issuer" );
79
+ logoutResponse .appendChild (issuer .item (0 ));
80
+ return Encoding .elementToString ((org .w3c .dom .Element ) logoutResponse );
81
+ }
82
+
52
83
public static boolean isLogout (Document xmlDoc ){
53
84
logger .trace ("isLogout" );
54
85
try {
0 commit comments