Example usage for java.security Provider getName

List of usage examples for java.security Provider getName

Introduction

In this page you can find the example usage for java.security Provider getName.

Prototype

public String getName() 

Source Link

Document

Returns the name of this provider.

Usage

From source file:test.integ.be.agiv.security.Config.java

public Config() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException,
        UnrecoverableKeyException, NoSuchProviderException {
    Properties properties = new Properties();
    properties.load(Config.class.getResourceAsStream("/agiv.properties"));
    this.username = properties.getProperty("username");
    this.password = properties.getProperty("password");
    this.pkcs12Path = properties.getProperty("pkcs12.path");
    this.pkcs12Password = properties.getProperty("pkcs12.password");
    Provider[] providers = Security.getProviders();
    for (Provider provider : providers) {
        LOG.debug("security provider: " + provider.getName());
    }/*from  w  w w  .  ja  v a 2s  .  c o  m*/
    if (null != this.pkcs12Path) {
        InputStream pkcs12InputStream = new FileInputStream(pkcs12Path);
        KeyStore keyStore = KeyStore.getInstance("PKCS12", "SunJSSE");
        keyStore.load(pkcs12InputStream, pkcs12Password.toCharArray());
        Enumeration<String> aliases = keyStore.aliases();
        String alias = aliases.nextElement();
        this.certificate = (X509Certificate) keyStore.getCertificate(alias);
        this.privateKey = (PrivateKey) keyStore.getKey(alias, this.pkcs12Password.toCharArray());
    } else {
        this.certificate = null;
        this.privateKey = null;
    }
}