Groovy Documentation

org.linkedin.groovy.util.encryption
[Groovy] Class EncryptionUtils

java.lang.Object
  org.linkedin.groovy.util.encryption.EncryptionUtils

class EncryptionUtils

Method Summary
static void createSecretKey(java.io.File keyFile, java.lang.String keyName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)

Create a file which stores random key which will be used for encrypt and decrypt

static java.lang.String decrypt(java.lang.String message, java.util.Map secretKeys)

decrypt a value using key in keyFile

static java.lang.String decryptBuffer(java.lang.String message, java.util.Map secretKeys)

Given a buffer with embedded encrypted strings, decrypt it.

static java.lang.Object decryptFiles(java.io.File fromDir, java.io.File toDir, java.util.Map secretKeys)

Takes an input directory (fromDir) and recursively finds and decrypt all files in it into new output directory (toDir)

static java.lang.String encrypt(java.lang.String value, java.util.Map secretKeys, java.lang.String keyName)

encrypt a value using the key in keyFile

static java.lang.String encryptionKeyName(java.lang.String encrypted)

static javax.crypto.SecretKey getSecretKey(java.io.File keyFile, java.lang.String keyName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)

static java.util.Map getSecretKeys(java.lang.String keyFileName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)

static java.util.Map getSecretKeys(java.io.File keyFile, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)

static boolean isEncrypted(java.lang.String encrypted)

given a string see if it encrypted.

static java.lang.String processBuffer(java.lang.String message, java.util.Map secretKeys, groovy.lang.Closure c)

Process a buffer with embedded encrypted strings, using the closure provided.

static void saveSecretKey(javax.crypto.SecretKey sk, java.io.File keyFile, java.lang.String keyName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

createSecretKey

static void createSecretKey(java.io.File keyFile, java.lang.String keyName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)
Create a file which stores random key which will be used for encrypt and decrypt
throws:
GeneralSecurityException
throws:
IOException


decrypt

static java.lang.String decrypt(java.lang.String message, java.util.Map secretKeys)
decrypt a value using key in keyFile
throws:
GeneralSecurityException
throws:
IOException


decryptBuffer

static java.lang.String decryptBuffer(java.lang.String message, java.util.Map secretKeys)
Given a buffer with embedded encrypted strings, decrypt it. Keeping the plain text part intact.
throws:
GeneralSecurityException
throws:
IOException
Parameters:
message
secretKeys
Returns:
decrypted buffer


decryptFiles

static java.lang.Object decryptFiles(java.io.File fromDir, java.io.File toDir, java.util.Map secretKeys)
Takes an input directory (fromDir) and recursively finds and decrypt all files in it into new output directory (toDir)
throws:
IOException
Parameters:
fromDir
toDir
secretKeys
Returns:
@throws FileNotFoundException


encrypt

static java.lang.String encrypt(java.lang.String value, java.util.Map secretKeys, java.lang.String keyName)
encrypt a value using the key in keyFile
throws:
GeneralSecurityException
throws:
IOException


encryptionKeyName

static java.lang.String encryptionKeyName(java.lang.String encrypted)


getSecretKey

static javax.crypto.SecretKey getSecretKey(java.io.File keyFile, java.lang.String keyName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)


getSecretKeys

static java.util.Map getSecretKeys(java.lang.String keyFileName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)


getSecretKeys

static java.util.Map getSecretKeys(java.io.File keyFile, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)


isEncrypted

static boolean isEncrypted(java.lang.String encrypted)
given a string see if it encrypted. This is done by checking the marker prefix/suffix that was added to the string.
Parameters:
encrypted
Returns:
true if the string passed in was encrypted.


processBuffer

static java.lang.String processBuffer(java.lang.String message, java.util.Map secretKeys, groovy.lang.Closure c)
Process a buffer with embedded encrypted strings, using the closure provided. Closure will receive three arguments: original string that was passed in, encrypted block that is embedded in the buffer and the secret keys that can used to decrypt it.
Parameters:
message
secretKeys
c
Returns:
String as processed by the closure


saveSecretKey

static void saveSecretKey(javax.crypto.SecretKey sk, java.io.File keyFile, java.lang.String keyName, java.lang.String keyStorePassword, java.lang.String secretKeyPassword)


 

Groovy Documentation