Package org.trustdeck.utils
Class Utility
java.lang.Object
org.trustdeck.utils.Utility
This class offers a variety of utilities.
- Author:
- Armin Müller and Eric Wündisch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractGroupPaths(List<org.keycloak.representations.idm.GroupRepresentation> groupRepresentations, Boolean recursive) Extracts the paths of the specified groups into a single list.findGroupEntryByPath(Map<String, String> flatGroups, String path) Retrieves an entry from the group IDs-to-paths-mapping, which matches a specified path.flattenGroupIDToPathMapping(List<org.keycloak.representations.idm.GroupRepresentation> groupRepresentations, Boolean recursive) Flattens the group structures into a group IDs-to-group paths-mapping.static StringgenerateAlphabet(String algorithm, String alphabet) Method to generate the alphabet depending on the given algorithm.static OffsetDateTimeparseDateTimeString(String dateTime) Method to parse a string in an unknown date-time format into the OffsetDateTime format.static LongvalidityTimeToSeconds(String validityTime) This method processes the given String, computes the encoded time and returns it in seconds.
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
validityTimeToSeconds
This method processes the given String, computes the encoded time and returns it in seconds.- Parameters:
validityTime- the String containing the validity time- Returns:
- the computed validity time in seconds or
nullif something went wrong
-
extractGroupPaths
public static List<String> extractGroupPaths(List<org.keycloak.representations.idm.GroupRepresentation> groupRepresentations, Boolean recursive) Extracts the paths of the specified groups into a single list. Iterates through a list ofGroupRepresentationobjects, extracting the path of each group and adding it to a result list. If therecursiveparameter is set totrue, it recursively flattens the paths of all subgroups as well, adding their paths to the list. -
flattenGroupIDToPathMapping
public static Map<String,String> flattenGroupIDToPathMapping(List<org.keycloak.representations.idm.GroupRepresentation> groupRepresentations, Boolean recursive) Flattens the group structures into a group IDs-to-group paths-mapping. This method traverses a list ofGroupRepresentationobjects and creates a map where each entry maps a group's ID to its path. If therecursiveparameter is set totrue, the method will also include all subgroups' IDs and paths.- Parameters:
groupRepresentations- the list ofGroupRepresentationobjects to be processedrecursive- iftrue, the method will include IDs and paths of subgroups recursively- Returns:
Mapwith group IDs as keys and group paths as values
-
findGroupEntryByPath
public static Map.Entry<String,String> findGroupEntryByPath(Map<String, String> flatGroups, String path) Retrieves an entry from the group IDs-to-paths-mapping, which matches a specified path.- Parameters:
flatGroups- a map where keys are group IDs and values are group pathspath- the group path to search for within the map- Returns:
Map.Entrycontaining the group ID and path that matches the specified path, ornullif no match is found
-
generateAlphabet
Method to generate the alphabet depending on the given algorithm.- Parameters:
algorithm- the user-given algorithmalphabet- the alphabet provided by the user, if available- Returns:
- the alphabet that matches the algorithm as a String
-
parseDateTimeString
Method to parse a string in an unknown date-time format into the OffsetDateTime format.- Parameters:
dateTime- the date time String- Returns:
- the given date-time as an instance of OffsetDateTime, or
nullif no known format was detected
-