Class GrouperClientUtils

java.lang.Object
edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
edu.internet2.middleware.grouperClient.util.GrouperClientUtils

public class GrouperClientUtils extends GrouperClientCommonUtils
utility methods specific to grouper client
  • Field Details

    • PERFORMANCE_LOG_LABEL_SQL

      public static final String PERFORMANCE_LOG_LABEL_SQL
      use this for performance log label for sql queries
      See Also:
  • Constructor Details

    • GrouperClientUtils

      public GrouperClientUtils()
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception
    • jsonConvertTo

      public static String jsonConvertTo(Object object, boolean includeObjectNameWrapper)
      convert object to json, optionally include object name wrapper
      Parameters:
      object -
      includeObjectNameWrapper -
      Returns:
      the json
    • jsonConvertFrom

      public static Object jsonConvertFrom(Map<String,Class<?>> conversionMap, String json)
      convert an object from json. note this works well if there are no collections, just real types, arrays, etc.
      Parameters:
      conversionMap - is the class simple name to class of objects which are allowed to be brought back. Note: only the top level object needs to be registered
      json -
      Returns:
      the object
    • performanceTimingAllDuration

      public static void performanceTimingAllDuration(String key, long durationNanos)
      Parameters:
      key -
      durationNanos -
    • toStringReflection

      public static String toStringReflection(Object object, Set<String> fieldsToIgnore)
      to string reflection
      Parameters:
      object -
      Returns:
      the string representation
    • toStringReflection

      public static String toStringReflection(Object object, Set<String> fieldsToIgnore, String extraInfo)
      to string reflection
      Parameters:
      object -
      Returns:
      the string representation
    • toStringReflection

      public static String toStringReflection(Object object)
      to string reflection
      Parameters:
      object -
      Returns:
      the string representation
    • appendQuestions

      public static String appendQuestions(int numberOfMarks)
      append a certain number of question marks to a query
      Parameters:
      query -
      numberOfMarks -
    • appendQuestions

      public static void appendQuestions(StringBuilder query, int numberOfMarks)
      append a certain number of question marks to a query
      Parameters:
      query -
      numberOfMarks -
    • retrieveLog

      public static Log retrieveLog(Class<?> theClass)
      Parameters:
      theClass -
      Returns:
      the log
    • grouperClientOverrideMap

      @Deprecated public static Map<String,String> grouperClientOverrideMap()
      Deprecated.
      use GrouperClientConfig.retrieveConfig().propertiesOverrideMap() instead
      override map for properties for testing
      Returns:
      the override map
    • grouperClientProperties

      @Deprecated public static Properties grouperClientProperties()
      Deprecated.
      use GrouperClientConfig.retrieveConfig().properties() instead
      grouper client properties
      Returns:
      the properties
    • propertiesValue

      @Deprecated public static String propertiesValue(String key, boolean required)
      Deprecated.
      use GrouperClientConfig.retrieveConfig().propertyValueString instead
      get a property and validate required from grouper.client.properties
      Parameters:
      key -
      required -
      Returns:
      the value
    • propertiesValueBoolean

      @Deprecated public static boolean propertiesValueBoolean(String key, boolean defaultValue, boolean required)
      Deprecated.
      use GrouperClientConfig.retrieveConfig().propertyValueBoolean instead
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      defaultValue -
      required -
      Returns:
      the string
    • propertiesValueInt

      @Deprecated public static int propertiesValueInt(String key, int defaultValue, boolean required)
      Deprecated.
      GrouperClientConfig.retrieveConfig().propertyValueInt
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      defaultValue -
      required -
      Returns:
      the string
    • substituteExpressionLanguage

      public static String substituteExpressionLanguage(String stringToParse, Map<String,Object> variableMap)
      substitute an EL for objects. Dont worry if something returns null
      Parameters:
      stringToParse -
      variableMap -
      Returns:
      the string
    • join

      public static void join(Thread thread)
      wait for a thread to end
      Parameters:
      thread -
    • substituteExpressionLanguage

      public static String substituteExpressionLanguage(String stringToParse, Map<String,Object> variableMap, boolean allowStaticClasses, boolean silent, boolean lenient, boolean logOnNull)
      substitute an EL for objects
      Parameters:
      stringToParse -
      variableMap -
      allowStaticClasses - if true allow static classes not registered with context
      silent - if silent mode, swallow exceptions (warn), and dont warn when variable not found
      lenient - false if undefined variables should throw an exception. if lenient is true (default) then undefined variables are null
      logOnNull - if null output of substitution should be logged
      Returns:
      the string
    • subjectAttributeValue

      public static String subjectAttributeValue(WsSubject wsSubject, String[] attributeNames, String attributeName)
      get the attribute value of an attribute name of a subject
      Parameters:
      wsSubject - subject
      attributeNames - list of attribute names in the subject
      attributeName - to query
      Returns:
      the value or null
    • encryptKey

      public static String encryptKey()
      Returns:
      the encrypt key
    • decryptFromFileIfFileExists

      public static String decryptFromFileIfFileExists(String pass, StringBuilder logInfo)
      decrypt a pass from a file if the file exists (i.e. passes might have slashes in them)
      Parameters:
      pass -
      logInfo - if not null, put log info in there
      Returns:
      the pass
    • cacheDirectoryName

      public static String cacheDirectoryName()
      name of the cache directory without trailing slash
      Returns:
      the name of the cache directory
    • encryptSha

      public static String encryptSha(String plaintext)
      encrypt a message to SHA with base 64
      Parameters:
      plaintext -
      Returns:
      the hash
    • httpCall

      public static HttpCallResponse httpCall(String urlSuffix, String serviceAuthn, HttpCallMethod httpCallMethod, String body)
      call HTTP with a url, optional request body, get a response body. this assumes json by default
      Parameters:
      urlSuffix - is after the configured URL
      serviceAuthn - is the config string that identifies the user/pass/url
      httpCallMethod - HTTP
      body - to send if applicable
      Returns:
      the response
    • popUrlString

      public static String popUrlString(List<String> urlStrings)
      pop first url string, retrieve, and remove, or null if not there
      Parameters:
      urlStrings -
      Returns:
      the string or null if not there