|
37 | 37 | * Defines the methods that you can invoke in your application in |
38 | 38 | * order to add SAML support (initiates sso, initiates slo, processes a |
39 | 39 | * SAML Response, a Logout Request or a Logout Response). |
| 40 | + * |
| 41 | + * This is stateful and not thread-safe, you should create a new instance for each request/response. |
40 | 42 | */ |
41 | 43 | public class Auth { |
42 | 44 | /** |
@@ -94,6 +96,11 @@ public class Auth { |
94 | 96 | */ |
95 | 97 | private String errorReason; |
96 | 98 |
|
| 99 | + /** |
| 100 | + * The id of the last request (Authn or Logout) generated |
| 101 | + */ |
| 102 | + private String lastRequestId; |
| 103 | + |
97 | 104 | /** |
98 | 105 | * Initializes the SP SAML instance. |
99 | 106 | * |
@@ -191,14 +198,15 @@ public void setStrict(Boolean value) |
191 | 198 | /** |
192 | 199 | * Initiates the SSO process. |
193 | 200 | * |
194 | | - * @param returnTo |
195 | | - * The target URL the user should be returned to after login. |
196 | | - * @param forceAuthn |
197 | | - * When true the AuthNReuqest will set the ForceAuthn='true' |
198 | | - * @param isPassive |
199 | | - * When true the AuthNReuqest will set the IsPassive='true' |
| 201 | + * @param returnTo |
| 202 | + * The target URL the user should be returned to after login. |
| 203 | + * @param forceAuthn |
| 204 | + * When true the AuthNRequest will set the ForceAuthn='true' |
| 205 | + * @param isPassive |
| 206 | + * When true the AuthNRequest will set the IsPassive='true' |
200 | 207 | * @param setNameIdPolicy |
201 | | - * When true the AuthNReuqest will set a nameIdPolicy |
| 208 | + * When true the AuthNRequest will set a nameIdPolicy |
| 209 | + * @return the representation of the AuthNRequest generated |
202 | 210 | * @throws IOException |
203 | 211 | */ |
204 | 212 | public void login(String returnTo, Boolean forceAuthn, Boolean isPassive, Boolean setNameIdPolicy) throws IOException { |
@@ -229,6 +237,7 @@ public void login(String returnTo, Boolean forceAuthn, Boolean isPassive, Boolea |
229 | 237 |
|
230 | 238 | LOGGER.debug("AuthNRequest sent to " + ssoUrl + " --> " + samlRequest); |
231 | 239 | Util.sendRedirect(response, ssoUrl, parameters); |
| 240 | + lastRequestId = authnRequest.getId(); |
232 | 241 | } |
233 | 242 |
|
234 | 243 | /** |
@@ -292,6 +301,7 @@ public void logout(String returnTo, String nameId, String sessionIndex) throws I |
292 | 301 | String sloUrl = getSLOurl(); |
293 | 302 | LOGGER.debug("Logout request sent to " + sloUrl + " --> " + samlLogoutRequest); |
294 | 303 | Util.sendRedirect(response, sloUrl, parameters); |
| 304 | + lastRequestId = logoutRequest.getId(); |
295 | 305 | } |
296 | 306 |
|
297 | 307 | /** |
@@ -538,7 +548,15 @@ public String getLastErrorReason() |
538 | 548 | { |
539 | 549 | return errorReason; |
540 | 550 | } |
541 | | - |
| 551 | + |
| 552 | + /** |
| 553 | + * @return the id of the last request generated (AuthnRequest or LogoutRequest), null if none |
| 554 | + */ |
| 555 | + public String getLastRequestId() |
| 556 | + { |
| 557 | + return lastRequestId; |
| 558 | + } |
| 559 | + |
542 | 560 | /** |
543 | 561 | * @return the Saml2Settings object. The Settings data. |
544 | 562 | */ |
|
0 commit comments