be.SIRAPRISE.util
Class MyKeyStore

java.lang.Object
  extended by be.SIRAPRISE.util.MyKeyStore

public abstract class MyKeyStore
extends java.lang.Object

Author:
Erwin

Field Summary
static java.lang.String RESOURCETPYE
           
static java.lang.String SUFFIX
           
 
Method Summary
static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz)
          Gets a KeyStore object of the default keystore type.
static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz, char[] storePassword)
          Gets a KeyStore object of the default keystore type.
static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz, java.lang.String keyStoreType)
          Gets a KeyStore object of the given keystore type.
static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz, java.lang.String keyStoreType, char[] storePassword)
          Gets a KeyStore object of the given keystore type.
static java.security.KeyStore getKeyStore(java.lang.String user)
          Gets a keystore object for a keystore of the default keystore type for the named user.
static java.security.KeyStore getKeyStore(java.lang.String user, char[] storePassword)
          Gets a keystore object for a keystore of the named keystore type for the named user.
static java.security.KeyStore getKeyStore(java.lang.String user, java.lang.String keyStoreType)
          Gets a keystore object for a keystore of the named keystore type for the named user.
static java.security.KeyStore getKeyStore(java.lang.String user, java.lang.String keyStoreType, char[] storePassword)
          Gets a keystore object for a keystore of the named keystore type for the named user.
static java.io.InputStream getKeyStoreInputStream(java.lang.Class<?> clazz)
          Gets an InputStream for reading a resource corresponding to the given class.
static java.io.InputStream getKeyStoreInputStream(java.lang.String user)
          Gets an InputStream for reading a keystore resource corresponding to the named user.
static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz)
          Gets a KeyStore object of the default keystore type.
static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz, char[] storePassword)
          Gets a KeyStore object of the default keystore type.
static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz, java.lang.String keyStoreType)
          Gets a KeyStore object of the given keystore type.
static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz, java.lang.String keyStoreType, char[] storePassword)
          Gets a KeyStore object of the given keystore type.
static java.io.InputStream getPackageKeyStoreInputStream(java.lang.Class<?> clazz)
          Gets an InputStream for reading a resource corresponding to the package of the given class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCETPYE

public static final java.lang.String RESOURCETPYE
See Also:
Constant Field Values

SUFFIX

public static final java.lang.String SUFFIX
See Also:
Constant Field Values
Method Detail

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz)
                                          throws java.security.KeyStoreException,
                                                 NotFoundException,
                                                 java.io.IOException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException
Gets a KeyStore object of the default keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full classname, followed by the SUFFIX constant.
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz,
                                                 char[] storePassword)
                                          throws java.security.KeyStoreException,
                                                 NotFoundException,
                                                 java.io.IOException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException
Gets a KeyStore object of the default keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full classname, followed by the SUFFIX constant.
storePassword - The password for loading the Store
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz,
                                                 java.lang.String keyStoreType)
                                          throws java.security.KeyStoreException,
                                                 NotFoundException,
                                                 java.io.IOException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException
Gets a KeyStore object of the given keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full classname, followed by the SUFFIX constant.
keyStoreType - The name of the KeyStore type to be returned to the caller
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.Class<?> clazz,
                                                 java.lang.String keyStoreType,
                                                 char[] storePassword)
                                          throws java.security.KeyStoreException,
                                                 NotFoundException,
                                                 java.io.IOException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException
Gets a KeyStore object of the given keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full classname, followed by the SUFFIX constant.
keyStoreType - The name of the KeyStore type to be returned to the caller
storePassword - The password for loading the store
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.String user)
                                          throws java.security.KeyStoreException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException,
                                                 NotFoundException
Gets a keystore object for a keystore of the default keystore type for the named user.

Parameters:
user - The user whose keystore is to be obtained
Returns:
a keystore object for a keystore of the default keystore type for the named user.
Throws:
java.security.KeyStoreException
java.io.IOException
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
NotFoundException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.String user,
                                                 char[] storePassword)
                                          throws java.security.KeyStoreException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException,
                                                 NotFoundException
Gets a keystore object for a keystore of the named keystore type for the named user.

Parameters:
user - The user whose keystore is to be obtained
storePassword - the password to be provided for opening the keystore
Returns:
a keystore object for a keystore of the named keystore type for the named user.
Throws:
java.security.KeyStoreException
java.io.IOException
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
NotFoundException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.String user,
                                                 java.lang.String keyStoreType)
                                          throws java.security.KeyStoreException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException,
                                                 NotFoundException
Gets a keystore object for a keystore of the named keystore type for the named user.

Parameters:
user - The user whose keystore is to be obtained
keyStoreType - The keystore type
Returns:
a keystore object for a keystore of the named keystore type for the named user.
Throws:
java.security.KeyStoreException
java.io.IOException
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
NotFoundException

getKeyStore

public static java.security.KeyStore getKeyStore(java.lang.String user,
                                                 java.lang.String keyStoreType,
                                                 char[] storePassword)
                                          throws java.security.KeyStoreException,
                                                 java.security.NoSuchAlgorithmException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException,
                                                 NotFoundException
Gets a keystore object for a keystore of the named keystore type for the named user.

Parameters:
user - The user whose keystore is to be obtained
keyStoreType - The keystore type
storePassword - the password to be provided for opening the keystore
Returns:
a keystore object for a keystore of the named keystore type for the named user.
Throws:
java.security.KeyStoreException
java.io.IOException
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
NotFoundException - If no keystore file for this user could be found

getKeyStoreInputStream

public static java.io.InputStream getKeyStoreInputStream(java.lang.Class<?> clazz)
                                                  throws NotFoundException
Gets an InputStream for reading a resource corresponding to the given class. Search will be conducted consecutively in the following places (in the example, the class is com.foo.Bar) :
  1. For a resource named com/foo/Bar/keystore on the classpath
  2. For a file named com.foo.Bar.keystore in the current user working dir
  3. For a file named com.foo.Bar.keystore on the user's home dir
  4. For a resource named /com.foo.Bar.keystore on the classpath
  5. For a file named com/foo/Bar.keystore in the current user working dir
  6. For a file named com/foo/Bar.keystore on the user's home dir
  7. For a resource named /com/foo/Bar.keystore on the classpath

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full classname, followed by the SUFFIX constant.
Returns:
An inputStream through which the resource corresponding to the clazz class can be read
Throws:
NotFoundException

getKeyStoreInputStream

public static java.io.InputStream getKeyStoreInputStream(java.lang.String user)
                                                  throws NotFoundException
Gets an InputStream for reading a keystore resource corresponding to the named user. The search will be for a file named .keystore in the directories pointed to by user.home and user.dir.

Parameters:
user - The user for which a keystore input stream is to be returned
Returns:
an InputStream for reading a keystore resource corresponding to the named user. The search will be for a file named .keystore in the directories pointed to by user.home and user.dir.
Throws:
NotFoundException

getPackageKeyStore

public static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz)
                                                 throws java.security.KeyStoreException,
                                                        NotFoundException,
                                                        java.io.IOException,
                                                        java.security.NoSuchAlgorithmException,
                                                        java.security.cert.CertificateException
Gets a KeyStore object of the default keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full packagename, followed by the SUFFIX constant.
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getPackageKeyStore

public static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz,
                                                        char[] storePassword)
                                                 throws java.security.KeyStoreException,
                                                        NotFoundException,
                                                        java.io.IOException,
                                                        java.security.NoSuchAlgorithmException,
                                                        java.security.cert.CertificateException
Gets a KeyStore object of the default keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full packagename, followed by the SUFFIX constant.
storePassword - The password for loading the store
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getPackageKeyStore

public static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz,
                                                        java.lang.String keyStoreType)
                                                 throws java.security.KeyStoreException,
                                                        NotFoundException,
                                                        java.io.IOException,
                                                        java.security.NoSuchAlgorithmException,
                                                        java.security.cert.CertificateException
Gets a KeyStore object of the given keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full packagename, followed by the SUFFIX constant.
keyStoreType - The name of the KeyStore type to be returned to the caller
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getPackageKeyStore

public static java.security.KeyStore getPackageKeyStore(java.lang.Class<?> clazz,
                                                        java.lang.String keyStoreType,
                                                        char[] storePassword)
                                                 throws java.security.KeyStoreException,
                                                        NotFoundException,
                                                        java.io.IOException,
                                                        java.security.NoSuchAlgorithmException,
                                                        java.security.cert.CertificateException
Gets a KeyStore object of the given keystore type.

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full packagename, followed by the SUFFIX constant.
keyStoreType - The name of the KeyStore type to be returned to the caller
storePassword - The password for loading the store
Returns:
The KeyStore object containing the contents of the keystore resource corresponding to the clazz class/object
Throws:
java.security.KeyStoreException
NotFoundException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException

getPackageKeyStoreInputStream

public static java.io.InputStream getPackageKeyStoreInputStream(java.lang.Class<?> clazz)
                                                         throws NotFoundException
Gets an InputStream for reading a resource corresponding to the package of the given class. Search will be conducted consecutively in the following places (in the example, the class is com.foo.Bar) :
  1. For a resource named com/foo/keystore on the classpath
  2. For a file named com.foo.keystore in the current user working dir
  3. For a file named com.foo.keystore on the user's home dir
  4. For a resource named /com.foo.keystore on the classpath
  5. For a file named com/foo.keystore in the current user working dir
  6. For a file named com/foo.keystore on the user's home dir
  7. For a resource named /com/foo.keystore on the classpath

Parameters:
clazz - The class of the object for which a keystore is to be found. The name of the resource that will be searched for is the full classname, followed by the SUFFIX constant.
Returns:
An inputStream through which the resource corresponding to the clazz class can be read
Throws:
NotFoundException