Skip to content

Commit

Permalink
add the saveInSession capability
Browse files Browse the repository at this point in the history
  • Loading branch information
leleuj committed Mar 7, 2018
1 parent 50cb922 commit f5d5240
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Expand Up @@ -234,11 +234,13 @@ The following options are available:

2) `defaultUrl` (optional): it's the default url after login if no url was originally requested (`/` by default)

3) `multiProfile` (optional): it indicates whether multiple authentications (and thus multiple profiles) must be kept at the same time (`false` by default)
3) `saveInSession` (optional) : it indicates whether the profile should be saved into the web session (`true` by defualt)

4) `renewSession` (optional): it indicates whether the web session must be renewed after login, to avoid session hijacking (`true` by default)
4) `multiProfile` (optional): it indicates whether multiple authentications (and thus multiple profiles) must be kept at the same time (`false` by default)

5) `defaultClient` (optional): it defines the default client to use to finish the login process if none is provided on the URL (not defined by default)
5) `renewSession` (optional): it indicates whether the web session must be renewed after login, to avoid session hijacking (`true` by default)

6) `defaultClient` (optional): it defines the default client to use to finish the login process if none is provided on the URL (not defined by default)


The filter can be defined in the `web.xml` file:
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/pac4j/j2e/filter/CallbackFilter.java
Expand Up @@ -24,6 +24,7 @@
* <ul>
* <li><code>configFactory</code> (the class name of the factory to build the configuration) or <code>config</code> (the configuration itself)</li>
* <li><code>defaultUrl</code> (default url after login if none was requested)</li>
* <li><code>saveInSession</code> (whether the profile should be saved into the session)</li>
* <li><code>multiProfile</code> (whether multiple profiles should be kept)</li>
* <li><code>renewSession</code> (whether the session must be renewed after login)</li>
* <li><code>defaultClient</code> (the default client if none is provided on the URL)</li>
Expand All @@ -38,6 +39,8 @@ public class CallbackFilter extends AbstractConfigFilter {

private String defaultUrl;

private Boolean saveInSession;

private Boolean multiProfile;

private Boolean renewSession;
Expand All @@ -60,6 +63,7 @@ public void init(final FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);

this.defaultUrl = getStringParam(filterConfig, Pac4jConstants.DEFAULT_URL, this.defaultUrl);
this.saveInSession = getBooleanParam(filterConfig, Pac4jConstants.SAVE_IN_SESSION, this.saveInSession);
this.multiProfile = getBooleanParam(filterConfig, Pac4jConstants.MULTI_PROFILE, this.multiProfile);
this.renewSession = getBooleanParam(filterConfig, Pac4jConstants.RENEW_SESSION, this.renewSession);
this.defaultClient = getStringParam(filterConfig, Pac4jConstants.DEFAULT_CLIENT, this.defaultClient);
Expand All @@ -78,7 +82,7 @@ protected void internalFilter(final HttpServletRequest request, final HttpServle
assertNotNull("config", config);
final J2EContext context = new J2EContext(request, response, config.getSessionStore());

callbackLogic.perform(context, config, J2ENopHttpActionAdapter.INSTANCE, this.defaultUrl, this.multiProfile, this.renewSession, this.defaultClient);
callbackLogic.perform(context, config, J2ENopHttpActionAdapter.INSTANCE, this.defaultUrl, this.saveInSession, this.multiProfile, this.renewSession, this.defaultClient);
}

public String getDefaultUrl() {
Expand All @@ -89,6 +93,14 @@ public void setDefaultUrl(final String defaultUrl) {
this.defaultUrl = defaultUrl;
}

public Boolean getSaveInSession() {
return saveInSession;
}

public void setSaveInSession(final Boolean saveInSession) {
this.saveInSession = saveInSession;
}

public Boolean getMultiProfile() {
return multiProfile;
}
Expand Down

0 comments on commit f5d5240

Please sign in to comment.