[keycloak-user] Obtaining the user name from the security context

Marek Posolda mposolda at redhat.com
Wed Nov 19 12:55:37 EST 2014


If you have 1.1.0.Beta1, you can try to use "principal-attribute" with 
value "|preferred_username" in the configuration of your adapter. More 
info in |http://docs.jboss.org/keycloak/docs/1.1.0.Beta1/userguide 
/html/ch07.html#adapter-config .

It should also work to cast getUserPrincipal() to KeycloakPrincipal and 
use something like:

((KeycloakPrincipal)getUserPrincipal()).getKeycloakSecurityContext().getToken().getPreferredUsername()

this should also work on older versions, but your code may need to have 
dependencies on keycloak.

Marek

On 19.11.2014 17:20, Gary Brown wrote:
> Hi
>
> When I access getUserPrincipal().getName() in javax.ws.rs.core.SecurityContext I get the UID.
>
> Is it possible to obtain the actual user name?
>
> Regards
> Gary
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20141119/abb2213a/attachment.html 


More information about the keycloak-user mailing list