java.lang.Object
edu.internet2.middleware.grouperClientExt.edu.internet2.middleware.morphString.Crypto

@Deprecated public class Crypto extends Object
Deprecated.
use edu.internet2.middleware.morphString.Crypto instead!
The purpose of this class is to provide encryption and decryption using standard Java libraries, for potentially large amounts of data.

This class provides default encryption using AES with a constant 128 bit key. If you want something more secure feel free to override the defaults however you please.

This class works in one of two ways, (1) in memory using Strings, or (2) via I/O streams (preferred for large amounts of data).

Crypo objects, or more specifically the default ciphers they create, are not threadsafe and are not computationally cheap, so a threadlocal factory method is provided for convenience. This is the preferred means of usage, but feel free to create these objects however you please.

Note that you can encrypt BLOB fields by specifying encryption in the configurator (Crypto is the default encryption mechanism for that).

  • Constructor Details

    • Crypto

      public Crypto(Crypto theCrypto)
      Deprecated.
    • Crypto

      public Crypto()
      Deprecated.
      Default crypto object
    • Crypto

      public Crypto(String theKey)
      Deprecated.
      Default crypto object
      Parameters:
      theKey - used to encrypt/decrypt
  • Method Details

    • getThreadLocalCrypto

      public static Crypto getThreadLocalCrypto()
      Deprecated.
      Returns:
      a non-null thread-safe crypto object from a ThreadLocal
    • generateKeyBytes

      public static byte[] generateKeyBytes(String cipherName, Integer keybits)
      Deprecated.
      Generate a key.
      Parameters:
      cipherName - the name of the cipher, if null will default to "AES"
      keybits - the number of bits in the key, if null will default to 128
      Returns:
      the bytes comprising the key
    • createDefaultCipher

      public Cipher createDefaultCipher()
      Deprecated.
      Create the default cipher
      Returns:
      the default cipher
    • encrypt

      public String encrypt(String clearText)
      Deprecated.
      Encrypt the string
      Parameters:
      clearText -
      Returns:
      the encrypted String
    • decrypt

      public String decrypt(String cipherText)
      Deprecated.
      Decrypt the string
      Parameters:
      cipherText -
      Returns:
      the decrypted string
    • encrypt

      public InputStream encrypt(InputStream in)
      Deprecated.
      Get the encrypted input stream
      Parameters:
      in -
      Returns:
      the encrypted input stream
    • decrypt

      public InputStream decrypt(InputStream in)
      Deprecated.
      the decrypted input stream
      Parameters:
      in -
      Returns:
      the decrypted input stream
    • encrypt

      public OutputStream encrypt(OutputStream out)
      Deprecated.
      the encrypted output stream
      Parameters:
      out -
      Returns:
      the encrypted output stream
    • decrypt

      public OutputStream decrypt(OutputStream out)
      Deprecated.
      the decrypted output stream
      Parameters:
      out -
      Returns:
      the decrypted output stream