Class AuthorityServiceImpl
java.lang.Object
org.alfresco.repo.security.authority.AuthorityServiceImpl
- All Implemented Interfaces:
AuthorityService,org.springframework.beans.factory.InitializingBean
public class AuthorityServiceImpl
extends Object
implements AuthorityService, org.springframework.beans.factory.InitializingBean
The default implementation of the authority service.
- Author:
- Andy Hind
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classLazy load set of authorities.Nested classes/interfaces inherited from interface org.alfresco.service.cmr.security.AuthorityService
AuthorityService.AuthorityFilter -
Field Summary
FieldsFields inherited from interface org.alfresco.service.cmr.security.AuthorityService
ZONE_APP_DEFAULT, ZONE_APP_SHARE, ZONE_AUTH_ALFRESCO, ZONE_AUTH_EXT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAuthority(String parentName, String childName) Set an authority to include another authority.voidaddAuthority(Collection<String> parentNames, String childName) Set a given child authority to be included by the given parent authorities.voidaddAuthorityToZones(String authorityName, Set<String> zones) Add a zone to an authority.voidbooleanauthorityExists(String name) Check if an authority exists.longCount the number of users (not groups)longCount the number of groupscreateAuthority(AuthorityType type, String shortName) Create an authority.createAuthority(AuthorityType type, String shortName, String authorityDisplayName, Set<String> authorityZones) Create an authority with a display name and zone.createAuthority(AuthorityType type, String shortName, String authorityDisplayName, Set<String> authorityZones, Map<QName, Serializable> properties) Create an authority with a display name and zone.createAuthority(AuthorityType type, String shortName, Map<QName, Serializable> properties) Create an authority with properties.voiddeleteAuthority(String name) Delete an authority and all its relationships.voiddeleteAuthority(String name, boolean cascade) Delete an authority and all its relationships, optionally recursively deleting child authorities of the same type.findAuthorities(AuthorityType type, String parentAuthority, boolean immediate, String displayNamePattern, String zoneName) Search for authorities by pattern matching (* and ?) against the authority name.Get all authorities by type See also "getAuthorities" (paged) alternativegetAllAuthoritiesInZone(String zoneName, AuthorityType type) Gets the names of all authorities in a zone, optionally filtered by type See also "getAuthorities" paged alternative (note: in that case, zone must exist)Get all root authorities by type.getAllRootAuthoritiesInZone(String zoneName, AuthorityType type) Gets the names of all root authorities in a zone, optionally filtered by type.Get the authorities for the current userorg.alfresco.query.PagingResults<String>getAuthorities(AuthorityType type, String zoneName, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, org.alfresco.query.PagingRequest pagingRequest) Get authorities by type and/or zonegetAuthoritiesForUser(String currentUserName) Get the authorities for the given userorg.alfresco.query.PagingResults<AuthorityInfo>getAuthoritiesInfo(AuthorityType type, String zoneName, String displayNameFilter, String sortBy, boolean sortAscending, org.alfresco.query.PagingRequest pagingRequest) Get authorities by type and/or zoneGet the display name for the given authority.Get the display name and description for the given authority.getAuthorityNodeRef(String name) Gets the authority node for the specified namegetAuthorityZones(String name) Gets the name of the zone containing the specified authority.getContainedAuthorities(AuthorityType type, String name, boolean immediate) Get all the authorities that are contained by the given authority.getContainingAuthorities(AuthorityType type, String name, boolean immediate) Get the authorities that contain the given authority, but usegetAuthoritiesForUser(userName).contains(authority)rather thangetContainingAuthorities(type, userName, false).contains(authority)or useAuthorityService.getContainingAuthoritiesInZone(AuthorityType, String, String, AuthorityFilter, int)as they will be much faster.getContainingAuthoritiesInZone(AuthorityType type, String authority, String zoneName, AuthorityService.AuthorityFilter filter, int size) Get a set of authorities with varying filter criteriaGet the name of the default zone.getName(AuthorityType type, String shortName) Create the full identifier for an authority given its short name and type.getOrCreateZone(String zoneName) Gets or creates an authority zone node with the specified namegetShortName(String name) Extract the short name of an authority from its full identifier.Gets an authority zone node with the specified namebooleanCheck of the current user has admin authority.booleanCheck of the current user has guest authority.booleanCheck the current user has system administration authority.voidinit()booleanisAdminAuthority(String authorityName) Does the given authority have admin authority.booleanisGuestAuthority(String authorityName) Does the given authority have guest authority.voidremoveAuthority(String parentName, String childName) Remove an authority as a member of another authority.voidremoveAuthorityFromZones(String authorityName, Set<String> zones) Remove a zone from an authorityvoidsetAdminGroups(Set<String> adminGroups) voidsetAuthenticationService(AuthenticationService authenticationService) voidsetAuthorityDAO(AuthorityDAO authorityDAO) voidsetAuthorityDisplayName(String authorityName, String authorityDisplayName) Set the display name for the given authority.voidsetAuthorityDisplayNameAndDescription(String authorityName, String authorityDisplayName, String description) Set the display name and description for the given authority.voidsetGuestGroups(Set<String> guestGroups) voidsetPermissionServiceSPI(PermissionServiceSPI permissionServiceSPI) voidsetPersonService(PersonService personService) voidsetPolicyComponent(PolicyComponent policyComponent) voidsetTenantService(TenantService tenantService) voidsetUserNameMatcher(UserNameMatcher userNameMatcher)
-
Field Details
-
GROUP_ALFRESCO_SYSTEM_ADMINISTRATORS_AUTHORITY
- See Also:
-
-
Constructor Details
-
AuthorityServiceImpl
public AuthorityServiceImpl()
-
-
Method Details
-
setTenantService
-
setPersonService
-
setAuthorityDAO
-
setUserNameMatcher
-
setAuthenticationService
-
setPermissionServiceSPI
-
setAdminGroups
-
setGuestGroups
-
setPolicyComponent
-
init
public void init() -
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
hasAdminAuthority
public boolean hasAdminAuthority()Check of the current user has admin authority. There is no contract for who should have this authority, only that it can be tested here. It could be determined by group membership, role, authentication mechanism, ...- Specified by:
hasAdminAuthorityin interfaceAuthorityService- Returns:
- true if the currently authenticated user has the admin authority
-
isAdminAuthority
Does the given authority have admin authority.- Specified by:
isAdminAuthorityin interfaceAuthorityService- Parameters:
authorityName- The name of the authority.- Returns:
- Whether the authority is an 'administrator'.
-
hasGuestAuthority
public boolean hasGuestAuthority()Check of the current user has guest authority. There is no contract for who should have this authority, only that it can be tested here. It could be determined by group membership, role, authentication mechanism, ...- Specified by:
hasGuestAuthorityin interfaceAuthorityService- Returns:
- true if the currently authenticated user has the guest authority
-
isGuestAuthority
Does the given authority have guest authority.- Specified by:
isGuestAuthorityin interfaceAuthorityService- Parameters:
authorityName- The name of the authority.- Returns:
- Whether the authority is a 'guest'.
-
countUsers
public long countUsers()Description copied from interface:AuthorityServiceCount the number of groups- Specified by:
countUsersin interfaceAuthorityService- Returns:
- Returns the number of groups
-
countGroups
public long countGroups()Description copied from interface:AuthorityServiceCount the number of users (not groups)- Specified by:
countGroupsin interfaceAuthorityService- Returns:
- Returns the number of usrs
-
getAuthorities
Get the authorities for the current user- Specified by:
getAuthoritiesin interfaceAuthorityService- Returns:
- authorities for the current user
-
getAuthoritiesForUser
Get the authorities for the given user- Specified by:
getAuthoritiesForUserin interfaceAuthorityService
-
getAllAuthorities
Get all authorities by type See also "getAuthorities" (paged) alternative- Specified by:
getAllAuthoritiesin interfaceAuthorityService- Parameters:
type- the type of authorities - cannot be null- Returns:
- all authorities by type
- See Also:
-
getAuthoritiesInfo
public org.alfresco.query.PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType type, String zoneName, String displayNameFilter, String sortBy, boolean sortAscending, org.alfresco.query.PagingRequest pagingRequest) Get authorities by type and/or zone- Specified by:
getAuthoritiesInfoin interfaceAuthorityService- Parameters:
type- the type of authorities (note: mandatory if zoneName is null)zoneName- the zoneName (note: mandatory if type is null)displayNameFilter- optional filter (startsWith / ignoreCase) for authority display name (note: implied trailing "*")sortBy- either "displayName", "shortName", "authorityName" or null if no sorting. note: for users, displayName/shortName is equivalent to the userName, for groups if the display is null then use the short namesortAscending- if true then sort ascending else sort descending (ignore if sortByDisplayName is false)pagingRequest- the requested page (skipCount, maxItems, queryExectionId)
-
getAuthorities
public org.alfresco.query.PagingResults<String> getAuthorities(AuthorityType type, String zoneName, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, org.alfresco.query.PagingRequest pagingRequest) Get authorities by type and/or zone- Specified by:
getAuthoritiesin interfaceAuthorityService- Parameters:
type- the type of authorities (note: mandatory if zoneName is null)zoneName- the zoneName (note: mandatory if type is null)displayNameFilter- optional filter (startsWith / ignoreCase) for authority display name (note: implied trailing "*")sortByDisplayName- if true then sort (ignoring case) by the authority display name, if false then unsorted note: for users, displayName/shortName is equivalent to the userName, for groups if the display is null then use the short namesortAscending- if true then sort ascending else sort descending (ignore if sortByDisplayName is false)pagingRequest- the requested page (skipCount, maxItems, queryExectionId)
-
addAuthority
Set an authority to include another authority. For example, adding a group to a group or adding a user to a group.- Specified by:
addAuthorityin interfaceAuthorityService- Parameters:
parentName- - the full name string identifier for the parent.childName- - the string identifier for the child.
-
addAuthority
Set a given child authority to be included by the given parent authorities. For example, adding a group to groups or adding a user to groups.- Specified by:
addAuthorityin interfaceAuthorityService- Parameters:
parentNames- - the full name string identifier for the parents.childName- - the string identifier for the child.
-
createAuthority
Create an authority.- Specified by:
createAuthorityin interfaceAuthorityService- Parameters:
type- - the type of the authorityshortName- - the short name of the authority to create this will also be set as the default display name for the authority- Returns:
- the name of the authority (this will be the prefix, if any associated with the type appended with the short name)
-
createAuthority
public String createAuthority(AuthorityType type, String shortName, Map<QName, Serializable> properties) Create an authority with properties.- Specified by:
createAuthorityin interfaceAuthorityService- Parameters:
type- - the type of the authorityshortName- - the short name of the authority to create this will also be set as the default display name for the authorityproperties- - properties that will be added to authority- Returns:
- the name of the authority (this will be the prefix, if any associated with the type appended with the short name)
-
deleteAuthority
Delete an authority and all its relationships. Note child authorities are not deleted.- Specified by:
deleteAuthorityin interfaceAuthorityService- Parameters:
name- String
-
deleteAuthority
Delete an authority and all its relationships, optionally recursively deleting child authorities of the same type.- Specified by:
deleteAuthorityin interfaceAuthorityService- Parameters:
name- the authority long namecascade- should the delete be cascaded to child authorities of the same type?
-
getAllRootAuthorities
Get all root authorities by type. Root authorities are ones that were created without an authority as the parent authority;- Specified by:
getAllRootAuthoritiesin interfaceAuthorityService- Parameters:
type- - the type of the authority- Returns:
- all root authorities by type.
-
getContainedAuthorities
Get all the authorities that are contained by the given authority. For a group you could get all the authorities it contains, just the users it contains or just the other groups it includes.- Specified by:
getContainedAuthoritiesin interfaceAuthorityService- Parameters:
type- - if not null, limit to the type of authority specifiedname- - the name of the containing authorityimmediate- - if true, limit the depth to just immediate child, if false find authorities at any depth
-
getContainingAuthorities
Get the authorities that contain the given authority, but usegetAuthoritiesForUser(userName).contains(authority)rather thangetContainingAuthorities(type, userName, false).contains(authority)or useAuthorityService.getContainingAuthoritiesInZone(AuthorityType, String, String, AuthorityFilter, int)as they will be much faster. For example, this method can be used find out all the authorities that contain a group.- Specified by:
getContainingAuthoritiesin interfaceAuthorityService- Parameters:
type- - if not null, limit to the type of authority specifiedname- - the name of the authority for which the containing authorities are required.immediate- - limit to immediate parents or any ancestor.
-
getAuthorityNodeRef
Gets the authority node for the specified name- Specified by:
getAuthorityNodeRefin interfaceAuthorityService- Parameters:
name- The authority name- Returns:
- the reference to the authority node
-
getContainingAuthoritiesInZone
public Set<String> getContainingAuthoritiesInZone(AuthorityType type, String authority, String zoneName, AuthorityService.AuthorityFilter filter, int size) Get a set of authorities with varying filter criteria- Specified by:
getContainingAuthoritiesInZonein interfaceAuthorityService- Parameters:
type- authority type or null for all typesauthority- if non-null, only return those authorities who contain this authorityzoneName- if non-null, only include authorities in the named zonefilter- optional callback to apply further filter criteria or nullsize- if greater than zero, the maximum results to return. The search strategy used is varied depending on this number.- Returns:
- a set of authorities
-
removeAuthority
Description copied from interface:AuthorityServiceRemove an authority as a member of another authority. The child authority will still exist. If the child authority was not created as a root authority and you remove its creation link, it will be moved to a root authority. If you want rid of it, use delete.- Specified by:
removeAuthorityin interfaceAuthorityService- Parameters:
parentName- - the string identifier for the parent.childName- - the string identifier for the child.
-
authorityExists
Check if an authority exists.- Specified by:
authorityExistsin interfaceAuthorityService- Parameters:
name- (the long name).- Returns:
- true, the authority exists.
-
createAuthority
public String createAuthority(AuthorityType type, String shortName, String authorityDisplayName, Set<String> authorityZones) Create an authority with a display name and zone.- Specified by:
createAuthorityin interfaceAuthorityService- Parameters:
type- the type of the authorityshortName- the short name of the authority to createauthorityDisplayName- the display name for the authorityauthorityZones- identifier for external user registry owning the authority ornullif not applicable- Returns:
- the full name of the authority (this will be the prefix, if any associated with the type appended with the short name)
-
createAuthority
public String createAuthority(AuthorityType type, String shortName, String authorityDisplayName, Set<String> authorityZones, Map<QName, Serializable> properties) Create an authority with a display name and zone.- Specified by:
createAuthorityin interfaceAuthorityService- Parameters:
type- the type of the authorityshortName- the short name of the authority to createauthorityDisplayName- the display name for the authorityauthorityZones- identifier for external user registry owning the authority ornullif not applicableproperties- - properties that will be added to authority- Returns:
- the full name of the authority (this will be the prefix, if any associated with the type appended with the short name)
-
getAuthorityDisplayName
Get the display name for the given authority.- Specified by:
getAuthorityDisplayNamein interfaceAuthorityService- Parameters:
name- - the full authority string including any prefix (e.g. GROUP_woof)- Returns:
- - the display name
-
setAuthorityDisplayName
Set the display name for the given authority. Setting the display name is only supported for authorities of type group- Specified by:
setAuthorityDisplayNamein interfaceAuthorityService- Parameters:
authorityName- StringauthorityDisplayName- String
-
getAuthorityDisplayNameAndDescription
Get the display name and description for the given authority.- Specified by:
getAuthorityDisplayNameAndDescriptionin interfaceAuthorityService- Parameters:
name- - the full authority string including any prefix (e.g. GROUP_woof)- Returns:
- - pair containing display name and description
-
setAuthorityDisplayNameAndDescription
public void setAuthorityDisplayNameAndDescription(String authorityName, String authorityDisplayName, String description) Set the display name and description for the given authority. Setting the display name is only supported for authorities of type group- Specified by:
setAuthorityDisplayNameAndDescriptionin interfaceAuthorityService- Parameters:
authorityName- StringauthorityDisplayName- Stringdescription- String
-
getAuthorityZones
Gets the name of the zone containing the specified authority.- Specified by:
getAuthorityZonesin interfaceAuthorityService- Parameters:
name- the authority long name- Returns:
- the the name of the zone containing the specified authority,
AuthorityService.ZONE_APP_DEFAULTif the authority exists but has no zone, ornullif the authority does not exist.
-
getOrCreateZone
Gets or creates an authority zone node with the specified name- Specified by:
getOrCreateZonein interfaceAuthorityService- Parameters:
zoneName- the zone name- Returns:
- reference to the zone node
-
getZone
Gets an authority zone node with the specified name- Specified by:
getZonein interfaceAuthorityService- Parameters:
zoneName- the zone name- Returns:
- reference to the zone node or null
-
getAllAuthoritiesInZone
Gets the names of all authorities in a zone, optionally filtered by type See also "getAuthorities" paged alternative (note: in that case, zone must exist)- Specified by:
getAllAuthoritiesInZonein interfaceAuthorityService- Parameters:
zoneName- the zone name - note: if zone does not exist then will currently return empty settype- the authority type to filter by ornullfor all authority types- Returns:
- the names of all authorities in a zone, optionally filtered by type
- See Also:
-
addAuthorityToZones
Add a zone to an authority.- Specified by:
addAuthorityToZonesin interfaceAuthorityService- Parameters:
authorityName- String
-
removeAuthorityFromZones
Remove a zone from an authority- Specified by:
removeAuthorityFromZonesin interfaceAuthorityService- Parameters:
authorityName- String
-
getDefaultZones
Get the name of the default zone.- Specified by:
getDefaultZonesin interfaceAuthorityService- Returns:
- the default zone
-
getAllRootAuthoritiesInZone
Gets the names of all root authorities in a zone, optionally filtered by type.- Specified by:
getAllRootAuthoritiesInZonein interfaceAuthorityService- Parameters:
zoneName- the zone nametype- the authority type to filter by ornullfor all authority types- Returns:
- the names of all root authorities in a zone, optionally filtered by type
-
findAuthorities
public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate, String displayNamePattern, String zoneName) Search for authorities by pattern matching (* and ?) against the authority name. Note: This will use a search index to find the results (eg. via Lucene / SOLR).- Specified by:
findAuthoritiesin interfaceAuthorityService- Parameters:
type- AuthorityTypeparentAuthority- if non-null, will look only for authorities who are a child of the named parentimmediate- iftruethen only search root groups if parentAuthority is null, or immediate children of parentAuthority if it is non-null.displayNamePattern- StringzoneName- - may be null to indicate all zones
-
getName
Create the full identifier for an authority given its short name and type.- Specified by:
getNamein interfaceAuthorityService- Parameters:
type- AuthorityTypeshortName- String- Returns:
- String
-
getShortName
Extract the short name of an authority from its full identifier.- Specified by:
getShortNamein interfaceAuthorityService- Parameters:
name- String- Returns:
- String
-
hasSysAdminAuthority
public boolean hasSysAdminAuthority()Description copied from interface:AuthorityServiceCheck the current user has system administration authority.- Specified by:
hasSysAdminAuthorityin interfaceAuthorityService- Returns:
- true if the currently authenticated user has the system administration authority, otherwise false
-