Package hudson.plugins.collabnet.auth
Class CNAuthentication
- java.lang.Object
-
- hudson.plugins.collabnet.auth.CNAuthentication
-
- All Implemented Interfaces:
Serializable
,Principal
,Authentication
public class CNAuthentication extends Object implements Authentication
Authentication class for CollabNet.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
SUPER_USER
-
Constructor Summary
Constructors Constructor Description CNAuthentication(Object principal, Object credentials)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CNAuthentication
cast(Authentication a)
static CNAuthentication
get()
If the current thread carries theCNAuthentication
object as the context, returns it.GrantedAuthority[]
getAuthorities()
CollabNetApp
getCredentials()
Object
getDetails()
String
getName()
String
getPrincipal()
String
getSessionId()
Set<Permission>
getUserProjectPermSet(String username, String projectId)
Get a set of all permission that a user has for a given project.boolean
isAuthenticated()
boolean
isCNAuthed()
Determine whether we have authenticated to CTF in the browser.boolean
isMember(String group)
boolean
isMemberOfAny(Collection<String> groups)
Determines if the authenticated user belongs to any of the groups.boolean
isProjectAdmin(CTFProject p)
Determines if the authenticated user is a project admin.boolean
isSuperUser()
Determines if the authenticated user is a super user.void
setAuthenticated(boolean authenticated)
void
setCNAuthed(boolean cnauthed)
Set whether we have authenticated to CTF in the browser.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.acegisecurity.Authentication
toSpring
-
-
-
-
Field Detail
-
SUPER_USER
public static final String SUPER_USER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CNAuthentication
public CNAuthentication(Object principal, Object credentials) throws IOException
- Throws:
IOException
-
-
Method Detail
-
setAuthenticated
public void setAuthenticated(boolean authenticated)
- Specified by:
setAuthenticated
in interfaceAuthentication
-
isAuthenticated
public boolean isAuthenticated()
- Specified by:
isAuthenticated
in interfaceAuthentication
-
getAuthorities
public GrantedAuthority[] getAuthorities()
- Specified by:
getAuthorities
in interfaceAuthentication
- Returns:
- a copy of the granted authorities.
-
getPrincipal
public String getPrincipal()
- Specified by:
getPrincipal
in interfaceAuthentication
-
getDetails
public Object getDetails()
- Specified by:
getDetails
in interfaceAuthentication
-
getCredentials
public CollabNetApp getCredentials()
- Specified by:
getCredentials
in interfaceAuthentication
-
isMember
public boolean isMember(String group)
- Parameters:
group
- name of a CN group.- Returns:
- true if the user is a member of the given group.
-
toString
public String toString()
-
isCNAuthed
public boolean isCNAuthed()
Determine whether we have authenticated to CTF in the browser.- Returns:
- true if authenticated
-
setCNAuthed
public void setCNAuthed(boolean cnauthed)
Set whether we have authenticated to CTF in the browser.- Parameters:
cnauthed
- true if current session is CTF authenticated in browser
-
isSuperUser
public boolean isSuperUser()
Determines if the authenticated user is a super user. This is currently from data that's calculated once (on login). If this ever turns out to be insufficient, we could change this method to get the data on the fly.
-
isMemberOfAny
public boolean isMemberOfAny(Collection<String> groups)
Determines if the authenticated user belongs to any of the groups. This is currently from data that's calculated once (on login). If this ever turns out to be insufficient, we could change this method to get the data on the fly.- Parameters:
groups
- collection of groups- Returns:
- true if the user is a member of any of the groups.
-
isProjectAdmin
public boolean isProjectAdmin(CTFProject p)
Determines if the authenticated user is a project admin.- Returns:
- true if the user is a project admin.
-
getSessionId
public String getSessionId()
-
getUserProjectPermSet
public Set<Permission> getUserProjectPermSet(String username, String projectId)
Get a set of all permission that a user has for a given project.- Parameters:
username
- user nameprojectId
- project id- Returns:
- set of permissions
-
get
public static CNAuthentication get()
If the current thread carries theCNAuthentication
object as the context, returns it. Or else null.
-
cast
public static CNAuthentication cast(Authentication a)
-
-