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 StringSUPER_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 CNAuthenticationcast(Authentication a)static CNAuthenticationget()If the current thread carries theCNAuthenticationobject as the context, returns it.GrantedAuthority[]getAuthorities()CollabNetAppgetCredentials()ObjectgetDetails()StringgetName()StringgetPrincipal()StringgetSessionId()Set<Permission>getUserProjectPermSet(String username, String projectId)Get a set of all permission that a user has for a given project.booleanisAuthenticated()booleanisCNAuthed()Determine whether we have authenticated to CTF in the browser.booleanisMember(String group)booleanisMemberOfAny(Collection<String> groups)Determines if the authenticated user belongs to any of the groups.booleanisProjectAdmin(CTFProject p)Determines if the authenticated user is a project admin.booleanisSuperUser()Determines if the authenticated user is a super user.voidsetAuthenticated(boolean authenticated)voidsetCNAuthed(boolean cnauthed)Set whether we have authenticated to CTF in the browser.StringtoString()-
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:
setAuthenticatedin interfaceAuthentication
-
isAuthenticated
public boolean isAuthenticated()
- Specified by:
isAuthenticatedin interfaceAuthentication
-
getAuthorities
public GrantedAuthority[] getAuthorities()
- Specified by:
getAuthoritiesin interfaceAuthentication- Returns:
- a copy of the granted authorities.
-
getPrincipal
public String getPrincipal()
- Specified by:
getPrincipalin interfaceAuthentication
-
getDetails
public Object getDetails()
- Specified by:
getDetailsin interfaceAuthentication
-
getCredentials
public CollabNetApp getCredentials()
- Specified by:
getCredentialsin 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 theCNAuthenticationobject as the context, returns it. Or else null.
-
cast
public static CNAuthentication cast(Authentication a)
-
-