Skip to content

Commit a83c819

Browse files
committed
#49. Suggested changes
1 parent beeef10 commit a83c819

1 file changed

Lines changed: 36 additions & 17 deletions

File tree

README.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
Add SAML support to your Java applications using this library.
66
Forget those complicated libraries and use that open source library provided and supported by OneLogin Inc.
77

8-
This is the Version 2.0.0-SNAPSHOT, compatible with java6 / java7 / java8.
8+
This is the Version 2.0.0, compatible with java6 / java7 / java8.
99

10-
The 1.1.2-SNAPSHOT is consider deprecated. If you used it, we strongly recommend to migrate to that new version.
11-
We rebuilt the toolkit on 2.0.0-SNAPSHOT so code/settings that you had will not be compatible.
10+
The 1.1.2 is consider deprecated. If you used it, we strongly recommend to migrate to that new version.
11+
We rebuilt the toolkit on 2.0.0 so code/settings that you had will not be compatible.
1212

1313

1414
## Why add SAML support to my software?
@@ -71,7 +71,17 @@ The toolkit is hosted on github. You can download it from:
7171
* Master repo: https://github.com/onelogin/java-saml/tree/master
7272

7373
#### Maven
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,
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+
7585

7686
### Dependencies
7787
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
139149

140150

141151
#### 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.
143153
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.
144154

145155
#### samples (com.onelogin:java-saml-tookit-samples) ####
@@ -341,19 +351,22 @@ The IdP will then return the SAML Response to the user's client. The client is t
341351

342352
We can set a 'returnTo' url parameter to the login function and that will be converted as a 'RelayState' parameter:
343353
```
344-
String target_url = 'https://example.com';
345-
auth.login(returnTo=target_url)
354+
String targetUrl = 'https://example.com';
355+
auth.login(returnTo=targetUrl)
346356
```
347-
The login method can recieve 3 more optional parameters:
357+
The login method can recieve 4 more optional parameters:
348358
- forceAuthn When true the AuthNReuqest will set the ForceAuthn='true'
349359
- isPassive When true the AuthNReuqest will set the Ispassive='true'
350360
- 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)
351362

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
353365
```
354366
auth.getLastRequestId()
355367
```
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+
357370

358371
#### The SP Endpoints
359372
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.
@@ -404,7 +417,7 @@ if (!errors.isEmpty()) {
404417
405418
String relayState = request.getParameter("RelayState");
406419
407-
if (relayState != null && relayState != ServletUtils.getSelfRoutedURLNoQuery(request)) {
420+
if (relayState != null && relayState != ServletUtils.getSelfRoutedURLNoQuery(request)) {
408421
response.sendRedirect(request.getParameter("RelayState"));
409422
} else {
410423
if (attributes.isEmpty()) {
@@ -426,7 +439,7 @@ if (!errors.isEmpty()) {
426439
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.
427440
At that point there are 2 possible alternatives:
428441
- 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.
430443
Notice that we saved the user data in the session before the redirection to have the user data available at the RelayState view.
431444

432445
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
445458
```
446459
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.
447460

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.
449462

450463
##### Single Logout Service (SLS)
451464
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
479492

480493
We can set a 'returnTo' url parameter to the logout function and that will be converted as a 'RelayState' parameter:
481494
```
482-
String target_url = 'https://example.com';
483-
auth.logout(returnTo=target_url)
495+
String targetUrl = 'https://example.com';
496+
auth.logout(returnTo=targetUrl)
484497
```
485498

486-
Also there are 2 optional parameters that can be set:
499+
Also there are 3 optional parameters that can be set:
487500
- 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.
488501
- sessionIndex. Identifies the session of the user.
489502
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+
490508
```
491509
auth.getLastRequestId()
492510
```
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+
494513

495514
## Demo included in the toolkit
496515
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

Comments
 (0)