Search in sources :

Example 1 with CryptoException

use of com.itrus.cryptorole.CryptoException in project portal by ixinportal.

the class TrustService method initSignKey.

/**
 * 初始化签名证书
 *
 * @throws NotSupportException
 * @throws CryptoException
 */
public void initSignKey() throws NotSupportException, CryptoException {
    try {
        Resource resource = new ClassPathResource(ksFileName);
        InputStream fis = resource.getInputStream();
        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(fis, kspass.toCharArray());
        fis.close();
        this.keyOfSigner = (PrivateKey) keyStore.getKey(kAliase, kPass.toCharArray());
        this.certOfSigner = (java.security.cert.X509Certificate) keyStore.getCertificate(kAliase);
    } catch (FileNotFoundException e) {
        throw new CryptoException(e);
    } catch (KeyStoreException e) {
        throw new CryptoException(e);
    } catch (NoSuchAlgorithmException e) {
        throw new CryptoException(e);
    } catch (CertificateException e) {
        throw new CryptoException(e);
    } catch (IOException e) {
        throw new CryptoException(e);
    } catch (UnrecoverableKeyException e) {
        throw new CryptoException(e);
    }
}
Also used : InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) FileNotFoundException(java.io.FileNotFoundException) CertificateException(java.security.cert.CertificateException) KeyStoreException(java.security.KeyStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) KeyStore(java.security.KeyStore) ClassPathResource(org.springframework.core.io.ClassPathResource) UnrecoverableKeyException(java.security.UnrecoverableKeyException) CryptoException(com.itrus.cryptorole.CryptoException)

Aggregations

CryptoException (com.itrus.cryptorole.CryptoException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 KeyStore (java.security.KeyStore)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 CertificateException (java.security.cert.CertificateException)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 Resource (org.springframework.core.io.Resource)1