Example usage for org.apache.commons.ssl TrustChain getTrustManagers

List of usage examples for org.apache.commons.ssl TrustChain getTrustManagers

Introduction

In this page you can find the example usage for org.apache.commons.ssl TrustChain getTrustManagers.

Prototype

public Object[] getTrustManagers()
        throws NoSuchAlgorithmException, KeyStoreException, IOException, CertificateException 

Source Link

Usage

From source file:org.fedoraproject.eclipse.packager.FedoraSSL.java

/**
 * Set up an SSLContext, and initialize it properly.
 * //from   w  w  w  .  ja v  a2 s. c  om
 * @throws GeneralSecurityException
 * @throws IOException
 * @return The initialized SSLConext instance.
 * @throws FileNotFoundException
 *             If one of the three certificates is missing.
 */
public SSLContext getInitializedSSLContext()
        throws GeneralSecurityException, FileNotFoundException, IOException {
    if (!allCertsExist) {
        Object[] bindings = { fedoraCert.getAbsolutePath(), fedoraServerCert.getAbsolutePath(),
                fedoraUploadCert.getAbsolutePath() };
        throw new FileNotFoundException(
                NLS.bind(FedoraPackagerText.FedoraSSL_certificatesMissingError, bindings));
    }
    TrustChain tc = getTrustChain();

    KeyMaterial kmat = getFedoraCertKeyMaterial();

    SSLContext sc = SSLContext.getInstance("SSL"); //$NON-NLS-1$

    sc.init((KeyManager[]) kmat.getKeyManagers(), (TrustManager[]) tc.getTrustManagers(),
            new java.security.SecureRandom());
    return sc;
}