com.atlassian.crowd.integration.springsecurity.user
Class CrowdUserDetailsServiceImpl

java.lang.Object
  extended by com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsServiceImpl
All Implemented Interfaces:
CrowdUserDetailsService, org.springframework.security.core.userdetails.UserDetailsService

public class CrowdUserDetailsServiceImpl
extends Object
implements CrowdUserDetailsService

Retrieves users from Crowd using Crowd's remote API.

Author:
Shihab Hamid

Constructor Summary
CrowdUserDetailsServiceImpl()
           
 
Method Summary
 String getAdminAuthority()
          Return the name of the admin authority.
 String getAuthorityPrefix()
          Return the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[] and no authorityMap is set.
 Iterable<Map.Entry<String,String>> getGroupToAuthorityMappings()
          Return the group-to-authority mappings
 CrowdUserDetails loadUserByToken(String token)
          Retrieve a user from Crowd by looking up the principal by their authenticated Crowd token.
 CrowdUserDetails loadUserByUsername(String username)
          Retrieves the user from Crowd by looking up the principal by username.
 void setAdminAuthority(String adminAuthority)
          Set the name of the admin authority.
 void setAuthenticationManager(AuthenticationManager authenticationManager)
           
 void setAuthorityPrefix(String authorityPrefix)
          Set the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[] and no authorityMap is set, e.g.
 void setGroupMembershipManager(GroupMembershipManager groupMembershipManager)
           
 void setGroupToAuthorityMappings(Iterable<Map.Entry<String,String>> groupToAuthorityMappings)
          Set the authority mappings.
 void setUserManager(UserManager userManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrowdUserDetailsServiceImpl

public CrowdUserDetailsServiceImpl()
Method Detail

loadUserByUsername

public CrowdUserDetails loadUserByUsername(String username)
                                    throws org.springframework.security.core.userdetails.UsernameNotFoundException,
                                           org.springframework.dao.DataAccessException
Description copied from interface: CrowdUserDetailsService
Retrieves the user from Crowd by looking up the principal by username.

Specified by:
loadUserByUsername in interface CrowdUserDetailsService
Specified by:
loadUserByUsername in interface org.springframework.security.core.userdetails.UserDetailsService
Parameters:
username - username of the principal.
Returns:
CrowdUserDetails corresponding to the principal.
Throws:
org.springframework.dao.DataAccessException - thrown if there was an underlying problem while communicating with the Crowd server.
org.springframework.security.core.userdetails.UsernameNotFoundException

loadUserByToken

public CrowdUserDetails loadUserByToken(String token)
                                 throws CrowdSSOTokenInvalidException,
                                        org.springframework.dao.DataAccessException
Description copied from interface: CrowdUserDetailsService
Retrieve a user from Crowd by looking up the principal by their authenticated Crowd token.

Specified by:
loadUserByToken in interface CrowdUserDetailsService
Parameters:
token - Crowd SSO token string.
Returns:
CrowdUserDetails corresponding to the principal.
Throws:
org.springframework.dao.DataAccessException - thrown if there was an underlying problem while communicating with the Crowd server.
CrowdSSOTokenInvalidException

getAuthorityPrefix

public String getAuthorityPrefix()
Description copied from interface: CrowdUserDetailsService
Return the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[] and no authorityMap is set.

Specified by:
getAuthorityPrefix in interface CrowdUserDetailsService
Returns:
prefix.

setAuthorityPrefix

public void setAuthorityPrefix(String authorityPrefix)
Description copied from interface: CrowdUserDetailsService
Set the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[] and no authorityMap is set, e.g. ROLE_crowd-administrators.

Specified by:
setAuthorityPrefix in interface CrowdUserDetailsService
Parameters:
authorityPrefix - prefix to apply. The default is no prefix.

getGroupToAuthorityMappings

public Iterable<Map.Entry<String,String>> getGroupToAuthorityMappings()
Description copied from interface: CrowdUserDetailsService
Return the group-to-authority mappings

Specified by:
getGroupToAuthorityMappings in interface CrowdUserDetailsService
Returns:
an iterable over mappings from group names (key) to authority names (value)

setGroupToAuthorityMappings

public void setGroupToAuthorityMappings(Iterable<Map.Entry<String,String>> groupToAuthorityMappings)
Description copied from interface: CrowdUserDetailsService
Set the authority mappings. The default is no authority mappings, which implies that authorities are derived from group names, with an optional authorityPrefix. If not null, the mappings are used instead to transform group names into authority names regardless of the authorityPrefix.

Versions of Crowd prior to 2.6 used to have a configurable authoritySuffix parameter which has been replaced by these mappings.

Specified by:
setGroupToAuthorityMappings in interface CrowdUserDetailsService
Parameters:
groupToAuthorityMappings - authority mappings. If absent, an authority prefix is used.

getAdminAuthority

public String getAdminAuthority()
Description copied from interface: CrowdUserDetailsService
Return the name of the admin authority.

Specified by:
getAdminAuthority in interface CrowdUserDetailsService
Returns:
name of the admin authority

setAdminAuthority

public void setAdminAuthority(String adminAuthority)
Description copied from interface: CrowdUserDetailsService
Set the name of the admin authority.

Specified by:
setAdminAuthority in interface CrowdUserDetailsService
Parameters:
adminAuthority - name of the admin authority. The default is ROLE_ADMIN.

setUserManager

public void setUserManager(UserManager userManager)

setGroupMembershipManager

public void setGroupMembershipManager(GroupMembershipManager groupMembershipManager)

setAuthenticationManager

public void setAuthenticationManager(AuthenticationManager authenticationManager)


Copyright © 2013 Atlassian. All Rights Reserved.