Interface ApplicationRoleManager
- All Known Implementing Classes:
DefaultApplicationRoleManager
,MockApplicationRoleManager
ApplicationRole
s. It is generally recommended to use
ApplicationAuthorizationService
or ApplicationRoleAdminService
rather than this class, as the service
layer contains additional validation and business logic.- Since:
- 7.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionSet<com.atlassian.application.api.ApplicationKey>
Returns an immutableSet
ofApplicationKey
s that are configured as the default applications for new users.Set<com.atlassian.crowd.embedded.api.Group>
getDefaultGroups
(com.atlassian.application.api.ApplicationKey key) Get the defaultGroup
s associated with theApplicationRole
backed by a (potentially exceeded) license.Set<com.atlassian.crowd.embedded.api.Group>
Get theSet
of group names that have been associated with all theApplicationRole
s that have a backing (but potentially exceeded) license.int
getRemainingSeats
(com.atlassian.application.api.ApplicationKey key) Retrieve the number of available (unoccupied) user seats for theApplicationRole
backed by a (potentially exceeded) license.int
getRemainingSeatsAsync
(com.atlassian.application.api.ApplicationKey key) Async version ofgetRemainingSeats(ApplicationKey)
.io.atlassian.fugue.Option<ApplicationRole>
getRole
(com.atlassian.application.api.ApplicationKey key) Returns theApplicationRole
identified by the givenApplicationKey
, orOption.none()
if no suchApplicationRole
exists.getRoles()
Returns an immutableSet
of allApplicationRole
s that are backed by a (potentially exceeded) license.getRolesForGroup
(com.atlassian.crowd.embedded.api.Group group) Returns theSet
ofApplicationRole
s associated with the givenGroup
, or groups for which the given group is a nested group (sub-group).int
getUserCount
(com.atlassian.application.api.ApplicationKey key) Retrieve the number of active users for the givenApplicationRole
.int
getUserCountAsync
(com.atlassian.application.api.ApplicationKey key) Async version ofgetUserCount(ApplicationKey)
.boolean
hasAnyRole
(ApplicationUser user) Returns true if the given user has been assigned to anyApplicationRole
that is backed by a (potentially exceeded) license.boolean
Returns true if the user limits of all of the given user's assignedApplicationRole
s have been exceeded.boolean
Async version ofhasExceededAllRoles(ApplicationUser)
.boolean
hasSeatsAvailable
(com.atlassian.application.api.ApplicationKey key, int seatCount) Determines whether theApplicationRole
backed by a license has the requested number of user seats available.boolean
hasSeatsAvailableAsync
(com.atlassian.application.api.ApplicationKey key, int seatCount) Async version ofhasSeatsAvailable(ApplicationKey, int)
.boolean
Returns true if the number of users assigned to anyApplicationRole
exceeds the number of seats granted to that role by its license.boolean
Async version ofisAnyRoleLimitExceeded()
.boolean
isRoleInstalledAndLicensed
(com.atlassian.application.api.ApplicationKey key) Determines whether an application identified by the givenApplicationKey
is installed and running in this JIRA instance AND has a backing license key.boolean
isRoleLimitExceeded
(com.atlassian.application.api.ApplicationKey role) Returnstrue
if the number of users assigned to the givenApplicationRole
exceeds the number of seats granted by its license.boolean
isRoleLimitExceededAsync
(com.atlassian.application.api.ApplicationKey role) Async version ofisRoleLimitExceeded(ApplicationKey)
.void
removeGroupFromRoles
(com.atlassian.crowd.embedded.api.Group group) Removes any/all associations of the given group from allApplicationRole
s (irrespective of whether theApplicationRole
s is backed by a license).default boolean
Deprecated.since 7.0.1 as this always returns true in JIRA 7setRole
(ApplicationRole role) Save the passedApplicationRole
information to the database.boolean
userHasRole
(ApplicationUser user, com.atlassian.application.api.ApplicationKey key) Returnstrue
if the passed user belongs to theApplicationRole
associated with the given key.boolean
userOccupiesRole
(ApplicationUser user, com.atlassian.application.api.ApplicationKey key) Returnstrue
if the passed user occupies a seat in theApplicationRole
associated with the given key.
-
Method Details
-
getRole
@Nonnull io.atlassian.fugue.Option<ApplicationRole> getRole(@Nonnull com.atlassian.application.api.ApplicationKey key) Returns theApplicationRole
identified by the givenApplicationKey
, orOption.none()
if no suchApplicationRole
exists.Note:
ApplicationRole
s returned by this method are guaranteed to be backed by a (potentially exceeded) license, however the installation state of the plugin/product that uses this role may not necessarily physically installed.- Parameters:
key
- theApplicationKey
of the role to search for.- Returns:
- the
ApplicationRole
associated with the passed role identifier, orOption.none()
.
-
getRoles
Returns an immutableSet
of allApplicationRole
s that are backed by a (potentially exceeded) license.- Returns:
- the
Set
of allApplicationRole
s that are backed by a (potentially exceeded) license.
-
getDefaultApplicationKeys
Returns an immutableSet
ofApplicationKey
s that are configured as the default applications for new users.- Returns:
- the
Set
ofApplicationKey
s that are configured as the default applications for new users.
-
hasAnyRole
Returns true if the given user has been assigned to anyApplicationRole
that is backed by a (potentially exceeded) license.- Returns:
- true if the given user has been assigned to any
ApplicationRole
that is backed by a (potentially exceeded) license.
-
userHasRole
boolean userHasRole(@Nullable ApplicationUser user, com.atlassian.application.api.ApplicationKey key) Returnstrue
if the passed user belongs to theApplicationRole
associated with the given key. NOTE: This does not check that the application is licensed with a valid license.- Parameters:
user
- the user to check - if this is null, returnsfalse
key
- the key corresponding to theApplicationRole
- Returns:
- true if the user belongs to a group of the given application
-
userOccupiesRole
boolean userOccupiesRole(@Nullable ApplicationUser user, com.atlassian.application.api.ApplicationKey key) Returnstrue
if the passed user occupies a seat in theApplicationRole
associated with the given key.- Parameters:
user
- the user to check - if this is null, returnsfalse
key
- the key corresponding to theApplicationRole
- Returns:
- true if the user occupies seat in the given application
-
hasExceededAllRoles
Returns true if the user limits of all of the given user's assignedApplicationRole
s have been exceeded. The user limit of anApplicationRole
is exceeded when the combined number of users assigned to that role (through assigned groups) exceeds the number of seats granted for that role in its license.Note: this method does NOT take into account whether licenses for application roles are
The method is known to be slow in some circumstances, and to block Jira instance. It's strongly recommended to useexpired
; this must be tested separately.hasExceededAllRolesAsync(ApplicationUser)
async version of the method}- Parameters:
user
- the user whose roles will be checked.- Returns:
true
if all of theuser
's roles have user counts that exceed the number of seats granted by licenses.
-
hasExceededAllRolesAsync
Async version ofhasExceededAllRoles(ApplicationUser)
. The method returns the last know value without waiting for the current changes to be propagated. This implementation is safer and offers a better performance. Returns true if the user limits of all of the given user's assignedApplicationRole
s have been exceeded. The user limit of anApplicationRole
is exceeded when the combined number of users assigned to that role (through assigned groups) exceeds the number of seats granted for that role in its license.Note: this method does NOT take into account whether licenses for application roles are
expired
; this must be tested separately.- Parameters:
user
- the user whose roles will be checked.- Returns:
true
if all of theuser
's roles have user counts that exceed the number of seats granted by licenses.
-
isAnyRoleLimitExceeded
boolean isAnyRoleLimitExceeded()Returns true if the number of users assigned to anyApplicationRole
exceeds the number of seats granted to that role by its license.The method is known to be slow in some circumstances, and to block Jira instance. It's strongly recommended to use
isAnyRoleLimitExceededAsync()
async version of the method} Note: this method does NOT take into account whether licenses for installed roles areexpired
; this must be tested separately.- Returns:
- true if the number of users for any role is greater than the number of seats granted to that role by its license.
-
isAnyRoleLimitExceededAsync
boolean isAnyRoleLimitExceededAsync()Async version ofisAnyRoleLimitExceeded()
. The method returns the last know value without waiting for the current changes to be propagated. This implementation is safer and offers a better performance. Returns true if the number of users assigned to anyApplicationRole
exceeds the number of seats granted to that role by its license.Note: this method does NOT take into account whether licenses for installed roles are
expired
; this must be tested separately.- Returns:
- true if the number of users for any role is greater than the number of seats granted to that role by its license.
-
isRoleLimitExceeded
boolean isRoleLimitExceeded(@Nonnull com.atlassian.application.api.ApplicationKey role) Returnstrue
if the number of users assigned to the givenApplicationRole
exceeds the number of seats granted by its license. This method unconditionally returnsfalse
if the passed role is not considered to be installed (ie: backed by a license).Note: this method does NOT take into account whether licenses for installed roles are
The method is known to be slow in some circumstances, and to block Jira instance. It's strongly recommended to useexpired
; this must be tested separately.async version of the method
- Parameters:
role
- the identifier of theApplicationRole
.- Returns:
true
if the installedApplicationRole
is exceeded orfalse
otherwise.
-
isRoleLimitExceededAsync
boolean isRoleLimitExceededAsync(@Nonnull com.atlassian.application.api.ApplicationKey role) Async version ofisRoleLimitExceeded(ApplicationKey)
. The method returns the last know value without waiting for the current changes to be propagated. This implementation is safer and offers a better performance. Returnstrue
if the number of users assigned to the givenApplicationRole
exceeds the number of seats granted by its license. This method unconditionally returnsfalse
if the passed role is not considered to be installed (ie: backed by a license).Note: this method does NOT take into account whether licenses for installed roles are
expired
; this must be tested separately.- Parameters:
role
- the identifier of theApplicationRole
.- Returns:
true
if the installedApplicationRole
is exceeded orfalse
otherwise.
-
getRolesForUser
- Parameters:
user
- the user whose roles will be checked.- Returns:
- the
Set
ofApplicationRole
s for the givenuser
.
-
getOccupiedLicenseRolesForUser
Returns theSet
ofApplicationRole
s that the givenApplicationUser
occupies seats in.ApplicationUser
has to actively take a seat in the returnedApplicationRole
s eg. for anApplicationUser
who has access to SOFTWARE and implicitly (or explicitly) CORE, they will only have SOFTWARE returned. For anApplicationUser
who has explicit access to SOFTWARE and CORE - with the SOFTWARE license exceeded, this will return both as the user effectively occupies a seat in both CORE and SOFTWARE now.- Parameters:
user
- the user whose roles will be checked.- Returns:
- the
Set
ofApplicationRole
s that the givenuser
is actively taking seats.
-
getRolesForGroup
Returns theSet
ofApplicationRole
s associated with the givenGroup
, or groups for which the given group is a nested group (sub-group).- Parameters:
group
- the group which roles will be checked.- Returns:
- the
Set
ofApplicationRole
s associated with the group or its super-groups.
-
getGroupsForLicensedRoles
Get theSet
of group names that have been associated with all theApplicationRole
s that have a backing (but potentially exceeded) license.- Returns:
- Groups associated with all the
ApplicationRole
s that have a backing (but potentially exceeded) license.
-
removeGroupFromRoles
void removeGroupFromRoles(@Nonnull com.atlassian.crowd.embedded.api.Group group) Removes any/all associations of the given group from allApplicationRole
s (irrespective of whether theApplicationRole
s is backed by a license).- Parameters:
group
- the group to remove.
-
isRoleInstalledAndLicensed
boolean isRoleInstalledAndLicensed(@Nonnull com.atlassian.application.api.ApplicationKey key) Determines whether an application identified by the given
ApplicationKey
is installed and running in this JIRA instance AND has a backing license key.- Parameters:
key
- the key that identifies theApplicationRole
backed by a (potentially exceeded) license.- Returns:
true
when theApplicationRole
backed by a (potentially exceeded) license has an associated application installed and running in this JIRA instance.
-
setRole
Save the passedApplicationRole
information to the database. This method will only accept the passed role if:- The role is backed by a (potentially exceeded) license.
- The role only contains currently valid groups.
- The default group are not a subset of the groups in the role.
- Parameters:
role
- the role to save.- Returns:
- the role as persisted to the database.
- Throws:
IllegalArgumentException
- if passed role does not contain valid groups, valid default groups or if the role does not have a backing license.
-
getUserCount
int getUserCount(@Nonnull com.atlassian.application.api.ApplicationKey key) Retrieve the number of active users for the givenApplicationRole
. It will uniquely count all users who are found in the groups associated with the application. The method is known to be slow in some circumstances, and to block Jira instance. It's strongly recommended to usegetUserCountAsync(ApplicationKey)
async version of the method}- Parameters:
key
- the key that identifies theApplicationRole
.- Returns:
- the number of active users for the given
ApplicationRole
, or zero if theApplicationRole
does not exist.
-
getUserCountAsync
int getUserCountAsync(@Nonnull com.atlassian.application.api.ApplicationKey key) Async version ofgetUserCount(ApplicationKey)
. The method returns the last know value without waiting for the current changes to be propagated. This implementation is safer and offers a better performance. Retrieve the number of active users for the givenApplicationRole
. It will uniquely count all users who are found in the groups associated with the application.- Parameters:
key
- the key that identifies theApplicationRole
.- Returns:
- the number of active users for the given
ApplicationRole
, or zero if theApplicationRole
does not exist.
-
getRemainingSeats
int getRemainingSeats(@Nonnull com.atlassian.application.api.ApplicationKey key) Retrieve the number of available (unoccupied) user seats for theApplicationRole
backed by a (potentially exceeded) license. The method is known to be slow in some circumstances, and to block Jira instance. It's strongly recommended to usegetRemainingSeatsAsync(ApplicationKey)
async version of the method}- Parameters:
key
- the key that identifies the licensedApplicationRole
.- Returns:
- the number of remaining users seats. Will return zero when there are more users than seats licensed, the
ApplicationRole
is not valid or there are as many active users as seats in the license. When the license is unlimited, it will return minus one (-1) - See Also:
-
getRemainingSeatsAsync
int getRemainingSeatsAsync(@Nonnull com.atlassian.application.api.ApplicationKey key) Async version ofgetRemainingSeats(ApplicationKey)
. The method returns the last know value without waiting for the current changes to be propagated. This implementation is safer and offers a better performance. Retrieve the number of available (unoccupied) user seats for theApplicationRole
backed by a (potentially exceeded) license.- Parameters:
key
- the key that identifies the licensedApplicationRole
.- Returns:
- the number of remaining users seats. Will return zero when there are more users than seats licensed, the
ApplicationRole
is not valid or there are as many active users as seats in the license. When the license is unlimited, it will return minus one (-1) - See Also:
-
hasSeatsAvailable
boolean hasSeatsAvailable(@Nonnull com.atlassian.application.api.ApplicationKey key, int seatCount) Determines whether theApplicationRole
backed by a license has the requested number of user seats available. The method is known to be slow in some circumstances, and to block Jira instance. It's strongly recommended to usehasSeatsAvailableAsync(ApplicationKey, int)
async version of the method}- Parameters:
key
- the key that identifies theApplicationRole
.seatCount
- the number of user seats that thisApplicationRole
should have capacity for.- Returns:
true
if theApplicationRole
for the providedApplicationKey
has the number of user seats available.false
if the there are not enough seats available.
-
hasSeatsAvailableAsync
boolean hasSeatsAvailableAsync(@Nonnull com.atlassian.application.api.ApplicationKey key, int seatCount) Async version ofhasSeatsAvailable(ApplicationKey, int)
. The method returns the last know value without waiting for the current changes to be propagated. This implementation is safer and offers a better performance. Determines whether theApplicationRole
backed by a license has the requested number of user seats available.- Parameters:
key
- the key that identifies theApplicationRole
.seatCount
- the number of user seats that thisApplicationRole
should have capacity for.- Returns:
true
if theApplicationRole
for the providedApplicationKey
has the number of user seats available.false
if the there are not enough seats available.
-
getDefaultGroups
@Nonnull Set<com.atlassian.crowd.embedded.api.Group> getDefaultGroups(@Nonnull com.atlassian.application.api.ApplicationKey key) Get the defaultGroup
s associated with theApplicationRole
backed by a (potentially exceeded) license.- Parameters:
key
- the key that identifies theApplicationRole
.- Returns:
- the
Set
of default groups associated with theApplicationRole
.
-
rolesEnabled
Deprecated.since 7.0.1 as this always returns true in JIRA 7Determines whetherApplicationRole
s are enabled.- Returns:
true
whenApplicationRole
are enabled,false
otherwise.
-