org.cogroo.addon.util
Class SecurityUtil

java.lang.Object
  extended by org.cogroo.addon.util.SecurityUtil

public class SecurityUtil
extends Object


Constructor Summary
SecurityUtil()
           
 
Method Summary
 byte[] decodeURLSafe(String encoded)
           
 byte[] decrypt(PrivateKey privateKey, byte[] encryptedSecretKey, byte[] encryptedText)
           
 String encode(byte[] key)
           
 String encodeURLSafe(byte[] key)
           
static String encodeURLSafe(String data)
           
 byte[] encrypt(PrivateKey privateKey, byte[] encryptedSecretKey, String data)
          Encrypt data using an key encrypted with a private key.
 String encrypt(String plaintext)
          Encrypt a string using SHA
 KeyPair genKeyPair()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityUtil

public SecurityUtil()
Method Detail

encrypt

public byte[] encrypt(PrivateKey privateKey,
                      byte[] encryptedSecretKey,
                      String data)
               throws InvalidKeyException
Encrypt data using an key encrypted with a private key.

Parameters:
privateKey - the private key to decrypt the secret key
encryptedSecretKey - a encrypted secret key
data - the data to encrypt
Returns:
the encrypted data
Throws:
InvalidKeyException - one of the keys is invalid

decrypt

public byte[] decrypt(PrivateKey privateKey,
                      byte[] encryptedSecretKey,
                      byte[] encryptedText)

genKeyPair

public KeyPair genKeyPair()

encode

public String encode(byte[] key)

encodeURLSafe

public static String encodeURLSafe(String data)

encodeURLSafe

public String encodeURLSafe(byte[] key)

decodeURLSafe

public byte[] decodeURLSafe(String encoded)

encrypt

public String encrypt(String plaintext)
Encrypt a string using SHA

Parameters:
plaintext - the original text
Returns:
resultant hash


Copyright © 2012-2013 CoGrOO. All Rights Reserved.