org.apache.cxf.rs.security.oauth2.utils.crypto
Class CryptoUtils

java.lang.Object
  extended by org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils

public final class CryptoUtils
extends Object

Encryption helpers


Method Summary
static SecretKey createSecretKeySpec(byte[] bytes, String algo)
           
static SecretKey decodeSecretKey(String encodedSecretKey)
           
static SecretKey decodeSecretKey(String encodedSecretKey, String secretKeyAlgo)
           
static byte[] decodeSequence(String encodedSequence)
           
static byte[] decryptBytes(byte[] bytes, Key secretKey)
           
static byte[] decryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps)
           
static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, PrivateKey privateKey)
           
static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, KeyProperties props, PrivateKey privateKey)
           
static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, PrivateKey privateKey)
           
static String decryptSequence(String encodedData, Key secretKey)
           
static String decryptSequence(String encodedData, Key secretKey, KeyProperties props)
           
static String decryptSequence(String encodedToken, String encodedSecretKey)
           
static String decryptSequence(String encodedData, String encodedSecretKey, KeyProperties props)
           
static String encodeBytes(byte[] bytes)
           
static String encodeSecretKey(SecretKey key)
           
static byte[] encryptBytes(byte[] bytes, Key secretKey)
           
static byte[] encryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps)
           
static String encryptSecretKey(SecretKey secretKey, PublicKey publicKey)
           
static String encryptSecretKey(SecretKey secretKey, PublicKey publicKey, KeyProperties props)
           
static String encryptSequence(String sequence, Key secretKey)
           
static String encryptSequence(String sequence, Key secretKey, KeyProperties keyProps)
           
static RSAPrivateKey getRSAPrivateKey(byte[] modulusBytes, byte[] privateExponentBytes)
           
static RSAPrivateKey getRSAPrivateKey(KeyFactory factory, byte[] modulusBytes, byte[] privateExponentBytes)
           
static RSAPrivateKey getRSAPrivateKey(String encodedModulus, String encodedPrivateExponent)
           
static RSAPublicKey getRSAPublicKey(byte[] modulusBytes, byte[] publicExponentBytes)
           
static RSAPublicKey getRSAPublicKey(KeyFactory factory, byte[] modulusBytes, byte[] publicExponentBytes)
           
static RSAPublicKey getRSAPublicKey(String encodedModulus, String encodedPublicExponent)
           
static SecretKey getSecretKey(KeyProperties props)
           
static SecretKey getSecretKey(String symEncAlgo)
           
static Cipher initCipher(Key secretKey, KeyProperties keyProps, int mode)
           
static byte[] signData(byte[] data, PrivateKey key, String signAlgo)
           
static byte[] signData(byte[] data, PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params)
           
static SecretKey unwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps)
           
static SecretKey unwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, String unwrapperKeyAlgo)
           
static void verifySignature(byte[] data, byte[] signature, PublicKey key, String signAlgo)
           
static void verifySignature(byte[] data, byte[] signature, PublicKey key, String signAlgo, AlgorithmParameterSpec params)
           
static byte[] wrapSecretKey(byte[] keyBytes, String keyAlgo, Key wrapperKey, String wrapperKeyAlgo)
           
static byte[] wrapSecretKey(SecretKey secretKey, Key wrapperKey, KeyProperties keyProps)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeSecretKey

public static String encodeSecretKey(SecretKey key)
                              throws SecurityException
Throws:
SecurityException

encryptSecretKey

public static String encryptSecretKey(SecretKey secretKey,
                                      PublicKey publicKey)
                               throws SecurityException
Throws:
SecurityException

encryptSecretKey

public static String encryptSecretKey(SecretKey secretKey,
                                      PublicKey publicKey,
                                      KeyProperties props)
                               throws SecurityException
Throws:
SecurityException

getRSAPublicKey

public static RSAPublicKey getRSAPublicKey(String encodedModulus,
                                           String encodedPublicExponent)

getRSAPublicKey

public static RSAPublicKey getRSAPublicKey(byte[] modulusBytes,
                                           byte[] publicExponentBytes)

getRSAPublicKey

public static RSAPublicKey getRSAPublicKey(KeyFactory factory,
                                           byte[] modulusBytes,
                                           byte[] publicExponentBytes)

getRSAPrivateKey

public static RSAPrivateKey getRSAPrivateKey(String encodedModulus,
                                             String encodedPrivateExponent)

signData

public static byte[] signData(byte[] data,
                              PrivateKey key,
                              String signAlgo)

signData

public static byte[] signData(byte[] data,
                              PrivateKey key,
                              String signAlgo,
                              SecureRandom random,
                              AlgorithmParameterSpec params)

verifySignature

public static void verifySignature(byte[] data,
                                   byte[] signature,
                                   PublicKey key,
                                   String signAlgo)

verifySignature

public static void verifySignature(byte[] data,
                                   byte[] signature,
                                   PublicKey key,
                                   String signAlgo,
                                   AlgorithmParameterSpec params)

getRSAPrivateKey

public static RSAPrivateKey getRSAPrivateKey(byte[] modulusBytes,
                                             byte[] privateExponentBytes)

getRSAPrivateKey

public static RSAPrivateKey getRSAPrivateKey(KeyFactory factory,
                                             byte[] modulusBytes,
                                             byte[] privateExponentBytes)

getSecretKey

public static SecretKey getSecretKey(String symEncAlgo)
                              throws SecurityException
Throws:
SecurityException

getSecretKey

public static SecretKey getSecretKey(KeyProperties props)
                              throws SecurityException
Throws:
SecurityException

decryptSequence

public static String decryptSequence(String encodedToken,
                                     String encodedSecretKey)
                              throws SecurityException
Throws:
SecurityException

decryptSequence

public static String decryptSequence(String encodedData,
                                     String encodedSecretKey,
                                     KeyProperties props)
                              throws SecurityException
Throws:
SecurityException

decryptSequence

public static String decryptSequence(String encodedData,
                                     Key secretKey)
                              throws SecurityException
Throws:
SecurityException

decryptSequence

public static String decryptSequence(String encodedData,
                                     Key secretKey,
                                     KeyProperties props)
                              throws SecurityException
Throws:
SecurityException

encryptSequence

public static String encryptSequence(String sequence,
                                     Key secretKey)
                              throws SecurityException
Throws:
SecurityException

encryptSequence

public static String encryptSequence(String sequence,
                                     Key secretKey,
                                     KeyProperties keyProps)
                              throws SecurityException
Throws:
SecurityException

encodeBytes

public static String encodeBytes(byte[] bytes)
                          throws SecurityException
Throws:
SecurityException

encryptBytes

public static byte[] encryptBytes(byte[] bytes,
                                  Key secretKey)
                           throws SecurityException
Throws:
SecurityException

encryptBytes

public static byte[] encryptBytes(byte[] bytes,
                                  Key secretKey,
                                  KeyProperties keyProps)
                           throws SecurityException
Throws:
SecurityException

decryptBytes

public static byte[] decryptBytes(byte[] bytes,
                                  Key secretKey)
                           throws SecurityException
Throws:
SecurityException

decryptBytes

public static byte[] decryptBytes(byte[] bytes,
                                  Key secretKey,
                                  KeyProperties keyProps)
                           throws SecurityException
Throws:
SecurityException

wrapSecretKey

public static byte[] wrapSecretKey(byte[] keyBytes,
                                   String keyAlgo,
                                   Key wrapperKey,
                                   String wrapperKeyAlgo)
                            throws SecurityException
Throws:
SecurityException

wrapSecretKey

public static byte[] wrapSecretKey(SecretKey secretKey,
                                   Key wrapperKey,
                                   KeyProperties keyProps)
                            throws SecurityException
Throws:
SecurityException

unwrapSecretKey

public static SecretKey unwrapSecretKey(byte[] wrappedBytes,
                                        String wrappedKeyAlgo,
                                        Key unwrapperKey,
                                        String unwrapperKeyAlgo)
                                 throws SecurityException
Throws:
SecurityException

unwrapSecretKey

public static SecretKey unwrapSecretKey(byte[] wrappedBytes,
                                        String wrappedKeyAlgo,
                                        Key unwrapperKey,
                                        KeyProperties keyProps)
                                 throws SecurityException
Throws:
SecurityException

initCipher

public static Cipher initCipher(Key secretKey,
                                KeyProperties keyProps,
                                int mode)
                         throws SecurityException
Throws:
SecurityException

decodeSecretKey

public static SecretKey decodeSecretKey(String encodedSecretKey)
                                 throws SecurityException
Throws:
SecurityException

decodeSecretKey

public static SecretKey decodeSecretKey(String encodedSecretKey,
                                        String secretKeyAlgo)
                                 throws SecurityException
Throws:
SecurityException

decryptSecretKey

public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey,
                                         PrivateKey privateKey)

decryptSecretKey

public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey,
                                         String secretKeyAlgo,
                                         PrivateKey privateKey)
                                  throws SecurityException
Throws:
SecurityException

decryptSecretKey

public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey,
                                         String secretKeyAlgo,
                                         KeyProperties props,
                                         PrivateKey privateKey)
                                  throws SecurityException
Throws:
SecurityException

createSecretKeySpec

public static SecretKey createSecretKeySpec(byte[] bytes,
                                            String algo)

decodeSequence

public static byte[] decodeSequence(String encodedSequence)
                             throws SecurityException
Throws:
SecurityException


Apache CXF