Class Utils

java.lang.Object
org.apache.commons.crypto.utils.Utils

public final class Utils extends Object
General utility methods.
  • Field Details

    • SYSTEM_PROPERTIES_FILE

      private static final String SYSTEM_PROPERTIES_FILE
      The file name of configuration file.
      See Also:
  • Constructor Details

    • Utils

      private Utils()
      The private constructor of Utils.
  • Method Details

    • checkArgument

      public static void checkArgument(boolean expression)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
      expression - a boolean expression.
      Throws:
      IllegalArgumentException - if expression is false.
    • checkArgument

      public static void checkArgument(boolean expression, Object errorMessage)
      Checks the truth of an expression.
      Parameters:
      expression - a boolean expression.
      errorMessage - the exception message to use if the check fails; will be converted to a string using String .valueOf(Object).
      Throws:
      IllegalArgumentException - if expression is false.
    • checkNotNull

      @Deprecated public static <T> T checkNotNull(T reference)
      Ensures that an object reference passed as a parameter to the calling method is not null.
      Type Parameters:
      T - the type of the object reference to be checked.
      Parameters:
      reference - an object reference.
      Returns:
      the non-null reference that was validated.
      Throws:
      NullPointerException - if reference is null.
    • checkState

      public static void checkState(boolean expression)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      Parameters:
      expression - a boolean expression.
      Throws:
      IllegalStateException - if expression is false.
    • checkState

      public static void checkState(boolean expression, String message)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      Parameters:
      expression - a boolean expression.
      message - Error message for the exception when the expression is false.
      Throws:
      IllegalStateException - if expression is false.
    • getCipherInstance

      public static CryptoCipher getCipherInstance(String transformation, Properties properties) throws IOException
      Helper method to create a CryptoCipher instance and throws only IOException.
      Parameters:
      transformation - the name of the transformation, e.g., AES/CBC/PKCS5Padding. See the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard transformation names.
      properties - The Properties class represents a set of properties.
      Returns:
      the CryptoCipher instance.
      Throws:
      IOException - if an I/O error occurs.
    • getDefaultProperties

      public static Properties getDefaultProperties()
      Gets a properties instance that defaults to the System Properties plus any other properties found in the file SYSTEM_PROPERTIES_FILE
      Returns:
      a Properties instance with defaults
    • getProperties

      public static Properties getProperties(Properties newProp)
      Gets the properties merged with default properties.
      Parameters:
      newProp - User-defined properties
      Returns:
      User-defined properties with the default properties
    • libraryPath

      static String libraryPath(String name)
    • splitClassNames

      public static List<String> splitClassNames(String clazzNames, String separator)
      Splits class names sequence into substrings, Trim each substring into an entry,and returns an list of the entries.
      Parameters:
      clazzNames - a string consist of a list of the entries joined by a delimiter, may be null or empty in which case an empty list is returned.
      separator - a delimiter for the input string.
      Returns:
      a list of class entries.