Hello, I am trying to retrieve information about the User logged into the webapp via keycloak. I have seen around information on using the following;

 

@SecurityDomain("keycloak")

 

@Context
SecurityContext sc;

 

And

KeycloakPrincipal principal = (KeycloakPrincipal) sc.getUserPrincipal();
 
 
 

But the above line is returning a NullPointerException.

 

I must say, I have already done the required configuration; as in enabling the Keycloak Subsystem within my app server's server configuration: standalone.xml.

Please any lead on how to retrieve the logged in User via KeyCloak?

 

 

Sent from Mail for Windows 10