Skip to content

Commit

Permalink
Enable use of custom ProfileManager implementations in DefaultSecurit…
Browse files Browse the repository at this point in the history
…yLogic

Some pac4j platform implementations (for example vertx-pac4j) use custom implementations of ProfileManager. However, the DefaultSecurityLogic appears to provide the implementation they would want to use, if they could inject their own ProfileManagers.

Therefore this change is proposed to use an overridable factory method for a ProfileManager (or subclass) rather than have an inline construction of a ProfileManager. Overriding this method thus enables use of a custom ProfileManager implementation such as that required for vert.x.
  • Loading branch information
Jeremy Prime committed Jun 30, 2016
1 parent d551c1b commit 6de2204
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public R perform(final C context, final Config config, final SecurityGrantedAcce

final boolean loadProfilesFromSession = loadProfilesFromSession(context, currentClients);
logger.debug("loadProfilesFromSession: {}", loadProfilesFromSession);
final ProfileManager manager = new ProfileManager(context);
final ProfileManager manager = getProfileManager(context);
List<CommonProfile> profiles = manager.getAll(loadProfilesFromSession);
logger.debug("profiles: {}", profiles);

Expand Down Expand Up @@ -165,6 +165,16 @@ public R perform(final C context, final Config config, final SecurityGrantedAcce
return httpActionAdapter.adapt(action.getCode(), context);
}

/**
* Given a webcontext generate a profileManager for it.
* Can be overridden for custom profile manager implementations
* @param context the web context
* @return profile manager implementation built from the context
*/
protected ProfileManager getProfileManager(final C context) {
return new ProfileManager(context);
}

/**
* Load the profiles from the web context if no clients are defined or if the first client is an indirect one or the {@link AnonymousClient}.
*
Expand Down

0 comments on commit 6de2204

Please sign in to comment.