@@ -221,10 +221,13 @@ public void setStrict(Boolean value)
221221 * When true the AuthNRequest will set the IsPassive='true'
222222 * @param setNameIdPolicy
223223 * When true the AuthNRequest will set a nameIdPolicy
224- * @returns the representation of the AuthNRequest generated
224+ * @param stay
225+ * True if we want to stay (returns the url string) False to execute redirection
226+ *
227+ * @return the SSO URL with the AuthNRequest if stay = True
225228 * @throws IOException
226229 */
227- public void login (String returnTo , Boolean forceAuthn , Boolean isPassive , Boolean setNameIdPolicy ) throws IOException {
230+ public String login (String returnTo , Boolean forceAuthn , Boolean isPassive , Boolean setNameIdPolicy , Boolean stay ) throws IOException {
228231 Map <String , String > parameters = new HashMap <String , String >();
229232
230233 AuthnRequest authnRequest = new AuthnRequest (settings , forceAuthn , isPassive , setNameIdPolicy );
@@ -253,11 +256,32 @@ public void login(String returnTo, Boolean forceAuthn, Boolean isPassive, Boolea
253256
254257 String ssoUrl = getSSOurl ();
255258
256- LOGGER .debug ("AuthNRequest sent to " + ssoUrl + " --> " + samlRequest );
257- ServletUtils .sendRedirect (response , ssoUrl , parameters );
258259 lastRequestId = authnRequest .getId ();
260+
261+ if (!stay ) {
262+ LOGGER .debug ("AuthNRequest sent to " + ssoUrl + " --> " + samlRequest );
263+ }
264+ return ServletUtils .sendRedirect (response , ssoUrl , parameters , stay );
259265 }
260266
267+ /**
268+ * Initiates the SSO process.
269+ *
270+ * @param returnTo
271+ * The target URL the user should be returned to after login (relayState).
272+ * Will be a self-routed URL when null, or not be appended at all when an empty string is provided
273+ * @param forceAuthn
274+ * When true the AuthNRequest will set the ForceAuthn='true'
275+ * @param isPassive
276+ * When true the AuthNRequest will set the IsPassive='true'
277+ * @param setNameIdPolicy
278+ * When true the AuthNRequest will set a nameIdPolicy
279+ * @throws IOException
280+ */
281+ public void login (String returnTo , Boolean forceAuthn , Boolean isPassive , Boolean setNameIdPolicy ) throws IOException {
282+ login (returnTo ,forceAuthn , isPassive , setNameIdPolicy , false );
283+ }
284+
261285 /**
262286 * Initiates the SSO process.
263287 *
@@ -290,11 +314,15 @@ public void login(String returnTo) throws IOException {
290314 * The NameID that will be set in the LogoutRequest.
291315 * @param sessionIndex
292316 * The SessionIndex (taken from the SAML Response in the SSO process).
317+ * @param stay
318+ * True if we want to stay (returns the url string) False to execute redirection
319+ *
320+ * @return the SLO URL with the LogoutRequest if stay = True
293321 *
294322 * @throws IOException
295323 * @throws XMLEntityException
296324 */
297- public void logout (String returnTo , String nameId , String sessionIndex ) throws IOException , XMLEntityException {
325+ public String logout (String returnTo , String nameId , String sessionIndex , Boolean stay ) throws IOException , XMLEntityException {
298326 Map <String , String > parameters = new HashMap <String , String >();
299327
300328 LogoutRequest logoutRequest = new LogoutRequest (settings , null , nameId , sessionIndex );
@@ -321,9 +349,30 @@ public void logout(String returnTo, String nameId, String sessionIndex) throws I
321349 }
322350
323351 String sloUrl = getSLOurl ();
324- LOGGER .debug ("Logout request sent to " + sloUrl + " --> " + samlLogoutRequest );
325- ServletUtils .sendRedirect (response , sloUrl , parameters );
326352 lastRequestId = logoutRequest .getId ();
353+
354+ if (!stay ) {
355+ LOGGER .debug ("Logout request sent to " + sloUrl + " --> " + samlLogoutRequest );
356+ }
357+ return ServletUtils .sendRedirect (response , sloUrl , parameters , stay );
358+ }
359+
360+ /**
361+ * Initiates the SLO process.
362+ *
363+ * @param returnTo
364+ * The target URL the user should be returned to after logout (relayState).
365+ * Will be a self-routed URL when null, or not be appended at all when an empty string is provided
366+ * @param nameId
367+ * The NameID that will be set in the LogoutRequest.
368+ * @param sessionIndex
369+ * The SessionIndex (taken from the SAML Response in the SSO process).
370+ *
371+ * @throws IOException
372+ * @throws XMLEntityException
373+ */
374+ public void logout (String returnTo , String nameId , String sessionIndex ) throws IOException , XMLEntityException {
375+ logout (returnTo , nameId , sessionIndex , false );
327376 }
328377
329378 /**
0 commit comments