org.itracker.services.util
Class UserUtilities

java.lang.Object
  extended by org.itracker.services.util.UserUtilities
All Implemented Interfaces:
AuthenticationConstants

public class UserUtilities
extends Object
implements AuthenticationConstants


Field Summary
static Set<Integer> ALL_PERMISSIONS_SET
           
protected static char[] alphabet
           
static int PERMISSION_ASSIGN_OTHERS
          Issue Assign to Others Permissions.
static int PERMISSION_ASSIGN_SELF
          Issue Assign to Self Permission.
static int PERMISSION_ASSIGNABLE
          Issue Assignable.
static int PERMISSION_CLOSE
          Issue Close Permission.
static int PERMISSION_CREATE
          Issue Create Permission
static int PERMISSION_CREATE_OTHERS
          Create for Others.
static int PERMISSION_EDIT
          Issue Edit Permission.
static int PERMISSION_EDIT_FULL
          Full edit permission.
static int PERMISSION_EDIT_USERS
          Edit Users Issues Permission.
static int PERMISSION_PRODUCT_ADMIN
          Product Admin Permission
static int PERMISSION_UNASSIGN_SELF
          Issue Unassign Self Permission.
static int PERMISSION_USER_ADMIN
          User Admin Permission.
static int PERMISSION_VIEW_ALL
          View All Issues Permission.
static int PERMISSION_VIEW_USERS
          View Users Issues Permission.
static int PREF_HIDE_ASSIGNED
           
static int PREF_HIDE_CREATED
           
static int PREF_HIDE_UNASSIGNED
           
static int PREF_HIDE_WATCHED
           
static int REGISTRATION_TYPE_ADMIN
           
static int REGISTRATION_TYPE_IMPORT
           
static int REGISTRATION_TYPE_SELF
           
static int STATUS_ACTIVE
           
static int STATUS_DELETED
           
static int STATUS_LOCKED
           
 
Fields inherited from interface org.itracker.services.util.AuthenticationConstants
AUTH_TYPE_CERTIFICATE, AUTH_TYPE_PASSWORD_ENC, AUTH_TYPE_PASSWORD_PLAIN, AUTH_TYPE_REQUEST, AUTH_TYPE_SHARED_SECRET, AUTH_TYPE_UNKNOWN, REQ_SOURCE_API, REQ_SOURCE_UNKNOWN, REQ_SOURCE_WEB, UPDATE_TYPE_CORE, UPDATE_TYPE_PERMISSION_ADD, UPDATE_TYPE_PERMISSION_SET, UPDATE_TYPE_PREFERENCE
 
Constructor Summary
UserUtilities()
           
 
Method Summary
static Permission[] createPermissionArray(User user, Project project, int[] permissions)
           
static String encryptPassword(String password)
          Returns an encrypted (digest) password from a plain text password.
static String generatePassword()
          Genrates a new random password.
static List<NameValuePair> getAssignableIssueOwnersList(Issue issue, Project project, User currUser, Locale locale, UserService userService, Map<Integer,Set<PermissionType>> userPermissions)
          This method will obtain and build a list of possible owners for the webpages to display and the operator to choose from.
static Integer[] getHiddenIndexSections(int sections)
           
static String getInitial(String name)
           
static String getPermissionName(int value)
           
static String getPermissionName(int value, Locale locale)
           
static List<NameValuePair> getPermissionNames()
           
static List<NameValuePair> getPermissionNames(Locale locale)
           
static String getStatusName(int value)
           
static String getStatusName(int value, Locale locale)
           
static HashMap<String,String> getStatusNames()
           
static HashMap<String,String> getStatusNames(Locale locale)
           
static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap, int permissionNeeded)
          Returns true if the user has the required permission in any project.
static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap, int[] permissionsNeeded)
          Returns true if the user has any of required permissions in any project.
static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap, Integer projectId, int permissionNeeded)
          Returns true if the user has the required permission for the given project.
static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap, Integer projectId, int[] permissionsNeeded)
          Returns true if the user has any of required permissions for the given project.
static boolean hideIndexSection(int section, int sections)
          Returns whether the user is currently hiding a particular section on the myItracker page.
static boolean isSuperUser(Map<Integer,Set<PermissionType>> permissionsMap)
          Checks to see if the user is a super user.
static Map<Integer,Set<PermissionType>> mapPermissionTypesByProjectId(List<Permission> permissionsList)
          Maps sets of permission types by project ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alphabet

protected static final char[] alphabet

STATUS_DELETED

public static final int STATUS_DELETED
See Also:
Constant Field Values

STATUS_ACTIVE

public static final int STATUS_ACTIVE
See Also:
Constant Field Values

STATUS_LOCKED

public static final int STATUS_LOCKED
See Also:
Constant Field Values

PERMISSION_USER_ADMIN

public static final int PERMISSION_USER_ADMIN
User Admin Permission. Currently this is equivalent to super user, since the permission can't be granted, and is only available to an admin.

See Also:
Constant Field Values

PERMISSION_PRODUCT_ADMIN

public static final int PERMISSION_PRODUCT_ADMIN
Product Admin Permission

See Also:
Constant Field Values

PERMISSION_CREATE

public static final int PERMISSION_CREATE
Issue Create Permission

See Also:
Constant Field Values

PERMISSION_EDIT

public static final int PERMISSION_EDIT
Issue Edit Permission. Users with this permission can edit any issue in the project.

See Also:
Constant Field Values

PERMISSION_CLOSE

public static final int PERMISSION_CLOSE
Issue Close Permission. Users with this permission can close issues in the project.

See Also:
Constant Field Values

PERMISSION_ASSIGN_SELF

public static final int PERMISSION_ASSIGN_SELF
Issue Assign to Self Permission. Users with this permission can assign issues to themselves.

See Also:
Constant Field Values

PERMISSION_ASSIGN_OTHERS

public static final int PERMISSION_ASSIGN_OTHERS
Issue Assign to Others Permissions. Users with this permission can assign issues to anyone, given than those users have the ability to recieve the assignment.

See Also:
Constant Field Values

PERMISSION_VIEW_ALL

public static final int PERMISSION_VIEW_ALL
View All Issues Permission. Users can view all issues in the project.

See Also:
Constant Field Values

PERMISSION_VIEW_USERS

public static final int PERMISSION_VIEW_USERS
View Users Issues Permission. Users can view thier own issues. This includes ones they are the creator or owner of.

See Also:
Constant Field Values

PERMISSION_EDIT_USERS

public static final int PERMISSION_EDIT_USERS
Edit Users Issues Permission. Users with this permission can edit any issue they created or own. They are limited to editing the description, adding history entries, and adding attachments.

See Also:
Constant Field Values

PERMISSION_UNASSIGN_SELF

public static final int PERMISSION_UNASSIGN_SELF
Issue Unassign Self Permission. Users with this permission can unassign issues they own.

See Also:
Constant Field Values

PERMISSION_ASSIGNABLE

public static final int PERMISSION_ASSIGNABLE
Issue Assignable. Users with this permission can be assigned any issue in the system. To determine if a user can be assigned an issue, it will be a combination of users with EDIT_ALL, users with EDIT_USERS if they are the creator, and users with this permission and EDIT_USERS.

See Also:
Constant Field Values

PERMISSION_CREATE_OTHERS

public static final int PERMISSION_CREATE_OTHERS
Create for Others. Users with this permission are allowed to create issues on behalf of other users. The system will treat the issue as if the other user had created it. The actual creator will be logged in the audit log.

See Also:
Constant Field Values

PERMISSION_EDIT_FULL

public static final int PERMISSION_EDIT_FULL
Full edit permission. This defines what levelof editing a user has for an issue. Without this permission, users will be limited to editing only the description, attachments, custom fields, and history of an issue.

See Also:
Constant Field Values

ALL_PERMISSIONS_SET

public static final Set<Integer> ALL_PERMISSIONS_SET

REGISTRATION_TYPE_ADMIN

public static final int REGISTRATION_TYPE_ADMIN
See Also:
Constant Field Values

REGISTRATION_TYPE_SELF

public static final int REGISTRATION_TYPE_SELF
See Also:
Constant Field Values

REGISTRATION_TYPE_IMPORT

public static final int REGISTRATION_TYPE_IMPORT
See Also:
Constant Field Values

PREF_HIDE_ASSIGNED

public static final int PREF_HIDE_ASSIGNED
See Also:
Constant Field Values

PREF_HIDE_UNASSIGNED

public static final int PREF_HIDE_UNASSIGNED
See Also:
Constant Field Values

PREF_HIDE_CREATED

public static final int PREF_HIDE_CREATED
See Also:
Constant Field Values

PREF_HIDE_WATCHED

public static final int PREF_HIDE_WATCHED
See Also:
Constant Field Values
Constructor Detail

UserUtilities

public UserUtilities()
Method Detail

getStatusName

public static String getStatusName(int value)

getStatusName

public static String getStatusName(int value,
                                   Locale locale)

getStatusNames

public static HashMap<String,String> getStatusNames()

getStatusNames

public static HashMap<String,String> getStatusNames(Locale locale)

getPermissionName

public static String getPermissionName(int value)

getPermissionName

public static String getPermissionName(int value,
                                       Locale locale)

getPermissionNames

public static List<NameValuePair> getPermissionNames()

getPermissionNames

public static List<NameValuePair> getPermissionNames(Locale locale)

generatePassword

public static String generatePassword()
                               throws PasswordException
Genrates a new random password. The password that is returned is in plain text.

Returns:
a new ramdon plaintext password
Throws:
PasswordException

encryptPassword

public static String encryptPassword(String password)
                              throws PasswordException
Returns an encrypted (digest) password from a plain text password.

Parameters:
password - the plain text password to encrypt.
Returns:
the encrypted password
Throws:
PasswordException

isSuperUser

public static boolean isSuperUser(Map<Integer,Set<PermissionType>> permissionsMap)
Checks to see if the user is a super user.

Parameters:
permissions - map of user permissions by project Id
Returns:
true is the user is a super user

hasPermission

public static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap,
                                    int permissionNeeded)
Returns true if the user has the required permission in any project.

Parameters:
permissions - a Map of the user's permissions by project ID
permissionNeeded - the permission to check for

hasPermission

public static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap,
                                    int[] permissionsNeeded)
Returns true if the user has any of required permissions in any project.

Parameters:
permissions - a HashMap of the user's permissions
permissionsNeeded - a list of permissions that can fulfill the permission check

hasPermission

public static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap,
                                    Integer projectId,
                                    int permissionNeeded)
Returns true if the user has the required permission for the given project.

Parameters:
permissions - a HashMap of the user's permissions
projectId - the project that the permission is required for
permissionNeeded - the permission to check for

hasPermission

public static boolean hasPermission(Map<Integer,Set<PermissionType>> permissionsMap,
                                    Integer projectId,
                                    int[] permissionsNeeded)
Returns true if the user has any of required permissions for the given project.

Parameters:
permissions - a HashMap of the user's permissions
projectId - the project that the permission is required for
permissionsNeeded - a list of permissions that can fulfill the permission check

getInitial

public static String getInitial(String name)

createPermissionArray

public static Permission[] createPermissionArray(User user,
                                                 Project project,
                                                 int[] permissions)

mapPermissionTypesByProjectId

public static Map<Integer,Set<PermissionType>> mapPermissionTypesByProjectId(List<Permission> permissionsList)
Maps sets of permission types by project ID.


hideIndexSection

public static boolean hideIndexSection(int section,
                                       int sections)
Returns whether the user is currently hiding a particular section on the myItracker page.

Parameters:
section - the section to check if it is hidden
an - integer of all sections the user is hiding
Returns:
true if the current section is hidden

getHiddenIndexSections

public static Integer[] getHiddenIndexSections(int sections)

getAssignableIssueOwnersList

public static List<NameValuePair> getAssignableIssueOwnersList(Issue issue,
                                                               Project project,
                                                               User currUser,
                                                               Locale locale,
                                                               UserService userService,
                                                               Map<Integer,Set<PermissionType>> userPermissions)
This method will obtain and build a list of possible owners for the webpages to display and the operator to choose from.

Parameters:
issue -
project -
currUser -
locale -
userPermissions -
Returns:


Copyright © 2002-2012 itracker. All Rights Reserved.