ok but I can't really see what is ' Object principal '

i've tried:
'var role =
SecurityContextHolder.getContext().getAuthentication().getAuthorities();'

but i got an error of course but I can't see how to get this information
realy.

gerome

2012/2/10 <[email protected]>

> Since Geoserver uses Spring Security you can do the following:
>
> To obtain the usern ame
>
>
> Object principal = SecurityContextHolder.**getContext().**
> getAuthentication().**getPrincipal();
>
> if (principal instanceof UserDetails) {
>  String username = ((UserDetails)principal).**getUsername();
> } else {
>  String username = principal.toString();
>
> To get the roles
>
> SecurityContextHolder.**getContext().**getAuthentication().**
> getAuthorities()
>
>
> Dont forget to check if 
> SecurityContextHolder.**getContext().**getAuthentication()
> is null, this is the case if there was no authentication process.
>
> Hope this helps
> Christian
>
>
>
> Zitat von Gerome Bracquemont <[email protected]>**:
>
>
>  Hello everybody.
>>
>> I use j_spring_security_check to authenticate my users in my client so
>> that
>> they are logged in with there geoserver profil.
>> This way geoserver expose the layers the user can access.
>>
>> Know, I would like to find a way of retreiving the user's role to adapte
>> the user interface.
>> For exemple I would like hide fonctionnalities for a role and give all to
>> an other.
>>
>> Do you have an idea on how to retreive the user's role ?
>>
>> Thanks
>>
>> gerome
>>
>>
>
>
> ------------------------------**------------------------------**----
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to