org.jboss.security.integration.password
Class KeyStoreUtil

java.lang.Object
  extended by org.jboss.security.integration.password.KeyStoreUtil

public class KeyStoreUtil
extends Object

Utility to handle Java Keystore

Since:
Jan 12, 2009
Author:
Anil.Saldhana@redhat.com

Constructor Summary
KeyStoreUtil()
           
 
Method Summary
static void createKeyStore(String path, char[] storePass)
          Create a Keystore
static KeyPair generateKeyPair(String algo)
          Generate a Key Pair
static KeyStore getKeyStore(InputStream ksStream, char[] storePass)
          Get the Key Store Note: This method wants the InputStream to be not null.
static KeyStore getKeyStore(String fileURL, char[] storePass)
          Get the Keystore given the url to the keystore file as a string
static KeyStore getKeyStore(URL url, char[] storePass)
          Get the Keystore given the URL to the keystore
static PublicKey getPublicKey(KeyStore ks, String alias, char[] password)
          Get the Public Key from the keystore
static void storeKeyPair(KeyStore ks, String alias, PublicKey publicKey, PrivateKey privateKey, char[] pass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyStoreUtil

public KeyStoreUtil()
Method Detail

createKeyStore

public static void createKeyStore(String path,
                                  char[] storePass)
                           throws Exception
Create a Keystore

Parameters:
storePass -
Throws:
Exception

getKeyStore

public static KeyStore getKeyStore(String fileURL,
                                   char[] storePass)
                            throws GeneralSecurityException,
                                   IOException
Get the Keystore given the url to the keystore file as a string

Parameters:
fileURL -
storePass -
Returns:
Throws:
GeneralSecurityException
IOException

getKeyStore

public static KeyStore getKeyStore(URL url,
                                   char[] storePass)
                            throws GeneralSecurityException,
                                   IOException
Get the Keystore given the URL to the keystore

Parameters:
url -
storePass -
Returns:
Throws:
GeneralSecurityException
IOException

getKeyStore

public static KeyStore getKeyStore(InputStream ksStream,
                                   char[] storePass)
                            throws GeneralSecurityException,
                                   IOException
Get the Key Store Note: This method wants the InputStream to be not null.

Parameters:
ksStream -
storePass -
Returns:
Throws:
GeneralSecurityException
IOException
IllegalArgumentException - if ksStream is null

generateKeyPair

public static KeyPair generateKeyPair(String algo)
                               throws Exception
Generate a Key Pair

Parameters:
algo - (RSA, DSA etc)
Returns:
Throws:
Exception

getPublicKey

public static PublicKey getPublicKey(KeyStore ks,
                                     String alias,
                                     char[] password)
                              throws Exception
Get the Public Key from the keystore

Parameters:
ks -
alias -
password -
Returns:
Throws:
Exception

storeKeyPair

public static void storeKeyPair(KeyStore ks,
                                String alias,
                                PublicKey publicKey,
                                PrivateKey privateKey,
                                char[] pass)
                         throws Exception
Throws:
Exception


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.