You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The toolkit is hosted at [Sonatype OSSRH (OSS Repository Hosting)](http://central.sonatype.org/pages/ossrh-guide.html) that is synced to the Central Repository,
74
+
The toolkit is hosted at [Sonatype OSSRH (OSS Repository Hosting)](http://central.sonatype.org/pages/ossrh-guide.html) that is synced to the Central Repository.
75
+
76
+
Install it as a maven dependecy:
77
+
```
78
+
<dependency>
79
+
<groupId>com.onelogin</groupId>
80
+
<artifactId>java-saml</artifactId>
81
+
<version>2.0.0</version>
82
+
</dependency>
83
+
```
84
+
75
85
76
86
### Dependencies
77
87
java-saml (com.onelogin:java-saml-toolkit) has the following dependencies:
@@ -139,7 +149,7 @@ In the repo, at *src/main/java* you will find the source, at *src/main/main/reso
139
149
140
150
141
151
#### toolkit (com.onelogin:java-saml) ####
142
-
This folder contains a maven project with the Auth class to handle the low level classes of java-saml-core and the ServletUtils class to handle javax.servlet.http objetcs, used on the Auth class.
152
+
This folder contains a maven project with the Auth class to handle the low level classes of java-saml-core and the ServletUtils class to handle javax.servlet.http objetcs, used on the Auth class.
143
153
In the repo, at *src/main/java* you will find the source and at *src/test/java* the junit tests for the classes Auth and ServletUtils.
@@ -341,19 +351,22 @@ The IdP will then return the SAML Response to the user's client. The client is t
341
351
342
352
We can set a 'returnTo' url parameter to the login function and that will be converted as a 'RelayState' parameter:
343
353
```
344
-
String target_url = 'https://example.com';
345
-
auth.login(returnTo=target_url)
354
+
String targetUrl = 'https://example.com';
355
+
auth.login(returnTo=targetUrl)
346
356
```
347
-
The login method can recieve 3 more optional parameters:
357
+
The login method can recieve 4 more optional parameters:
348
358
- forceAuthn When true the AuthNReuqest will set the ForceAuthn='true'
349
359
- isPassive When true the AuthNReuqest will set the Ispassive='true'
350
360
- setNameIdPolicy When true the AuthNReuqest will set a nameIdPolicy element.
361
+
- stay True if we want to stay (returns the url string) False to execute a redirection to that url (IdP SSO URL)
351
362
352
-
If a match on the future SAMLResponse ID and the AuthNRequest ID to be sent is required, that AuthNRequest ID must be extracted and stored for future validation, we can get that ID by
363
+
By default the login method initiates a redirect to the SAML Identity Provider. You can use the stay parameter, to prevent that, and execute the redirection manually. We need to use that
364
+
if a match on the future SAMLResponse ID and the AuthNRequest ID to be sent is required, that AuthNRequest ID must be extracted and stored for future validation so we can't execute the redirection on the login, instead set stay to true, then get that ID by
353
365
```
354
366
auth.getLastRequestId()
355
367
```
356
-
and use the login method that let set the stay parameter to true, in order to avoid the redirection.
368
+
and later excuting the redirection manually.
369
+
357
370
358
371
#### The SP Endpoints
359
372
Related to the SP there are 3 important endpoints: The metadata view, the ACS view and the SLS view. The toolkit provides at the demo of the samples folder those views.
The SAML response is processed and then checked that there are no errors. It also verifies that the user is authenticated and stored the userdata in session.
427
440
At that point there are 2 possible alternatives:
428
441
- If no RelayState is provided, we could show the user data in this view or however we wanted.
429
-
- If RelayState is provided, a rediretion take place.
442
+
- If RelayState is provided, a redirection take place.
430
443
Notice that we saved the user data in the session before the redirection to have the user data available at the RelayState view.
431
444
432
445
In order to retrieve attributes we use:
@@ -445,7 +458,7 @@ With this method we get a Map with all the user data provided by the IdP in the
445
458
```
446
459
Each attribute name can be used as a key to obtain the value. Every attribute is a list of values. A single-valued attribute is a listy of a single element.
447
460
448
-
Before trying to get an attribute, check that the user is authenticated. If the user isn't authenticated, an empty dict will be returned. For example, if we call to getAttributes before a auth.processResponse, the getAttributes() will return an empty Map.
461
+
Before trying to get an attribute, check that the user is authenticated. If the user isn't authenticated, an empty Map will be returned. For example, if we call to getAttributes before a auth.processResponse, the getAttributes() will return an empty Map.
449
462
450
463
##### Single Logout Service (SLS)
451
464
This code handles the Logout Request and the Logout Responses.
@@ -479,18 +492,24 @@ The IdP will return the Logout Response through the user's client to the Single
479
492
480
493
We can set a 'returnTo' url parameter to the logout function and that will be converted as a 'RelayState' parameter:
481
494
```
482
-
String target_url = 'https://example.com';
483
-
auth.logout(returnTo=target_url)
495
+
String targetUrl = 'https://example.com';
496
+
auth.logout(returnTo=targetUrl)
484
497
```
485
498
486
-
Also there are 2 optional parameters that can be set:
499
+
Also there are 3 optional parameters that can be set:
487
500
- nameId. That will be used to build the LogoutRequest. If not name_id parameter is set and the auth object processed a SAML Response with a NameId, then this NameId will be used.
488
501
- sessionIndex. Identifies the session of the user.
489
502
If a match on the LogoutResponse ID and the LogoutRequest ID to be sent is required, that LogoutRequest ID must to be extracted and stored for future validation, we can get that ID by
503
+
- stay. True if we want to stay (returns the url string) False to execute a redirection to that url (IdP SLS URL)
504
+
505
+
By default the logout method initiates a redirect to the SAML Identity Provider. You can use the stay parameter, to prevent that, and execute the redirection manually. We need to use that
506
+
if a match on the future LogoutResponse ID and the LogoutRequest ID to be sent is required, that LogoutRequest ID must be extracted and stored for future validation so we can't execute the redirection on the logout, instead set stay to true, then get that ID by
507
+
490
508
```
491
509
auth.getLastRequestId()
492
510
```
493
-
and use the logout method that let set the stay parameter to true, in order to avoid the redirection.
511
+
and later excuting the redirection manually.
512
+
494
513
495
514
## Demo included in the toolkit
496
515
The Onelogin's Java Toolkit allows you to provide the settings in a unique file as described at the [Settings section](https://github.com/onelogin/java-saml/#Settings).
0 commit comments