Class CrowdUserDetailsServiceImpl
java.lang.Object
com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsServiceImpl
- All Implemented Interfaces:
CrowdUserDetailsService
,org.springframework.security.core.userdetails.UserDetailsService
Retrieves users from Crowd using Crowd's remote API.
- Author:
- Shihab Hamid
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the name of the admin authority.Return the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[] and no authorityMap is set.Return the group-to-authority mappingsloadUserByToken
(String token) Retrieve a user from Crowd by looking up the principal by their authenticated Crowd token.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
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
setCrowdClient
(CrowdClient crowdClient) void
setGroupToAuthorityMappings
(Iterable<Map.Entry<String, String>> groupToAuthorityMappings) Set the authority mappings.void
setUserAuthoritiesProvider
(UserAuthoritiesProvider userAuthoritiesProvider) Set a User to Authorities provider, eg.
-
Constructor Details
-
CrowdUserDetailsServiceImpl
public CrowdUserDetailsServiceImpl()
-
-
Method Details
-
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 interfaceCrowdUserDetailsService
- Specified by:
loadUserByUsername
in interfaceorg.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 interfaceCrowdUserDetailsService
- 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
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 interfaceCrowdUserDetailsService
- Returns:
- prefix.
-
setAuthorityPrefix
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 interfaceCrowdUserDetailsService
- Parameters:
authorityPrefix
- prefix to apply. The default is no prefix.
-
getGroupToAuthorityMappings
Description copied from interface:CrowdUserDetailsService
Return the group-to-authority mappings- Specified by:
getGroupToAuthorityMappings
in interfaceCrowdUserDetailsService
- 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 interfaceCrowdUserDetailsService
- Parameters:
groupToAuthorityMappings
- authority mappings. If absent, an authority prefix is used.
-
setUserAuthoritiesProvider
Set a User to Authorities provider, eg. to delegate to UserPermissionService. This takes priority over all other methods of Authorities calculations.- Parameters:
userAuthoritiesProvider
- the implementation to use
-
getAdminAuthority
Description copied from interface:CrowdUserDetailsService
Return the name of the admin authority.- Specified by:
getAdminAuthority
in interfaceCrowdUserDetailsService
- Returns:
- name of the admin authority
-
setAdminAuthority
Set the name of the admin authority.- Specified by:
setAdminAuthority
in interfaceCrowdUserDetailsService
- Parameters:
adminAuthority
- name of the admin authority. The default is ROLE_SYS_ADMIN.
-
setCrowdClient
-