org.exist.xmldb
Class LocalUserManagementService

java.lang.Object
  extended by org.exist.xmldb.LocalUserManagementService
All Implemented Interfaces:
EXistUserManagementService, UserManagementService, Configurable, Service

public class LocalUserManagementService
extends Object
implements EXistUserManagementService

Local Implementation (i.e. embedded) of an eXist-specific service which provides methods to manage users and permissions.

Author:
Wolfgang Meier , Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it, Adam Retter

Constructor Summary
LocalUserManagementService(Subject user, BrokerPool pool, LocalCollection collection)
           
 
Method Summary
 void addAccount(Account u)
          Add a new account to the database
 void addAccountToGroup(String accountName, String groupName)
           
 void addGroup(Group group)
           
 void addGroupManager(String manager, String groupName)
           
 void addUser(User user)
           
 void addUserGroup(Account user)
          Update the specified user without update user's password Method added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
 void chmod(int mode)
           
 void chmod(Resource resource, int mode)
          Change permissions for the specified resource.
 void chmod(Resource resource, String modeStr)
          Change permissions for the specified resource.
 void chmod(String modeStr)
          Change permissions for the current collection
 void chown(Account u, String group)
          Change owner and group of the current collection.
 void chown(Resource resource, Account u, String group)
          Change owner and group of the specified resource.
 Account getAccount(String name)
          Get a account record from the database
 Account[] getAccounts()
          Retrieve a list of all existing accounts.
 Group getGroup(String name)
           
 String[] getGroupMembers(String groupName)
           
 String[] getGroups()
          Retrieve a list of all existing groups.
 String getName()
          Get the name of this service
 Permission getPermissions(Collection coll)
          Get permissions for the specified collections
 Permission getPermissions(Resource resource)
          Get permissions for the specified resource
 String getProperty(String property)
          Get a property defined by this service.
 Date getSubCollectionCreationTime(Collection parent, String name)
           
 Permission getSubCollectionPermissions(Collection parent, String name)
          Get the permissions of the sub-collection
 Permission getSubResourcePermissions(Collection parent, String name)
          Get the permissions of the sub-resource
 User getUser(String name)
           
 User[] getUsers()
           
 String getVersion()
          Get the version of this service
 String hasUserLock(Resource res)
          Check if the resource has a user lock.
 Permission[] listCollectionPermissions()
          Get permissions for all child collections contained in the current collection.
 Permission[] listResourcePermissions()
          Get permissions for all resources contained in the current collection.
 void lockResource(Resource resource, Account u)
          Lock the specified resource for the specified user.
 void lockResource(Resource res, User u)
           
 void removeAccount(Account u)
          Delete a user from the database
 void removeGroup(Group group)
           
 void removeGroupManager(String groupName, String manager)
           
 void removeGroupMember(String group, String member)
           
 void removeUser(User user)
           
 void setCollection(Collection collection)
          Set the current collection for this service
 void setPermissions(Collection child, Permission perm)
          Set permissions for the specified collection.
 void setPermissions(Collection child, String owner, String group, int mode, List<ACEAider> aces)
           
 void setPermissions(Resource resource, Permission perm)
          Set permissions for the specified resource.
 void setPermissions(Resource resource, String owner, String group, int mode, List<ACEAider> aces)
           
 void setProperty(String property, String value)
          Set a property for this service.
 void setUserPrimaryGroup(String username, String groupName)
           
 void unlockResource(Resource resource)
          Unlock the specified resource.
 void updateAccount(Account u)
          Update existing account information
 void updateGroup(Group g)
          Update existing group information
 void updateUser(User user)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalUserManagementService

public LocalUserManagementService(Subject user,
                                  BrokerPool pool,
                                  LocalCollection collection)
Method Detail

getName

public String getName()
Description copied from interface: UserManagementService
Get the name of this service

Specified by:
getName in interface UserManagementService
Specified by:
getName in interface Service
Returns:
The name

getVersion

public String getVersion()
Description copied from interface: UserManagementService
Get the version of this service

Specified by:
getVersion in interface UserManagementService
Specified by:
getVersion in interface Service
Returns:
The version value

addAccount

public void addAccount(Account u)
                throws XMLDBException
Description copied from interface: UserManagementService
Add a new account to the database

Specified by:
addAccount in interface UserManagementService
Parameters:
u - The feature to be added to the Account
Throws:
XMLDBException - Description of the Exception

addGroup

public void addGroup(Group group)
              throws XMLDBException
Specified by:
addGroup in interface UserManagementService
Throws:
XMLDBException

setUserPrimaryGroup

public void setUserPrimaryGroup(String username,
                                String groupName)
                         throws XMLDBException
Specified by:
setUserPrimaryGroup in interface EXistUserManagementService
Throws:
XMLDBException

setPermissions

public void setPermissions(Resource resource,
                           Permission perm)
                    throws XMLDBException
Description copied from interface: UserManagementService
Set permissions for the specified resource.

Specified by:
setPermissions in interface UserManagementService
Throws:
XMLDBException

setPermissions

public void setPermissions(Collection child,
                           Permission perm)
                    throws XMLDBException
Description copied from interface: UserManagementService
Set permissions for the specified collection.

Specified by:
setPermissions in interface UserManagementService
Throws:
XMLDBException

setPermissions

public void setPermissions(Collection child,
                           String owner,
                           String group,
                           int mode,
                           List<ACEAider> aces)
                    throws XMLDBException
Specified by:
setPermissions in interface UserManagementService
Throws:
XMLDBException

setPermissions

public void setPermissions(Resource resource,
                           String owner,
                           String group,
                           int mode,
                           List<ACEAider> aces)
                    throws XMLDBException
Specified by:
setPermissions in interface UserManagementService
Throws:
XMLDBException

chmod

public void chmod(String modeStr)
           throws XMLDBException
Description copied from interface: UserManagementService
Change permissions for the current collection

Specified by:
chmod in interface UserManagementService
Parameters:
modeStr - String describing the permissions to grant or deny.
Throws:
XMLDBException

chmod

public void chmod(Resource resource,
                  int mode)
           throws XMLDBException
Description copied from interface: UserManagementService
Change permissions for the specified resource.

Specified by:
chmod in interface UserManagementService
Throws:
XMLDBException

chmod

public void chmod(int mode)
           throws XMLDBException
Specified by:
chmod in interface UserManagementService
Throws:
XMLDBException

chmod

public void chmod(Resource resource,
                  String modeStr)
           throws XMLDBException
Description copied from interface: UserManagementService
Change permissions for the specified resource. Permissions are specified in a string according to the following format:
[user|group|other]=[+|-][read|write|update]
For example, to grant all permissions to the group and deny everything to others: group=+write,+read,+update,other=-read The changes are applied to the permissions currently active for this resource.

Specified by:
chmod in interface UserManagementService
Parameters:
resource - Description of the Parameter
modeStr - Description of the Parameter
Throws:
XMLDBException - Description of the Exception

chown

public void chown(Account u,
                  String group)
           throws XMLDBException
Description copied from interface: UserManagementService
Change owner and group of the current collection.

Specified by:
chown in interface UserManagementService
Parameters:
u - Description of the Parameter
group - Description of the Parameter
Throws:
XMLDBException - Description of the Exception

chown

public void chown(Resource resource,
                  Account u,
                  String group)
           throws XMLDBException
Description copied from interface: UserManagementService
Change owner and group of the specified resource.

Specified by:
chown in interface UserManagementService
Parameters:
resource - Description of the Parameter
u - Description of the Parameter
group - Description of the Parameter
Throws:
XMLDBException - Description of the Exception

hasUserLock

public String hasUserLock(Resource res)
                   throws XMLDBException
Description copied from interface: UserManagementService
Check if the resource has a user lock. Returns the name of the owner of the lock or null if no lock has been set on the resource.

Specified by:
hasUserLock in interface UserManagementService
Returns:
Name of the owner of the lock
Throws:
XMLDBException

lockResource

public void lockResource(Resource resource,
                         Account u)
                  throws XMLDBException
Description copied from interface: UserManagementService
Lock the specified resource for the specified user. A locked resource cannot be changed by other users (except users in group DBA) until the lock is released. Users with admin privileges can always change a resource.

Specified by:
lockResource in interface UserManagementService
Throws:
XMLDBException

unlockResource

public void unlockResource(Resource resource)
                    throws XMLDBException
Description copied from interface: UserManagementService
Unlock the specified resource. The current user has to be same who locked the resource. Exception: admin users can always unlock a resource.

Specified by:
unlockResource in interface UserManagementService
Throws:
XMLDBException

getPermissions

public Permission getPermissions(Collection coll)
                          throws XMLDBException
Description copied from interface: UserManagementService
Get permissions for the specified collections

Specified by:
getPermissions in interface UserManagementService
Parameters:
coll - Description of the Parameter
Returns:
The permissions value
Throws:
XMLDBException - Description of the Exception

getSubCollectionPermissions

public Permission getSubCollectionPermissions(Collection parent,
                                              String name)
                                       throws XMLDBException
Description copied from interface: UserManagementService
Get the permissions of the sub-collection

Specified by:
getSubCollectionPermissions in interface UserManagementService
Throws:
XMLDBException

getSubResourcePermissions

public Permission getSubResourcePermissions(Collection parent,
                                            String name)
                                     throws XMLDBException
Description copied from interface: UserManagementService
Get the permissions of the sub-resource

Specified by:
getSubResourcePermissions in interface UserManagementService
Throws:
XMLDBException

getSubCollectionCreationTime

public Date getSubCollectionCreationTime(Collection parent,
                                         String name)
                                  throws XMLDBException
Specified by:
getSubCollectionCreationTime in interface UserManagementService
Throws:
XMLDBException

getPermissions

public Permission getPermissions(Resource resource)
                          throws XMLDBException
Description copied from interface: UserManagementService
Get permissions for the specified resource

Specified by:
getPermissions in interface UserManagementService
Parameters:
resource - Description of the Parameter
Returns:
The permissions value
Throws:
XMLDBException - Description of the Exception

listResourcePermissions

public Permission[] listResourcePermissions()
                                     throws XMLDBException
Description copied from interface: UserManagementService
Get permissions for all resources contained in the current collection. Returns a list of permissions in the same order as Collection.listResources().

Specified by:
listResourcePermissions in interface UserManagementService
Returns:
Permission[]
Throws:
XMLDBException

listCollectionPermissions

public Permission[] listCollectionPermissions()
                                       throws XMLDBException
Description copied from interface: UserManagementService
Get permissions for all child collections contained in the current collection. Returns a list of permissions in the same order as Collection.listChildCollections().

Specified by:
listCollectionPermissions in interface UserManagementService
Returns:
Permission[]
Throws:
XMLDBException

getAccount

public Account getAccount(String name)
                   throws XMLDBException
Description copied from interface: UserManagementService
Get a account record from the database

Specified by:
getAccount in interface UserManagementService
Parameters:
name - Description of the Parameter
Returns:
The user value
Throws:
XMLDBException - Description of the Exception

getAccounts

public Account[] getAccounts()
                      throws XMLDBException
Description copied from interface: UserManagementService
Retrieve a list of all existing accounts.

Specified by:
getAccounts in interface UserManagementService
Returns:
The accounts value
Throws:
XMLDBException - Description of the Exception

getGroup

public Group getGroup(String name)
               throws XMLDBException
Specified by:
getGroup in interface UserManagementService
Throws:
XMLDBException

getGroups

public String[] getGroups()
                   throws XMLDBException
Description copied from interface: UserManagementService
Retrieve a list of all existing groups. Please note: new groups are created automatically if a new group is assigned to a user. You can't add or remove them.

Specified by:
getGroups in interface UserManagementService
Returns:
List of all existing groups.
Throws:
XMLDBException

removeAccount

public void removeAccount(Account u)
                   throws XMLDBException
Description copied from interface: UserManagementService
Delete a user from the database

Specified by:
removeAccount in interface UserManagementService
Parameters:
u - User
Throws:
XMLDBException

removeGroup

public void removeGroup(Group group)
                 throws XMLDBException
Specified by:
removeGroup in interface UserManagementService
Throws:
XMLDBException

setCollection

public void setCollection(Collection collection)
                   throws XMLDBException
Description copied from interface: UserManagementService
Set the current collection for this service

Specified by:
setCollection in interface UserManagementService
Specified by:
setCollection in interface Service
Parameters:
collection - The new collection value
Throws:
XMLDBException - Description of the Exception

updateAccount

public void updateAccount(Account u)
                   throws XMLDBException
Description copied from interface: UserManagementService
Update existing account information

Specified by:
updateAccount in interface UserManagementService
Parameters:
u - Description of the Parameter
Throws:
XMLDBException - Description of the Exception

updateGroup

public void updateGroup(Group g)
                 throws XMLDBException
Description copied from interface: UserManagementService
Update existing group information

Specified by:
updateGroup in interface UserManagementService
Parameters:
g - The group to update
Throws:
XMLDBException - if the group could not be updated

getGroupMembers

public String[] getGroupMembers(String groupName)
                         throws XMLDBException
Specified by:
getGroupMembers in interface UserManagementService
Throws:
XMLDBException

addAccountToGroup

public void addAccountToGroup(String accountName,
                              String groupName)
                       throws XMLDBException
Specified by:
addAccountToGroup in interface UserManagementService
Throws:
XMLDBException

addGroupManager

public void addGroupManager(String manager,
                            String groupName)
                     throws XMLDBException
Specified by:
addGroupManager in interface UserManagementService
Throws:
XMLDBException

removeGroupManager

public void removeGroupManager(String groupName,
                               String manager)
                        throws XMLDBException
Specified by:
removeGroupManager in interface UserManagementService
Throws:
XMLDBException

addUserGroup

public void addUserGroup(Account user)
                  throws XMLDBException
Description copied from interface: UserManagementService
Update the specified user without update user's password Method added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it

Specified by:
addUserGroup in interface UserManagementService
Parameters:
user - Description of the Parameter
Throws:
XMLDBException - Description of the Exception

removeGroupMember

public void removeGroupMember(String group,
                              String member)
                       throws XMLDBException
Specified by:
removeGroupMember in interface UserManagementService
Throws:
XMLDBException

addUser

public void addUser(User user)
             throws XMLDBException
Specified by:
addUser in interface UserManagementService
Throws:
XMLDBException

updateUser

public void updateUser(User user)
                throws XMLDBException
Specified by:
updateUser in interface UserManagementService
Throws:
XMLDBException

getUser

public User getUser(String name)
             throws XMLDBException
Specified by:
getUser in interface UserManagementService
Throws:
XMLDBException

getUsers

public User[] getUsers()
                throws XMLDBException
Specified by:
getUsers in interface UserManagementService
Throws:
XMLDBException

removeUser

public void removeUser(User user)
                throws XMLDBException
Specified by:
removeUser in interface UserManagementService
Throws:
XMLDBException

lockResource

public void lockResource(Resource res,
                         User u)
                  throws XMLDBException
Specified by:
lockResource in interface UserManagementService
Throws:
XMLDBException

getProperty

public String getProperty(String property)
                   throws XMLDBException
Description copied from interface: UserManagementService
Get a property defined by this service.

Specified by:
getProperty in interface UserManagementService
Specified by:
getProperty in interface Configurable
Parameters:
property - Description of the Parameter
Returns:
The property value
Throws:
XMLDBException - Description of the Exception

setProperty

public void setProperty(String property,
                        String value)
                 throws XMLDBException
Description copied from interface: UserManagementService
Set a property for this service.

Specified by:
setProperty in interface UserManagementService
Specified by:
setProperty in interface Configurable
Parameters:
property - The new property value
value - The new property value
Throws:
XMLDBException - Description of the Exception


Copyright (C) The eXist-db Project. All rights reserved.