org.alfresco.repo.security.person
Class PersonServiceImpl

java.lang.Object
  extended by org.alfresco.repo.transaction.TransactionListenerAdapter
      extended by org.alfresco.repo.security.person.PersonServiceImpl
All Implemented Interfaces:
NodeServicePolicies.BeforeCreateNodePolicy, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, ClassPolicy, Policy, TransactionListener, PersonService

public class PersonServiceImpl
extends TransactionListenerAdapter
implements PersonService, NodeServicePolicies.BeforeCreateNodePolicy, NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy


Nested Class Summary
static class PersonServiceImpl.NodeIdComparator
           
 
Nested classes/interfaces inherited from interface org.alfresco.service.cmr.security.PersonService
PersonService.PersonInfo
 
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy
Policy.Arg
 
Field Summary
static java.lang.String KEY_ALLOW_UID_UPDATE
           
static java.lang.String PEOPLE_FOLDER_SHORT_QNAME
           
static java.lang.String SYSTEM_FOLDER_SHORT_QNAME
           
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeCreateNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy
ARG_0, ARG_1, ARG_2, QNAME
 
Fields inherited from interface org.alfresco.repo.policy.Policy
NAMESPACE
 
Constructor Summary
PersonServiceImpl()
           
 
Method Summary
 void afterCommit()
          Process clean up any duplicates that were flagged during the transaction.
 void beforeCommit(boolean readOnly)
          Called before a transaction is committed.
 void beforeCreateNode(org.alfresco.service.cmr.repository.NodeRef parentRef, org.alfresco.service.namespace.QName assocTypeQName, org.alfresco.service.namespace.QName assocQName, org.alfresco.service.namespace.QName nodeTypeQName)
          Called before a new node is created.
 void beforeCreateNodeValidation(org.alfresco.service.cmr.repository.NodeRef parentRef, org.alfresco.service.namespace.QName assocTypeQName, org.alfresco.service.namespace.QName assocQName, org.alfresco.service.namespace.QName nodeTypeQName)
           
 void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Called before a node is deleted.
 void beforeDeleteNodeValidation(org.alfresco.service.cmr.repository.NodeRef nodeRef)
           
 boolean createMissingPeople()
          Does this service create people on demand if they are missing.
 org.alfresco.service.cmr.repository.NodeRef createPerson(java.util.Map properties)
          Create a new person with the given properties.
 org.alfresco.service.cmr.repository.NodeRef createPerson(java.util.Map properties, java.util.Set zones)
          Create a new person with the given properties, recording them against the given zone name (usually identifying an external user registry from which the details were obtained).
 void deletePerson(org.alfresco.service.cmr.repository.NodeRef personRef)
          Delete the person identified by the given ref.
 void deletePerson(java.lang.String userName)
          Delete the person identified by the given user name.
 boolean equals(java.lang.Object obj)
           
 java.util.Set getAllPeople()
          Deprecated. see getPeople
 java.util.Set getMutableProperties()
          Get the list of properties that are mutable.
 org.alfresco.query.PagingResults getPeople(java.util.List stringPropFilters, boolean filterIgnoreCase, java.util.List sortProps, org.alfresco.query.PagingRequest pagingRequest)
          Get paged list of people optionally filtered and/or sorted
 org.alfresco.service.cmr.repository.NodeRef getPeopleContainer()
          Return the container that stores people.
 java.util.Set getPeopleFilteredByProperty(org.alfresco.service.namespace.QName propertyKey, java.io.Serializable propertyValue)
          Deprecated. see getPeople
 org.alfresco.service.cmr.repository.NodeRef getPerson(java.lang.String userName)
          Get a person by userName.
 org.alfresco.service.cmr.repository.NodeRef getPerson(java.lang.String userName, boolean autoCreate)
          Retrieve the person NodeRef for a username key.
 java.lang.String getUserIdentifier(java.lang.String caseSensitiveUserName)
          Given the case sensitive user name find the approriate identifier from the person service.
 boolean getUserNamesAreCaseSensitive()
          Are user names case sensitive?
 int hashCode()
           
 void init()
          Spring bean init method
 boolean isMutable()
          Can this service create, delete and update person information?
 void notifyPerson(java.lang.String userName, java.lang.String password)
          Notifies a user by email that their account has been created, and the details of it.
 void onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
          Called when a new node has been created.
 void onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.Map before, java.util.Map after)
          When a uid is changed we need to create an alias for the old uid so permissions are not broken.
 void onUpdatePropertiesUser(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.Map before, java.util.Map after)
          Track the enabled/disabled flag on cm:user.
 boolean personExists(java.lang.String caseSensitiveUserName)
          Check if a person exists.
 void setAclDAO(AclDAO aclDao)
           
 void setAuthenticationService(MutableAuthenticationService authenticationService)
           
 void setAuthorityService(AuthorityService authorityService)
           
 void setCannedQueryRegistry(org.alfresco.util.registry.NamedObjectRegistry cannedQueryRegistry)
          Set the registry of canned queries
 void setCreateMissingPeople(boolean createMissingPeople)
          Set if missing people should be created.
 void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
           
 void setDuplicateMode(java.lang.String duplicateMode)
           
 void setHomeFolderCreationEager(boolean homeFolderCreationEager)
          Indicates if home folders should be created when the person is created or delayed until first accessed.
 void setHomeFolderManager(HomeFolderManager homeFolderManager)
           
 void setIncludeAutoCreated(boolean includeAutoCreated)
           
 void setLastIsBest(boolean lastIsBest)
           
 void setNamespacePrefixResolver(org.alfresco.service.namespace.NamespacePrefixResolver namespacePrefixResolver)
           
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
           
 void setPermissionServiceSPI(PermissionServiceSPI permissionServiceSPI)
           
 void setPermissionsManager(PermissionsManager permissionsManager)
           
 void setPersonCache(org.alfresco.repo.cache.SimpleCache personCache)
          Set the username to person cache.
 void setPersonProperties(java.lang.String userName, java.util.Map properties)
          Set the properties on a person - some of these may be persisted in different locations.
 void setPersonProperties(java.lang.String userName, java.util.Map properties, boolean autoCreate)
          Set the properties on a person - some of these may be persisted in different locations.
 void setPolicyComponent(PolicyComponent policyComponent)
           
 void setProcessDuplicates(boolean processDuplicates)
           
 void setRepoAdminService(RepoAdminService repoAdminService)
           
 void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
           
 void setServiceRegistry(ServiceRegistry serviceRegistry)
           
 void setStoreUrl(java.lang.String storeUrl)
           
 void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
           
 void setTransactionService(TransactionService transactionService)
           
 void setUserNameMatcher(UserNameMatcher userNameMatcher)
           
static java.lang.String updateUsernameForTenancy(java.lang.String username, org.alfresco.repo.tenant.TenantService tenantService)
          Helper for when creating new users and people: Updates the supplied username with any required tenant details, and ensures that the tenant domains match.
 
Methods inherited from class org.alfresco.repo.transaction.TransactionListenerAdapter
afterRollback, beforeCompletion, flush
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_FOLDER_SHORT_QNAME

public static final java.lang.String SYSTEM_FOLDER_SHORT_QNAME
See Also:
Constant Field Values

PEOPLE_FOLDER_SHORT_QNAME

public static final java.lang.String PEOPLE_FOLDER_SHORT_QNAME
See Also:
Constant Field Values

KEY_ALLOW_UID_UPDATE

public static final java.lang.String KEY_ALLOW_UID_UPDATE
See Also:
Constant Field Values
Constructor Detail

PersonServiceImpl

public PersonServiceImpl()
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

init

public void init()
Spring bean init method


setCreateMissingPeople

public void setCreateMissingPeople(boolean createMissingPeople)
Set if missing people should be created.

Specified by:
setCreateMissingPeople in interface PersonService
Parameters:
createMissingPeople - set to true to create people
See Also:
PersonService.getPerson(String)

setNamespacePrefixResolver

public void setNamespacePrefixResolver(org.alfresco.service.namespace.NamespacePrefixResolver namespacePrefixResolver)

setAuthorityService

public void setAuthorityService(AuthorityService authorityService)

setAuthenticationService

public void setAuthenticationService(MutableAuthenticationService authenticationService)

setDictionaryService

public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)

setPermissionServiceSPI

public void setPermissionServiceSPI(PermissionServiceSPI permissionServiceSPI)

setTransactionService

public void setTransactionService(TransactionService transactionService)

setServiceRegistry

public void setServiceRegistry(ServiceRegistry serviceRegistry)

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)

setTenantService

public void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)

setSearchService

public void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)

setRepoAdminService

public void setRepoAdminService(RepoAdminService repoAdminService)

setPolicyComponent

public void setPolicyComponent(PolicyComponent policyComponent)

setStoreUrl

public void setStoreUrl(java.lang.String storeUrl)

setUserNameMatcher

public void setUserNameMatcher(UserNameMatcher userNameMatcher)

setDuplicateMode

public void setDuplicateMode(java.lang.String duplicateMode)

setIncludeAutoCreated

public void setIncludeAutoCreated(boolean includeAutoCreated)

setLastIsBest

public void setLastIsBest(boolean lastIsBest)

setProcessDuplicates

public void setProcessDuplicates(boolean processDuplicates)

setHomeFolderManager

public void setHomeFolderManager(HomeFolderManager homeFolderManager)

setHomeFolderCreationEager

public void setHomeFolderCreationEager(boolean homeFolderCreationEager)
Indicates if home folders should be created when the person is created or delayed until first accessed.


setAclDAO

public void setAclDAO(AclDAO aclDao)

setPermissionsManager

public void setPermissionsManager(PermissionsManager permissionsManager)

setCannedQueryRegistry

public void setCannedQueryRegistry(org.alfresco.util.registry.NamedObjectRegistry cannedQueryRegistry)
Set the registry of canned queries


setPersonCache

public void setPersonCache(org.alfresco.repo.cache.SimpleCache personCache)
Set the username to person cache.


getPerson

public org.alfresco.service.cmr.repository.NodeRef getPerson(java.lang.String userName)
Get a person by userName. The person is store in the repository. The person may be created as a side effect of this call, depending on the setting to create missing people or not.

Specified by:
getPerson in interface PersonService
Parameters:
userName - - the userName key to find the person
Returns:
Returns the person node, either existing or new
See Also:
PersonService.setCreateMissingPeople(boolean), PersonService.createMissingPeople()

getPerson

public org.alfresco.service.cmr.repository.NodeRef getPerson(java.lang.String userName,
                                                             boolean autoCreate)
Retrieve the person NodeRef for a username key. Depending on the autoCreate parameter and configuration missing people will be created if not found, else a NoSuchPersonException exception will be thrown.

Specified by:
getPerson in interface PersonService
Parameters:
userName - of the person NodeRef to retrieve
autoCreate - should we auto-create the person node and home folder if they don't exist? (and configuration allows us to)
Returns:
NodeRef of the person as specified by the username

personExists

public boolean personExists(java.lang.String caseSensitiveUserName)
Check if a person exists.

Specified by:
personExists in interface PersonService
Parameters:
caseSensitiveUserName - the user name
Returns:
Returns true if the user exists, otherwise false

afterCommit

public void afterCommit()
Process clean up any duplicates that were flagged during the transaction.

Specified by:
afterCommit in interface TransactionListener
Overrides:
afterCommit in class TransactionListenerAdapter

createMissingPeople

public boolean createMissingPeople()
Does this service create people on demand if they are missing. If this is true, a call to getPerson() will create a person if they are missing.

Specified by:
createMissingPeople in interface PersonService
Returns:
true if people are created on demand and false otherwise.

getMutableProperties

public java.util.Set getMutableProperties()
Get the list of properties that are mutable. Some service may only allow a limited list of properties to be changed. This may be those persisted in the repository or those that can be changed in some other implementation such as LDAP.

Specified by:
getMutableProperties in interface PersonService
Returns:
A set of QNames that identify properties that can be changed

setPersonProperties

public void setPersonProperties(java.lang.String userName,
                                java.util.Map properties)
Set the properties on a person - some of these may be persisted in different locations.

Specified by:
setPersonProperties in interface PersonService
Parameters:
userName - - the user for which the properties should be set.
properties - - the map of properties to set (as the NodeService)

setPersonProperties

public void setPersonProperties(java.lang.String userName,
                                java.util.Map properties,
                                boolean autoCreate)
Set the properties on a person - some of these may be persisted in different locations.

Specified by:
setPersonProperties in interface PersonService
Parameters:
userName - - the user for which the properties should be set.
properties - - the map of properties to set (as the NodeService)
autoCreate - should we auto-create the home folder if it doesn't exist? (and configuration allows us to)

isMutable

public boolean isMutable()
Can this service create, delete and update person information?

Specified by:
isMutable in interface PersonService
Returns:
true if this service allows mutation to people.

createPerson

public org.alfresco.service.cmr.repository.NodeRef createPerson(java.util.Map properties)
Create a new person with the given properties. The userName is one of the properties. Users with duplicate userNames are not allowed.

Specified by:
createPerson in interface PersonService
Returns:

createPerson

public org.alfresco.service.cmr.repository.NodeRef createPerson(java.util.Map properties,
                                                                java.util.Set zones)
Create a new person with the given properties, recording them against the given zone name (usually identifying an external user registry from which the details were obtained). The userName is one of the properties. Users with duplicate userNames are not allowed.

Specified by:
createPerson in interface PersonService
Parameters:
properties - the properties
zones - a set if zones including the identifier for the external user registry owning the person information, or null or an empty set
Returns:
the node ref

notifyPerson

public void notifyPerson(java.lang.String userName,
                         java.lang.String password)
Notifies a user by email that their account has been created, and the details of it. Normally called after PersonService.createPerson(Map) or PersonService.createPerson(Map, Set) where email notifications are required.

Specified by:
notifyPerson in interface PersonService
Parameters:
userName - of the person to notify
password - of the person to notify

getPeopleContainer

public org.alfresco.service.cmr.repository.NodeRef getPeopleContainer()
Return the container that stores people.

Specified by:
getPeopleContainer in interface PersonService
Returns:

deletePerson

public void deletePerson(java.lang.String userName)
Delete the person identified by the given user name.

Specified by:
deletePerson in interface PersonService

deletePerson

public void deletePerson(org.alfresco.service.cmr.repository.NodeRef personRef)
Delete the person identified by the given ref.

Specified by:
deletePerson in interface PersonService

getAllPeople

public java.util.Set getAllPeople()
Deprecated. see getPeople

Get all the people we know about.

Specified by:
getAllPeople in interface PersonService
Returns:
a set of people in no specific order.

getPeople

public org.alfresco.query.PagingResults getPeople(java.util.List stringPropFilters,
                                                  boolean filterIgnoreCase,
                                                  java.util.List sortProps,
                                                  org.alfresco.query.PagingRequest pagingRequest)
Get paged list of people optionally filtered and/or sorted

Specified by:
getPeople in interface PersonService
filterIgnoreCase - true to ignore case when filtering, false to be case-sensitive when filtering
sortProps - sort property, eg. cm:username ascending
pagingRequest - skip, max + optional query execution id

getPeopleFilteredByProperty

public java.util.Set getPeopleFilteredByProperty(org.alfresco.service.namespace.QName propertyKey,
                                                 java.io.Serializable propertyValue)
Deprecated. see getPeople

Get people filtered by the given property name/value pair

Specified by:
getPeopleFilteredByProperty in interface PersonService
Parameters:
propertyKey - property key of property to filter people by
propertyValue - property value of property to filter people by
Returns:
people filtered by the given property name/value pair

onCreateNode

public void onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
Called when a new node has been created.

Specified by:
onCreateNode in interface NodeServicePolicies.OnCreateNodePolicy
Parameters:
childAssocRef - the created child association reference

beforeCreateNode

public void beforeCreateNode(org.alfresco.service.cmr.repository.NodeRef parentRef,
                             org.alfresco.service.namespace.QName assocTypeQName,
                             org.alfresco.service.namespace.QName assocQName,
                             org.alfresco.service.namespace.QName nodeTypeQName)
Description copied from interface: NodeServicePolicies.BeforeCreateNodePolicy
Called before a new node is created.

Specified by:
beforeCreateNode in interface NodeServicePolicies.BeforeCreateNodePolicy
Parameters:
parentRef - the parent node reference
assocTypeQName - the association type qualified name
assocQName - the association qualified name
nodeTypeQName - the node type qualified name

beforeCreateNodeValidation

public void beforeCreateNodeValidation(org.alfresco.service.cmr.repository.NodeRef parentRef,
                                       org.alfresco.service.namespace.QName assocTypeQName,
                                       org.alfresco.service.namespace.QName assocQName,
                                       org.alfresco.service.namespace.QName nodeTypeQName)

beforeDeleteNode

public void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: NodeServicePolicies.BeforeDeleteNodePolicy
Called before a node is deleted.

Specified by:
beforeDeleteNode in interface NodeServicePolicies.BeforeDeleteNodePolicy
Parameters:
nodeRef - the node reference

beforeDeleteNodeValidation

public void beforeDeleteNodeValidation(org.alfresco.service.cmr.repository.NodeRef nodeRef)

getUserIdentifier

public java.lang.String getUserIdentifier(java.lang.String caseSensitiveUserName)
Given the case sensitive user name find the approriate identifier from the person service. If the system is case sensitive it will return the same string. If case insentive it will return the common object. If the user does not exist it will return null;

Specified by:
getUserIdentifier in interface PersonService
Returns:

getUserNamesAreCaseSensitive

public boolean getUserNamesAreCaseSensitive()
Are user names case sensitive?

Specified by:
getUserNamesAreCaseSensitive in interface PersonService
Returns:

onUpdateProperties

public void onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                               java.util.Map before,
                               java.util.Map after)
When a uid is changed we need to create an alias for the old uid so permissions are not broken. This can happen when an already existing user is updated via LDAP e.g. migration to LDAP, or when a user is auto created and then updated by LDAP This is probably less likely after 3.2 and sync on missing person See https://issues.alfresco.com/jira/browse/ETWOTWO-389 (non-Javadoc)

Specified by:
onUpdateProperties in interface NodeServicePolicies.OnUpdatePropertiesPolicy
Parameters:
nodeRef - reference to the updated node
before - the node's properties before the change
after - the node's properties after the change

onUpdatePropertiesUser

public void onUpdatePropertiesUser(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                   java.util.Map before,
                                   java.util.Map after)
Track the enabled/disabled flag on cm:user.


beforeCommit

public void beforeCommit(boolean readOnly)
Called before a transaction is committed.

All transaction resources are still available.

Specified by:
beforeCommit in interface TransactionListener
Overrides:
beforeCommit in class TransactionListenerAdapter
Parameters:
readOnly - true if the transaction is read-only

updateUsernameForTenancy

public static java.lang.String updateUsernameForTenancy(java.lang.String username,
                                                        org.alfresco.repo.tenant.TenantService tenantService)
                                                 throws TenantDomainMismatchException
Helper for when creating new users and people: Updates the supplied username with any required tenant details, and ensures that the tenant domains match. If Multi-Tenant is disabled, returns the same username.

Throws:
TenantDomainMismatchException


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.