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

java.lang.Object
  extended by com.atlassian.crowd.integration.acegi.user.CrowdUserDetailsServiceImpl
All Implemented Interfaces:
CrowdUserDetailsService, org.acegisecurity.userdetails.UserDetailsService

public class CrowdUserDetailsServiceImpl
extends java.lang.Object
implements CrowdUserDetailsService

Retrieves users from Crowd using Crowd's remote API.

Author:
Shihab Hamid

Field Summary
protected static org.apache.log4j.Logger LOGGER
           
 
Constructor Summary
CrowdUserDetailsServiceImpl()
           
 
Method Summary
protected  org.acegisecurity.GrantedAuthority[] getAuthorities(java.lang.String username)
          Requests the group memberships of the user from the Crowd Server.
 java.lang.String getAuthorityPrefix()
          Return the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[].
 java.lang.String getAuthoritySuffix()
          Return the authority suffix, e.g.
 CrowdUserDetails loadUserByToken(java.lang.String token)
          Retrieve a user from Crowd by looking up the principal by their authenticated Crowd token.
 CrowdUserDetails loadUserByUsername(java.lang.String username)
          Retrieves the user from Crowd by looking up the principal by username.
 void setAuthenticationManager(AuthenticationManager authenticationManager)
           
 void setAuthorityPrefix(java.lang.String authorityPrefix)
          Set the authority prefix applied to group names the principal is a member of when generating the GrantedAuthority[].
 void setAuthoritySuffix(java.lang.String authoritySuffix)
          Set the authority suffix e.g.
 void setGroupMembershipManager(GroupMembershipManager groupMembershipManager)
           
 void setUserManager(UserManager userManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.apache.log4j.Logger LOGGER
Constructor Detail

CrowdUserDetailsServiceImpl

public CrowdUserDetailsServiceImpl()
Method Detail

loadUserByUsername

public CrowdUserDetails loadUserByUsername(java.lang.String username)
                                    throws org.acegisecurity.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.acegisecurity.userdetails.UserDetailsService
Parameters:
username - username of the principal.
Returns:
CrowdUserDetails corresponding to the principal.
Throws:
org.acegisecurity.userdetails.UsernameNotFoundException - thrown if a principal with the requested username cannot be found in Crowd.
org.springframework.dao.DataAccessException - thrown if there was an underlying problem while communicating with the Crowd server.

loadUserByToken

public CrowdUserDetails loadUserByToken(java.lang.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:
CrowdSSOTokenInvalidException - if the provided token is invalid.
org.springframework.dao.DataAccessException - thrown if there was an underlying problem while communicating with the Crowd server.

getAuthorities

protected org.acegisecurity.GrantedAuthority[] getAuthorities(java.lang.String username)
                                                       throws InvalidAuthorizationTokenException,
                                                              java.rmi.RemoteException,
                                                              ObjectNotFoundException
Requests the group memberships of the user from the Crowd Server.

Each GrantedAuthority string is appended with the authorityPrefix as a prefix.

Parameters:
username - username of the user to look up.
Returns:
groups memberships as GrantedAuthority objects. Returns 0 GrantedAuthorities if the user does not exist in Crowd or there was a problem talking to the Crowd server.
Throws:
InvalidAuthorizationTokenException - invalid application client.
java.rmi.RemoteException - underlying Crowd Server problem.
ObjectNotFoundException - The user identified by username could not be found.

getAuthorityPrefix

public java.lang.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[].

Specified by:
getAuthorityPrefix in interface CrowdUserDetailsService
Returns:
prefix.

setAuthorityPrefix

public void setAuthorityPrefix(java.lang.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[].

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

getAuthoritySuffix

public java.lang.String getAuthoritySuffix()
Description copied from interface: CrowdUserDetailsService
Return the authority suffix, e.g. "ADMIN" Currently crowd does not support multiple ROLE types, so just one will be returned. If this value is not set, Authorities will be returned based on group name, e.g. ROLE_crowd-administrators.

Specified by:
getAuthoritySuffix in interface CrowdUserDetailsService
Returns:
prefix.

setAuthoritySuffix

public void setAuthoritySuffix(java.lang.String authoritySuffix)
Description copied from interface: CrowdUserDetailsService
Set the authority suffix e.g. "ADMIN" Currently crowd does not support multiple ROLE types, so just one will be returned. If this value is not set, Authorities will be returned based on group name, e.g. ROLE_crowd-administrators.

Specified by:
setAuthoritySuffix in interface CrowdUserDetailsService
Parameters:
authoritySuffix - suffix to apply.

setUserManager

public void setUserManager(UserManager userManager)

setGroupMembershipManager

public void setGroupMembershipManager(GroupMembershipManager groupMembershipManager)

setAuthenticationManager

public void setAuthenticationManager(AuthenticationManager authenticationManager)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.