Example usage for org.apache.hadoop.security.ssl SSLFactory SSL_SERVER_CONF_KEY

List of usage examples for org.apache.hadoop.security.ssl SSLFactory SSL_SERVER_CONF_KEY

Introduction

In this page you can find the example usage for org.apache.hadoop.security.ssl SSLFactory SSL_SERVER_CONF_KEY.

Prototype

String SSL_SERVER_CONF_KEY

To view the source code for org.apache.hadoop.security.ssl SSLFactory SSL_SERVER_CONF_KEY.

Click Source Link

Usage

From source file:io.hops.hopsworks.common.security.BaseHadoopClientsService.java

License:Open Source License

@PostConstruct
public void init() {
    String confDir = settings.getHadoopConfDir();
    File coreSite = new File(confDir, "core-site.xml");
    if (!coreSite.exists()) {
        handleMissingConf("core-site.xml", confDir);
    }/*www.  j  a va  2 s . com*/

    Configuration conf = new Configuration();
    conf.addResource(new Path(coreSite.getAbsolutePath()));

    sslConf = new Configuration(false);
    String hadoopConfDir = settings.getHadoopConfDir();
    File serverSSLConf = new File(hadoopConfDir, conf.get(SSLFactory.SSL_SERVER_CONF_KEY, "ssl-server.xml"));
    sslConf.addResource(new Path(serverSSLConf.getAbsolutePath()));
    superKeystorePath = sslConf.get(FileBasedKeyStoresFactory.resolvePropertyName(SSLFactory.Mode.SERVER,
            FileBasedKeyStoresFactory.SSL_KEYSTORE_LOCATION_TPL_KEY));
    superKeystorePassword = sslConf.get(FileBasedKeyStoresFactory.resolvePropertyName(SSLFactory.Mode.SERVER,
            FileBasedKeyStoresFactory.SSL_KEYSTORE_PASSWORD_TPL_KEY));
    superTrustStorePath = sslConf.get(FileBasedKeyStoresFactory.resolvePropertyName(SSLFactory.Mode.SERVER,
            FileBasedKeyStoresFactory.SSL_TRUSTSTORE_LOCATION_TPL_KEY));
    superTrustStorePassword = sslConf.get(FileBasedKeyStoresFactory.resolvePropertyName(SSLFactory.Mode.SERVER,
            FileBasedKeyStoresFactory.SSL_TRUSTSTORE_PASSWORD_TPL_KEY));
    try {
        superuser = UserGroupInformation.getLoginUser().getUserName();
    } catch (IOException ex) {
        throw new IllegalStateException("Could not identify login user");
    }
}

From source file:io.hops.security.HopsUtil.java

License:Apache License

private static void writeSSLConf(Configuration sslConf, Configuration systemConf, File passwdFile)
        throws IOException {
    String filename = systemConf.get(SSLFactory.SSL_SERVER_CONF_KEY, "ssl-server.xml");
    // Workaround for testing
    String outputFile;//from w w w.  j av a2s  . c  o  m
    if (passwdFile.getParentFile() == null) {
        outputFile = filename;
    } else {
        outputFile = Paths.get(passwdFile.getParentFile().getAbsolutePath(), filename).toString();
    }

    try (FileWriter fw = new FileWriter(outputFile, false)) {
        sslConf.writeXml(fw);
        fw.flush();
    }
}