@Service(value="cuba_RolesService") public class RolesServiceBean extends java.lang.Object implements RolesService
Modifier and Type | Field and Description |
---|---|
protected DataManager |
dataManager |
protected EntityStates |
entityStates |
protected GlobalConfig |
globalConfig |
protected org.slf4j.Logger |
log |
protected Metadata |
metadata |
protected PersistenceSecurity |
persistenceSecurity |
protected PredefinedRoleDefinitionRepository |
predefinedRoleDefinitionRepository |
protected RolesHelper |
rolesHelper |
protected ServerConfig |
serverConfig |
NAME
Constructor and Description |
---|
RolesServiceBean() |
Modifier and Type | Method and Description |
---|---|
java.util.Collection<Role> |
getAllRoles()
Returns a collection of all roles (
Role objects) available in the application (SecurityStorageMode is taken into account). |
java.util.Collection<Role> |
getDefaultRoles()
Returns all roles marked as default (both from the database and from the source code).
|
java.util.Collection<Permission> |
getPermissions(java.lang.String predefinedRoleName,
PermissionType permissionType)
Finds a predefined role definition by the name and builds a collection of
Permission objects that has a
given permissionType . |
Access |
getPermissionUndefinedAccessPolicy()
Returns a policy for resolving permission values that are not explicitly defined in roles.
|
Role |
getRoleDefinitionAndTransformToRole(java.lang.String roleDefinitionName)
Finds the predefined role definition by the name and converts it to the
Role object. |
RoleDefinition |
getRoleDefinitionByName(java.lang.String name) |
java.util.Collection<RoleDefinition> |
getRoleDefinitionsForUser(User user)
Returns a collection of
RoleDefinition objects assigned to the User . |
java.util.Collection<Role> |
getRolesForUser(User user)
Returns a collection of
Role objects assigned to the User . |
int |
getRolesPolicyVersion()
Returns the roles policy version.
|
boolean |
isRoleStorageMixedMode() |
Role |
transformToRole(RoleDefinition roleDefinition,
RoleTransformationOption... transformationOptions)
Transforms the given
roleDefinition to the Role object. |
@Inject protected DataManager dataManager
@Inject protected GlobalConfig globalConfig
@Inject protected PersistenceSecurity persistenceSecurity
@Inject protected org.slf4j.Logger log
@Inject protected ServerConfig serverConfig
@Inject protected PredefinedRoleDefinitionRepository predefinedRoleDefinitionRepository
@Inject protected Metadata metadata
@Inject protected RolesHelper rolesHelper
@Inject protected EntityStates entityStates
public java.util.Collection<Role> getAllRoles()
RolesService
Role
objects) available in the application (SecurityStorageMode
is taken into account). If there are predefined roles (RoleDefinition
objects in the
source code), they will be converted to Role
and will also be returned in the result collection. The
resulting roles permissions collections are not filled.getAllRoles
in interface RolesService
Role
objects) available in the application.@Nullable public RoleDefinition getRoleDefinitionByName(java.lang.String name)
getRoleDefinitionByName
in interface RolesService
public Role getRoleDefinitionAndTransformToRole(java.lang.String roleDefinitionName)
RolesService
Role
object.getRoleDefinitionAndTransformToRole
in interface RolesService
roleDefinitionName
- name of a predefined roleRole
object that contains all permissions of a predefined role or null if role definition is not
found.public boolean isRoleStorageMixedMode()
isRoleStorageMixedMode
in interface RolesService
true
if roles are stored in a source code and in a database, false
otherwise. See SecurityStorageMode
public java.util.Collection<Role> getDefaultRoles()
RolesService
getDefaultRoles
in interface RolesService
public Role transformToRole(RoleDefinition roleDefinition, RoleTransformationOption... transformationOptions)
RolesService
roleDefinition
to the Role
object. By default, all permissions will also be
transformed, if you don't need them in the resulting role, use the RoleTransformationOption.DO_NOT_INCLUDE_PERMISSIONS
option.transformToRole
in interface RolesService
public java.util.Collection<Permission> getPermissions(java.lang.String predefinedRoleName, PermissionType permissionType)
RolesService
Permission
objects that has a
given permissionType
.getPermissions
in interface RolesService
predefinedRoleName
- name of a predefined rolepermissionType
- type of permissions that should be returnedPermission
objects or an empty collection if the predefined role doesn't existpublic java.util.Collection<Role> getRolesForUser(User user)
RolesService
Role
objects assigned to the User
. If the user role is associated with a
predefined role definition, the predefined role will be converted to the Role
getRolesForUser
in interface RolesService
Role
objectspublic java.util.Collection<RoleDefinition> getRoleDefinitionsForUser(User user)
RolesService
RoleDefinition
objects assigned to the User
. If the user role is
associated with the database role, the database role will be converted to the RoleDefinition
getRoleDefinitionsForUser
in interface RolesService
RoleDefinition
objectspublic Access getPermissionUndefinedAccessPolicy()
RolesService
RolesService.getRolesPolicyVersion()
if a role doesn't define any explicit permission then this target is allowed,
for policy v2 the undefined permission is denied.getPermissionUndefinedAccessPolicy
in interface RolesService
public int getRolesPolicyVersion()
RolesService
getRolesPolicyVersion
in interface RolesService