Class RbacGeneratorUtils
java.lang.Object
com.evolveum.midpoint.ninja.action.mining.generator.context.RbacGeneratorUtils
Utility methods for generating rbac data.
Part of RBAC Testing Data, which provides testing data for role mining and other RBAC-related processes.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static @NotNull AssignmentType
createOrgAssignment
(@NotNull String oid) Creates an assignment of type OrgType with the provided OID.protected static @NotNull AssignmentType
createRoleAssignment
(@NotNull String oid) Creates an assignment of type RoleType with the provided OID.static @Nullable RoleType
getAdditionNoiseRole
(int chance) Retrieves an additional noise role based on a given chance.protected static @NotNull List<PrismObject<RoleType>>
getBusinessRolesOidAssignment
(@NotNull AssignmentHolderType object, @NotNull com.evolveum.midpoint.repo.api.RepositoryService repository, @NotNull OperationResult result) Retrieves a list of PrismObjects representing business RoleType assignments for the specified AssignmentHolderType.static @Nullable InitialObjectsDefinition.AuxInitialBusinessRole
getRandomAuxWithChance
(InitialObjectsDefinition.AuxInitialBusinessRole auxRole, int chance) Retrieves aux role with a chance specified chance.protected static InitialObjectsDefinition.JobInitialBusinessRole
Retrieves a randomly selected job business role.protected static InitialObjectsDefinition.LocationInitialBusinessRole
Retrieves a randomly selected location business role.static @NotNull String
Retrieves a randomly selected job title from the provided list, excluding an empty string.static @NotNull String
Retrieves a randomly selected job title from the provided list, including an empty string.protected static InitialObjectsDefinition.PlanktonApplicationBusinessAbstractRole
Retrieves a randomly selected plankton abstract role.protected static @NotNull List<InitialObjectsDefinition.PlanktonApplicationBusinessAbstractRole>
getRandomPlanktonRoles
(int minRoles, GeneratorOptions generatorOptions) Retrieves a list of randomly selected plankton abstract roles.static boolean
isForgetRole
(int chance) Determines whether a role should be forgotten based on a given chance.loadNamesFromCSV
(@NotNull String csvPath) Loads names from a CSV file located at the specified path.static void
setUpArchetypeUser
(@NotNull UserType user, @NotNull String archetypeOid) Creates an assignment of type ArchetypeType with the provided OID.
-
Constructor Details
-
RbacGeneratorUtils
public RbacGeneratorUtils()
-
-
Method Details
-
getRandomLocationBusinessRole
@NotNull protected static InitialObjectsDefinition.LocationInitialBusinessRole getRandomLocationBusinessRole()Retrieves a randomly selected location business role.- Returns:
- The randomly selected location business role.
-
getRandomJobBusinessRole
@NotNull protected static InitialObjectsDefinition.JobInitialBusinessRole getRandomJobBusinessRole()Retrieves a randomly selected job business role.- Returns:
- The randomly selected job business role.
-
getRandomPlanktonRole
@NotNull protected static InitialObjectsDefinition.PlanktonApplicationBusinessAbstractRole getRandomPlanktonRole()Retrieves a randomly selected plankton abstract role.- Returns:
- The randomly selected plankton abstract role.
-
getRandomPlanktonRoles
@NotNull protected static @NotNull List<InitialObjectsDefinition.PlanktonApplicationBusinessAbstractRole> getRandomPlanktonRoles(int minRoles, GeneratorOptions generatorOptions) Retrieves a list of randomly selected plankton abstract roles.- Parameters:
minRoles
- The minimum number of roles to select.generatorOptions
- The generator options to consider.- Returns:
- A list of randomly selected plankton abstract roles.
-
getRandomlyJobTitlesWithNone
Retrieves a randomly selected job title from the provided list, including an empty string.- Returns:
- The randomly selected job title.
-
getRandomlyJobTitles
Retrieves a randomly selected job title from the provided list, excluding an empty string.- Returns:
- The randomly selected job title.
-
createOrgAssignment
Creates an assignment of type OrgType with the provided OID.- Parameters:
oid
- The OID of the organization.- Returns:
- The created assignment.
-
createRoleAssignment
@NotNull protected static @NotNull AssignmentType createRoleAssignment(@NotNull @NotNull String oid) Creates an assignment of type RoleType with the provided OID.- Parameters:
oid
- The OID of the role object.- Returns:
- The created assignment.
-
setUpArchetypeUser
public static void setUpArchetypeUser(@NotNull @NotNull UserType user, @NotNull @NotNull String archetypeOid) Creates an assignment of type ArchetypeType with the provided OID.- Parameters:
user
- The user for which to create the assignment.archetypeOid
- The OID of the archetype object.
-
getBusinessRolesOidAssignment
@NotNull protected static @NotNull List<PrismObject<RoleType>> getBusinessRolesOidAssignment(@NotNull @NotNull AssignmentHolderType object, @NotNull @NotNull com.evolveum.midpoint.repo.api.RepositoryService repository, @NotNull @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException Retrieves a list of PrismObjects representing business RoleType assignments for the specified AssignmentHolderType.- Parameters:
object
- The AssignmentHolderType for which to retrieve business role assignments.repository
- The RepositoryService used to retrieve objects from the repository.result
- The OperationResult to track the operation's result.- Returns:
- A list of PrismObjects representing the business RoleType assignments.
- Throws:
SchemaException
- If an error related to schema occurs.ObjectNotFoundException
- If an object cannot be found in the repository.
-
loadNamesFromCSV
@NotNull protected static @NotNull Set<String> loadNamesFromCSV(@NotNull @NotNull String csvPath) throws IOException Loads names from a CSV file located at the specified path.NOTE: names are expected to be in the column with the specified header at "name" value.
- Parameters:
csvPath
- The path to the CSV file.- Returns:
- A set containing the loaded names.
- Throws:
IOException
- If an I/O error occurs while reading the CSV file.
-
getRandomAuxWithChance
public static @Nullable InitialObjectsDefinition.AuxInitialBusinessRole getRandomAuxWithChance(@NotNull InitialObjectsDefinition.AuxInitialBusinessRole auxRole, int chance) Retrieves aux role with a chance specified chance.- Parameters:
auxRole
- The business role to consider.chance
- The chance of the role being returned.- Returns:
- The randomly selected location business role.
-
isForgetRole
public static boolean isForgetRole(int chance) Determines whether a role should be forgotten based on a given chance. The chance is a percentage value between 0 and 100. A random number between 0 and 100 is generated and if it's less than the given chance, the method returns true.- Parameters:
chance
- The chance (percentage) of forgetting a role.- Returns:
- True if the role should be forgotten, false otherwise.
-
getAdditionNoiseRole
Retrieves an additional noise role based on a given chance. The chance is a percentage value between 0 and 100. A random number between 0 and 100 is generated and if it's less than the given chance, a noise role is selected randomly from the list of noise roles. If the chance condition is not met or there are no noise roles, the method returns null.- Parameters:
chance
- The chance (percentage) of getting an additional noise role.- Returns:
- A RoleType object representing the additional noise role, or null if no role is selected.
-