Search in sources :

Example 1 with KeyStoreLoader

use of org.demoiselle.signer.core.keystore.loader.KeyStoreLoader in project signer by demoiselle.

the class CertificateLoaderImpl method loadFromToken.

/**
 * When a PIN(Personal Identification Number) was informed,
 * obtain the certificate from a Token or Smartcard, defined by ICP-BRASIL with the name A3.
 *
 * @param pinNumber personal id number
 * @return the certificate information in X509Certificate format
 */
@Override
public X509Certificate loadFromToken(String pinNumber) {
    if (this.keyStore == null) {
        KeyStoreLoader keyStoreLoader = KeyStoreLoaderFactory.factoryKeyStoreLoader();
        this.keyStore = keyStoreLoader.getKeyStore();
    }
    String alias;
    try {
        alias = this.keyStore.aliases().nextElement();
        return (X509Certificate) this.keyStore.getCertificateChain(alias)[0];
    } catch (KeyStoreException e) {
        throw new CertificateCoreException("", e);
    }
}
Also used : KeyStoreLoader(org.demoiselle.signer.core.keystore.loader.KeyStoreLoader) KeyStoreException(java.security.KeyStoreException) X509Certificate(java.security.cert.X509Certificate) CertificateCoreException(org.demoiselle.signer.core.exception.CertificateCoreException)

Example 2 with KeyStoreLoader

use of org.demoiselle.signer.core.keystore.loader.KeyStoreLoader in project signer by demoiselle.

the class PDFSigner method getKeyStoreTokenBySigner.

// Usa o Signer para leitura, funciona para windows e NeoID
private KeyStore getKeyStoreTokenBySigner() {
    try {
        KeyStoreLoader keyStoreLoader = KeyStoreLoaderFactory.factoryKeyStoreLoader();
        KeyStore keyStore = keyStoreLoader.getKeyStore();
        return keyStore;
    } catch (Exception e1) {
        e1.printStackTrace();
        return null;
    } finally {
    }
}
Also used : KeyStoreLoader(org.demoiselle.signer.core.keystore.loader.KeyStoreLoader) KeyStore(java.security.KeyStore) IOException(java.io.IOException)

Example 3 with KeyStoreLoader

use of org.demoiselle.signer.core.keystore.loader.KeyStoreLoader in project signer by demoiselle.

the class CAdESSignerTest method getKeyStoreTokenBySigner.

// Usa o Signer para leitura, funciona para windows e NeoID
private KeyStore getKeyStoreTokenBySigner() {
    try {
        KeyStoreLoader keyStoreLoader = KeyStoreLoaderFactory.factoryKeyStoreLoader();
        KeyStore keyStore = keyStoreLoader.getKeyStore();
        return keyStore;
    } catch (Exception e1) {
        e1.printStackTrace();
        return null;
    } finally {
    }
}
Also used : KeyStoreLoader(org.demoiselle.signer.core.keystore.loader.KeyStoreLoader) MSKeyStoreLoader(org.demoiselle.signer.core.keystore.loader.implementation.MSKeyStoreLoader) KeyStore(java.security.KeyStore) KeyStoreException(java.security.KeyStoreException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

KeyStoreLoader (org.demoiselle.signer.core.keystore.loader.KeyStoreLoader)3 IOException (java.io.IOException)2 KeyStore (java.security.KeyStore)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 X509Certificate (java.security.cert.X509Certificate)1 CertificateCoreException (org.demoiselle.signer.core.exception.CertificateCoreException)1 MSKeyStoreLoader (org.demoiselle.signer.core.keystore.loader.implementation.MSKeyStoreLoader)1