Class Utility

java.lang.Object
org.trustdeck.utils.Utility

@Component public class Utility extends Object
This class offers a variety of utilities.
Author:
Armin Müller and Eric Wündisch
  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • validityTimeToSeconds

      public static Long validityTimeToSeconds(String validityTime)
      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 null if 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 of GroupRepresentation objects, extracting the path of each group and adding it to a result list. If the recursive parameter is set to true, it recursively flattens the paths of all subgroups as well, adding their paths to the list.
      Parameters:
      groupRepresentations - the list of GroupRepresentation objects to be flattened
      recursive - if true, the method will also include paths of subgroups recursively
      Returns:
      List of String containing the paths of all groups (and optionally subgroups)
    • 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 of GroupRepresentation objects and creates a map where each entry maps a group's ID to its path. If the recursive parameter is set to true, the method will also include all subgroups' IDs and paths.
      Parameters:
      groupRepresentations - the list of GroupRepresentation objects to be processed
      recursive - if true, the method will include IDs and paths of subgroups recursively
      Returns:
      Map with 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 paths
      path - the group path to search for within the map
      Returns:
      Map.Entry containing the group ID and path that matches the specified path, or null if no match is found
    • generateAlphabet

      public static String generateAlphabet(String algorithm, String alphabet)
      Method to generate the alphabet depending on the given algorithm.
      Parameters:
      algorithm - the user-given algorithm
      alphabet - the alphabet provided by the user, if available
      Returns:
      the alphabet that matches the algorithm as a String
    • parseDateTimeString

      public static OffsetDateTime parseDateTimeString(String dateTime)
      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 null if no known format was detected