org.neociclo.odetteftp.util
Class SecurityUtil

java.lang.Object
  extended by org.neociclo.odetteftp.util.SecurityUtil

public class SecurityUtil
extends Object

Version:
$Rev: 311 $ $Date: 2010-05-07 11:46:40 -0300 (Fri, 07 May 2010) $
Author:
Rafael Marins

Field Summary
static String BC_PROVIDER
          BouncyCastle JCE Provider name.
static String DEFAULT_OFTP_HASH_ALGORITHM
          Use SHA-1 as hash generation algorithm.
 
Constructor Summary
SecurityUtil()
           
 
Method Summary
static byte[] computeFileHash(File file, String algorithm)
           
static X509Certificate getCertificateEntry(KeyStore ks)
           
static PrivateKey getPrivateKey(KeyStore ks, char[] password)
           
static void installBouncyCastleProviderIfNecessary()
           
static X509Certificate openCertificate(File path)
           
static KeyStore openKeyStore(File path, char[] password)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BC_PROVIDER

public static final String BC_PROVIDER
BouncyCastle JCE Provider name.


DEFAULT_OFTP_HASH_ALGORITHM

public static final String DEFAULT_OFTP_HASH_ALGORITHM
Use SHA-1 as hash generation algorithm.

See Also:
Constant Field Values
Constructor Detail

SecurityUtil

public SecurityUtil()
Method Detail

openKeyStore

public static KeyStore openKeyStore(File path,
                                    char[] password)
                             throws KeyStoreException,
                                    NoSuchProviderException,
                                    NoSuchAlgorithmException,
                                    CertificateException,
                                    IOException
Throws:
KeyStoreException
NoSuchProviderException
NoSuchAlgorithmException
CertificateException
IOException

getPrivateKey

public static PrivateKey getPrivateKey(KeyStore ks,
                                       char[] password)
                                throws KeyStoreException,
                                       NoSuchAlgorithmException,
                                       UnrecoverableKeyException
Throws:
KeyStoreException
NoSuchAlgorithmException
UnrecoverableKeyException

openCertificate

public static X509Certificate openCertificate(File path)
                                       throws FileNotFoundException,
                                              CertificateException,
                                              NoSuchProviderException
Throws:
FileNotFoundException
CertificateException
NoSuchProviderException

installBouncyCastleProviderIfNecessary

public static void installBouncyCastleProviderIfNecessary()

getCertificateEntry

public static X509Certificate getCertificateEntry(KeyStore ks)
                                           throws KeyStoreException
Throws:
KeyStoreException

computeFileHash

public static byte[] computeFileHash(File file,
                                     String algorithm)
                              throws NoSuchAlgorithmException,
                                     NoSuchProviderException,
                                     IOException
Throws:
NoSuchAlgorithmException
NoSuchProviderException
IOException


ACCORD