org.mobicents.slee.resource.parlay.util.crypto
Class RSAUtil

java.lang.Object
  extended by org.mobicents.slee.resource.parlay.util.crypto.RSAUtil

public class RSAUtil
extends java.lang.Object

This class provides utility methods for the creation, use and storage of RSA public and private keys.


Constructor Summary
RSAUtil()
           
 
Method Summary
static byte[] decryptMessage(byte[] message, java.security.PrivateKey privateKey, java.lang.String cipherAlgorithm)
          Decrypts a message using the private key.
static byte[] encryptMessage(byte[] message, java.security.interfaces.RSAPublicKey publicKey, java.lang.String cipherAlgorithm)
          Encrypts a message using the private key.
static java.security.KeyPair generateRSAKeyPair(int keySize)
          Generates an RSA key pair
static java.security.PrivateKey getPrivateKey(java.lang.String clientID)
           
static java.security.interfaces.RSAPublicKey getPublicKey(java.lang.String file, java.lang.String clientID)
           
static void loadKeyStore(java.lang.String vault, java.lang.String file)
          loads a keyStore from a .jks file or creates a new one.
static void saveKeyStore(java.lang.String vault)
          Saves the keyStore to a password protected file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSAUtil

public RSAUtil()
Method Detail

generateRSAKeyPair

public static java.security.KeyPair generateRSAKeyPair(int keySize)
                                                throws RSAUtilException
Generates an RSA key pair

Parameters:
keySize - the desired RSA key size
Returns:
the generated key pair
Throws:
RSAUtilException

getPublicKey

public static java.security.interfaces.RSAPublicKey getPublicKey(java.lang.String file,
                                                                 java.lang.String clientID)
                                                          throws RSAUtilException
Parameters:
file -
clientID -
Returns:
Throws:
RSAUtilException

getPrivateKey

public static java.security.PrivateKey getPrivateKey(java.lang.String clientID)
                                              throws RSAUtilException
Parameters:
clientID -
Returns:
Throws:
RSAUtilException

encryptMessage

public static byte[] encryptMessage(byte[] message,
                                    java.security.interfaces.RSAPublicKey publicKey,
                                    java.lang.String cipherAlgorithm)
                             throws RSAUtilException
Encrypts a message using the private key.

Parameters:
message - the message to be encrypted
publicKey - the key for the encryption
Returns:
the encrypted message
Throws:
RSAUtilException

decryptMessage

public static byte[] decryptMessage(byte[] message,
                                    java.security.PrivateKey privateKey,
                                    java.lang.String cipherAlgorithm)
                             throws RSAUtilException
Decrypts a message using the private key.

Parameters:
message - the message to be encrypted
privateKey - the key for the decryption
Returns:
the encrypted message
Throws:
RSAUtilException

loadKeyStore

public static void loadKeyStore(java.lang.String vault,
                                java.lang.String file)
                         throws RSAUtilException
loads a keyStore from a .jks file or creates a new one.

Parameters:
vault -
file -
Throws:
RSAUtilException

saveKeyStore

public static void saveKeyStore(java.lang.String vault)
                         throws RSAUtilException
Saves the keyStore to a password protected file.

Throws:
RSAUtilException


Copyright © 2009. All Rights Reserved.