Class SecurityUtil

java.lang.Object
org.identityconnectors.common.security.SecurityUtil

public final class SecurityUtil extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static char[]
    bytesToChars(byte[] bytes)
    Converts bytes to chars without using any external functions that might allocate additional buffers for the potentially sensitive data.
    static byte[]
    charsToBytes(char[] chars)
    Converts chars to bytes without using any external functions that might allocate additional buffers for the potentially sensitive data.
    static void
    clear(byte[] bytes)
    Clears an array of potentially sensitive bytes
    static void
    clear(char[] chars)
    Clears an array of potentially sensitive chars
    static String
    computeBase64SHA1Hash(byte[] bytes)
    Computes the base 64 encoded SHA1 hash of the input
    static String
    computeBase64SHA1Hash(char[] input)
    Computes the base 64 encoded SHA1 hash of the input
    static boolean
    verifyBase64SHA1Hash(char[] input, String hash)
    Verifies the base 64-encoded SHA1 hash of the input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • charsToBytes

      public static byte[] charsToBytes(char[] chars)
      Converts chars to bytes without using any external functions that might allocate additional buffers for the potentially sensitive data. This guarantees the caller that they only need to cleanup the input and result.
      Parameters:
      chars - The chars
      Returns:
      The bytes
    • bytesToChars

      public static char[] bytesToChars(byte[] bytes)
      Converts bytes to chars without using any external functions that might allocate additional buffers for the potentially sensitive data. This guarantees the caller that they only need to cleanup the input and result.
      Parameters:
      bytes - The bytes (to convert into characters).
      Returns:
      The characters (converted from the specified bytes).
    • clear

      public static void clear(byte[] bytes)
      Clears an array of potentially sensitive bytes
      Parameters:
      bytes - The bytes. May be null.
    • clear

      public static void clear(char[] chars)
      Clears an array of potentially sensitive chars
      Parameters:
      chars - The characters. May be null.
    • computeBase64SHA1Hash

      public static String computeBase64SHA1Hash(char[] input)
      Computes the base 64 encoded SHA1 hash of the input
      Parameters:
      input - The input chars
      Returns:
      the hash
    • computeBase64SHA1Hash

      public static String computeBase64SHA1Hash(byte[] bytes)
      Computes the base 64 encoded SHA1 hash of the input
      Parameters:
      bytes - The input bytes.
      Returns:
      the hash (computed from the input bytes).
    • verifyBase64SHA1Hash

      public static boolean verifyBase64SHA1Hash(char[] input, String hash)
      Verifies the base 64-encoded SHA1 hash of the input.
      Parameters:
      input - The input chars
      hash - The expected hash
      Returns:
      true if the hash of the input characters matches the expected hash.