be.SIRAPRISE.util
Class MyCertificate

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

public abstract class MyCertificate
extends java.lang.Object

Author:
Erwin

Field Summary
static java.lang.String RESOURCETYPE
           
static java.lang.String SUFFIX
           
static java.lang.String X509CERTIFICATETYPE
           
 
Method Summary
static java.security.cert.Certificate getCertificate(java.lang.Class<?> clazz)
          Gets a Certificate object of the default certificate type.
static java.security.cert.Certificate getCertificate(java.lang.Class<?> clazz, java.lang.String certificateType)
          Gets a Certificate object of the given certificate type.
static java.io.InputStream getCertificateInputStream(java.lang.Class<?> clazz)
          Gets an InputStream for reading a resource corresponding to the given class.
static java.security.cert.Certificate getPackageCertificate(java.lang.Class<?> clazz)
          Gets a Certificate object of the default certificate type.
static java.security.cert.Certificate getPackageCertificate(java.lang.Class<?> clazz, java.lang.String certificateType)
          Gets a Certificate object of the given certificate type.
static java.io.InputStream getPackageCertificateInputStream(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

RESOURCETYPE

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

SUFFIX

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

X509CERTIFICATETYPE

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

getCertificate

public static java.security.cert.Certificate getCertificate(java.lang.Class<?> clazz)
                                                     throws java.security.cert.CertificateException,
                                                            NotFoundException,
                                                            java.io.IOException,
                                                            java.security.cert.CertificateException
Gets a Certificate object of the default certificate type.

Parameters:
clazz - The class of the object for which a certificate 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 Certificate object containing the contents of the certificate resource corresponding to the clazz class/object
Throws:
java.security.cert.CertificateException
NotFoundException
java.io.IOException
java.security.cert.CertificateException

getCertificate

public static java.security.cert.Certificate getCertificate(java.lang.Class<?> clazz,
                                                            java.lang.String certificateType)
                                                     throws java.security.cert.CertificateException,
                                                            NotFoundException,
                                                            java.io.IOException,
                                                            java.security.cert.CertificateException
Gets a Certificate object of the given certificate type.

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

getCertificateInputStream

public static java.io.InputStream getCertificateInputStream(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.certificate (= com/foo/Bar.certificate) on the classpath
  2. For a file named com.foo.Bar.certificate in the current user working dir
  3. For a file named com.foo.Bar.certificate on the user's home dir

Parameters:
clazz - The class of the object for which a certificate 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

getPackageCertificate

public static java.security.cert.Certificate getPackageCertificate(java.lang.Class<?> clazz)
                                                            throws java.security.cert.CertificateException,
                                                                   NotFoundException,
                                                                   java.io.IOException,
                                                                   java.security.cert.CertificateException
Gets a Certificate object of the default certificate type.

Parameters:
clazz - The class of the object for which a certificate 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 Certificate object containing the contents of the certificate resource corresponding to the clazz class/object
Throws:
java.security.cert.CertificateException
NotFoundException
java.io.IOException
java.security.cert.CertificateException

getPackageCertificate

public static java.security.cert.Certificate getPackageCertificate(java.lang.Class<?> clazz,
                                                                   java.lang.String certificateType)
                                                            throws java.security.cert.CertificateException,
                                                                   NotFoundException,
                                                                   java.io.IOException,
                                                                   java.security.cert.CertificateException
Gets a Certificate object of the given certificate type.

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

getPackageCertificateInputStream

public static java.io.InputStream getPackageCertificateInputStream(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.certificate (= /com/foo/certificate) on the classpath
  2. For a file named com.foo.certificate in the current user working dir
  3. For a file named com.foo.certificate on the user's home dir

Parameters:
clazz - The class of the object for which a certificate 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