Skip to content

Get the authenticated user profiles

LELEU Jérôme edited this page Nov 20, 2020 · 8 revisions

You can get the profile(s) of the authenticated user using the ProfileManager.

>> Read the documentation of the ProfileManager component.

Example:

WebContext context = new JEEContext(request, response);
ProfileManager manager = new ProfileManager(context);
Optional<UserProfile> profile = manager.getProfile();

While you can build the JEEContext and the ProfileManager, you may also inject them.

First, you must register the components:

@ComponentScan(basePackages = "org.pac4j.springframework.component")

or

@Import(ComponentConfig.class)

Then, you can inject the ProfileManager (and the JEEContext):

@Autowired
private ProfileManager profileManager;
Clone this wiki locally