hudson.plugins.collabnet.auth
Class CNConnection

java.lang.Object
  extended by hudson.plugins.collabnet.auth.CNConnection

public class CNConnection
extends java.lang.Object

CNConnection encapsulates the CN webservice methods.


Method Summary
 boolean addRoles(java.lang.String projectId, java.util.List<java.lang.String> roleNames, java.util.List<java.lang.String> descriptions)
           
 java.util.Collection<java.lang.String> getAdmins(java.lang.String projectId)
           
 CNAuthentication getAuth()
           
 CollabNetApp getCollabNetApp()
           
static CNConnection getInstance()
          Gets an instance with the current authentication, or null if the auth is the wrong type.
static CNConnection getInstance(org.acegisecurity.Authentication a)
          Wraps the private constructor.
 java.lang.String getProjectId(java.lang.String project)
           
 java.util.Collection<java.lang.String> getProjects()
           
 java.lang.String getUsername()
           
 java.util.Collection<java.lang.String> getUserRoles(java.lang.String projectId, java.lang.String username)
           
 java.util.Collection<java.lang.String> getUsers(java.lang.String projectId)
           
static CNVersion getVersion(java.lang.String url)
           
 void grantRoles(java.lang.String projectId, java.util.Collection<java.lang.String> roles, java.util.Collection<java.lang.String> usernames)
          Grant the specified roles to the users in the given project.
 boolean isGroupnameValid(java.lang.String group)
           
 boolean isMemberOfAny(java.util.Collection<java.lang.String> groups)
          Determines if the authenticated user belongs to any of the groups.
 boolean isProjectAdmin(java.lang.String projectId)
          Determines if the authenticated user is a project admin.
 boolean isSuperUser()
          Determines if the authenticated user is a super user.
 boolean isUsernameValid(java.lang.String username)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CNConnection getInstance()
Gets an instance with the current authentication, or null if the auth is the wrong type.


getInstance

public static CNConnection getInstance(org.acegisecurity.Authentication a)
Wraps the private constructor. Will return null if the Authentication is the wrong type (i.e. not CNAuthentication).


getCollabNetApp

public CollabNetApp getCollabNetApp()
Returns:
the CollabNetApp.

getVersion

public static CNVersion getVersion(java.lang.String url)
Parameters:
url - for CollabNet server
Returns:
the CollabNet version for the given url.

getUsername

public java.lang.String getUsername()
Returns:
the username.

getAuth

public CNAuthentication getAuth()
Returns:
the Authentication.

isMemberOfAny

public boolean isMemberOfAny(java.util.Collection<java.lang.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 -
Returns:
true if the user is a member of any of the groups.

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.


isProjectAdmin

public boolean isProjectAdmin(java.lang.String projectId)
Determines if the authenticated user is a project admin.

Parameters:
projectId -
Returns:
true if the user is a project admin.

getProjectId

public java.lang.String getProjectId(java.lang.String project)
Parameters:
project - name
Returns:
projectId or null, if none found.

getProjects

public java.util.Collection<java.lang.String> getProjects()
Returns:
all project names, sanitized for JS.

getUserRoles

public java.util.Collection<java.lang.String> getUserRoles(java.lang.String projectId,
                                                           java.lang.String username)
Parameters:
projectId -
username -
Returns:
a Collection of roles the user has in this project.

getUsers

public java.util.Collection<java.lang.String> getUsers(java.lang.String projectId)
Parameters:
projectId -
Returns:
a Collection of all users that are members of the project.

isUsernameValid

public boolean isUsernameValid(java.lang.String username)
Parameters:
username -
Returns:
true if user exists.

isGroupnameValid

public boolean isGroupnameValid(java.lang.String group)
Parameters:
group -
Returns:
true if group exists.

getAdmins

public java.util.Collection<java.lang.String> getAdmins(java.lang.String projectId)
Parameters:
projectId -
Returns:
a Collection of all admins in the project.

addRoles

public boolean addRoles(java.lang.String projectId,
                        java.util.List<java.lang.String> roleNames,
                        java.util.List<java.lang.String> descriptions)
Parameters:
projectId -
roleNames -
descriptions - of the roles.

grantRoles

public void grantRoles(java.lang.String projectId,
                       java.util.Collection<java.lang.String> roles,
                       java.util.Collection<java.lang.String> usernames)
Grant the specified roles to the users in the given project.

Parameters:
projectId -
roles -
usernames -


Copyright © 2010. All Rights Reserved.