Search in sources :

Example 1 with ApiMain

use of org.dataportabilityproject.gateway.ApiMain in project data-transfer-project by google.

the class SingleVMMain method initializeGateway.

public void initializeGateway() {
    ApiMain apiMain = new ApiMain();
    try (InputStream stream = ReferenceApiServer.class.getClassLoader().getResourceAsStream("demo-selfsigned-keystore.jks")) {
        if (stream == null) {
            throw new IllegalArgumentException("Demo keystore was not found");
        }
        // initialise the keystore
        char[] password = "password".toCharArray();
        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(stream, password);
        KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
        keyManagerFactory.init(keyStore, password);
        TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509");
        trustManagerFactory.init(keyStore);
        apiMain.initializeHttps(trustManagerFactory, keyManagerFactory);
        apiMain.start();
    } catch (Exception e) {
        errorCallback.accept(e);
    }
}
Also used : InputStream(java.io.InputStream) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) ApiMain(org.dataportabilityproject.gateway.ApiMain) KeyStore(java.security.KeyStore) ReferenceApiServer(org.dataportabilityproject.gateway.reference.ReferenceApiServer) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Aggregations

InputStream (java.io.InputStream)1 KeyStore (java.security.KeyStore)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1 ApiMain (org.dataportabilityproject.gateway.ApiMain)1 ReferenceApiServer (org.dataportabilityproject.gateway.reference.ReferenceApiServer)1