@@ -71,6 +71,11 @@ public class Auth {
7171 */
7272 private String nameid ;
7373
74+ /**
75+ * NameIDFormat.
76+ */
77+ private String nameidFormat ;
78+
7479 /**
7580 * SessionIndex. When the user is logged, this stored it from the AuthnStatement of the SAML Response
7681 */
@@ -345,18 +350,20 @@ public void login(String returnTo) throws IOException, SettingsException {
345350 * @param sessionIndex
346351 * The SessionIndex (taken from the SAML Response in the SSO process).
347352 * @param stay
348- * True if we want to stay (returns the url string) False to execute redirection
353+ * True if we want to stay (returns the url string) False to execute redirection
354+ * @param nameidFormat
355+ * The NameID Format will be set in the LogoutRequest.
349356 *
350357 * @return the SLO URL with the LogoutRequest if stay = True
351358 *
352359 * @throws IOException
353360 * @throws XMLEntityException
354361 * @throws SettingsException
355362 */
356- public String logout (String returnTo , String nameId , String sessionIndex , Boolean stay ) throws IOException , XMLEntityException , SettingsException {
363+ public String logout (String returnTo , String nameId , String sessionIndex , Boolean stay , String nameidFormat ) throws IOException , XMLEntityException , SettingsException {
357364 Map <String , String > parameters = new HashMap <String , String >();
358365
359- LogoutRequest logoutRequest = new LogoutRequest (settings , null , nameId , sessionIndex );
366+ LogoutRequest logoutRequest = new LogoutRequest (settings , null , nameId , sessionIndex , nameidFormat );
360367 String samlLogoutRequest = logoutRequest .getEncodedLogoutRequest ();
361368 parameters .put ("SAMLRequest" , samlLogoutRequest );
362369
@@ -399,13 +406,56 @@ public String logout(String returnTo, String nameId, String sessionIndex, Boolea
399406 * The NameID that will be set in the LogoutRequest.
400407 * @param sessionIndex
401408 * The SessionIndex (taken from the SAML Response in the SSO process).
409+ * @param stay
410+ * True if we want to stay (returns the url string) False to execute redirection
411+ *
412+ * @return the SLO URL with the LogoutRequest if stay = True
402413 *
403414 * @throws IOException
404415 * @throws XMLEntityException
405416 * @throws SettingsException
406417 */
418+ public String logout (String returnTo , String nameId , String sessionIndex , Boolean stay ) throws IOException , XMLEntityException , SettingsException {
419+ return logout (returnTo , nameId , sessionIndex , stay , null );
420+ }
421+
422+ /**
423+ * Initiates the SLO process.
424+ *
425+ * @param returnTo
426+ * The target URL the user should be returned to after logout (relayState).
427+ * Will be a self-routed URL when null, or not be appended at all when an empty string is provided
428+ * @param nameId
429+ * The NameID that will be set in the LogoutRequest.
430+ * @param sessionIndex
431+ * The SessionIndex (taken from the SAML Response in the SSO process).
432+ * @param nameidFormat
433+ * The NameID Format will be set in the LogoutRequest.
434+ * @throws IOException
435+ * @throws XMLEntityException
436+ * @throws SettingsException
437+ */
438+ public void logout (String returnTo , String nameId , String sessionIndex , String nameidFormat ) throws IOException , XMLEntityException , SettingsException {
439+ logout (returnTo , nameId , sessionIndex , false , nameidFormat );
440+ }
441+
442+ /**
443+ * Initiates the SLO process.
444+ *
445+ * @param returnTo
446+ * The target URL the user should be returned to after logout (relayState).
447+ * Will be a self-routed URL when null, or not be appended at all when an empty string is provided
448+ * @param nameId
449+ * The NameID that will be set in the LogoutRequest.
450+ * @param sessionIndex
451+ * The SessionIndex (taken from the SAML Response in the SSO process).
452+ *
453+ * @throws IOException
454+ * @throws XMLEntityException
455+ * @throws SettingsException
456+ */
407457 public void logout (String returnTo , String nameId , String sessionIndex ) throws IOException , XMLEntityException , SettingsException {
408- logout (returnTo , nameId , sessionIndex , false );
458+ logout (returnTo , nameId , sessionIndex , false , null );
409459 }
410460
411461 /**
@@ -416,7 +466,7 @@ public void logout(String returnTo, String nameId, String sessionIndex) throws I
416466 * @throws SettingsException
417467 */
418468 public void logout () throws IOException , XMLEntityException , SettingsException {
419- logout (null , null , null );
469+ logout (null , null , null , false );
420470 }
421471
422472 /**
@@ -475,6 +525,7 @@ public void processResponse(String requestId) throws Exception {
475525
476526 if (samlResponse .isValid (requestId )) {
477527 nameid = samlResponse .getNameId ();
528+ nameidFormat = samlResponse .getNameIdFormat ();
478529 authenticated = true ;
479530 attributes = samlResponse .getAttributes ();
480531 sessionIndex = samlResponse .getSessionIndex ();
@@ -643,6 +694,14 @@ public final String getNameId()
643694 return nameid ;
644695 }
645696
697+ /**
698+ * @return the nameID Format of the assertion
699+ */
700+ public final String getNameIdFormat ()
701+ {
702+ return nameidFormat ;
703+ }
704+
646705 /**
647706 * @return the SessionIndex of the assertion
648707 */
0 commit comments