keystoreWrapper = KeystoreWrapper.newStore().build(); outputStream = openWrite(); keystoreWrapper.saveKeystore(outputStream); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); for (String entry : keystoreWrapper.listEntries()) { prompt.println(entry); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) && force == false) { boolean proceed = promptYesNo("Setting %s already exists. Overwrite? [y/N]", arg); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) == false) { prompt.printf("ERROR: Setting [%s] does not exist in the keystore.%n", arg);
keystoreWrapper = KeystoreWrapper.newStore().build(); outputStream = openWrite(); keystoreWrapper.saveKeystore(outputStream); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); for (String entry : keystoreWrapper.listEntries()) { prompt.println(entry); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) && force == false) { boolean proceed = promptYesNo("Setting %s already exists. Overwrite? [y/N]", arg); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) == false) { prompt.printf("ERROR: Setting [%s] does not exist in the keystore.%n", arg);
keystoreWrapper = KeystoreWrapper.newStore().build(); outputStream = openWrite(); keystoreWrapper.saveKeystore(outputStream); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); for (String entry : keystoreWrapper.listEntries()) { prompt.println(entry); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) && force == false) { boolean proceed = promptYesNo("Setting %s already exists. Overwrite? [y/N]", arg); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) == false) { prompt.printf("ERROR: Setting [%s] does not exist in the keystore.%n", arg);
keystoreWrapper = KeystoreWrapper.newStore().build(); outputStream = openWrite(); keystoreWrapper.saveKeystore(outputStream); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); for (String entry : keystoreWrapper.listEntries()) { prompt.println(entry); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) && force == false) { boolean proceed = promptYesNo("Setting %s already exists. Overwrite? [y/N]", arg); keystoreWrapper = KeystoreWrapper.loadStore(inputStream).build(); if (keystoreWrapper.containsEntry(arg) == false) { prompt.printf("ERROR: Setting [%s] does not exist in the keystore.%n", arg);
public SecureSettings(Settings settings) { this.settings = settings; String keystoreLocation = settings.getProperty(ConfigurationOptions.ES_KEYSTORE_LOCATION); if (keystoreLocation != null) { KeystoreBuilder builder = KeystoreWrapper.loadStore(keystoreLocation); try { this.keystoreWrapper = builder.build(); } catch (EsHadoopSecurityException e) { throw new EsHadoopException("Could not load keystore", e); } catch (IOException e) { throw new EsHadoopException("Could not load keystore", e); } } else { this.keystoreWrapper = null; } }
public SecureSettings(Settings settings) { this.settings = settings; String keystoreLocation = settings.getProperty(ConfigurationOptions.ES_KEYSTORE_LOCATION); if (keystoreLocation != null) { KeystoreBuilder builder = KeystoreWrapper.loadStore(keystoreLocation); try { this.keystoreWrapper = builder.build(); } catch (EsHadoopSecurityException e) { throw new EsHadoopException("Could not load keystore", e); } catch (IOException e) { throw new EsHadoopException("Could not load keystore", e); } } else { this.keystoreWrapper = null; } }
public SecureSettings(Settings settings) { this.settings = settings; String keystoreLocation = settings.getProperty(ConfigurationOptions.ES_KEYSTORE_LOCATION); if (keystoreLocation != null) { KeystoreBuilder builder = KeystoreWrapper.loadStore(keystoreLocation); try { this.keystoreWrapper = builder.build(); } catch (EsHadoopSecurityException e) { throw new EsHadoopException("Could not load keystore", e); } catch (IOException e) { throw new EsHadoopException("Could not load keystore", e); } } else { this.keystoreWrapper = null; } }
public static KeystoreBuilder newStore() { return new KeystoreBuilder(); }
public static KeystoreBuilder loadStore(String path) { return new KeystoreBuilder(path); }
public static KeystoreBuilder loadStore(InputStream stream) { return new KeystoreBuilder(stream); }
public static KeystoreBuilder loadStore(String path) { return new KeystoreBuilder(path); }
public static KeystoreBuilder newStore() { return new KeystoreBuilder(); }
public static KeystoreBuilder loadStore(InputStream stream) { return new KeystoreBuilder(stream); }
public static KeystoreBuilder loadStore(String path) { return new KeystoreBuilder(path); }
public static KeystoreBuilder newStore() { return new KeystoreBuilder(); }
public static KeystoreBuilder loadStore(InputStream stream) { return new KeystoreBuilder(stream); }
@Test public void listKeystore() throws Exception { BytesArray storeData = new BytesArray(128); KeystoreWrapper ks = KeystoreWrapper.newStore().build(); ks.setSecureSetting("test.password.1", "blah"); ks.setSecureSetting("test.password.2", "blah"); ks.saveKeystore(new FastByteArrayOutputStream(storeData)); TestPrompt console = new TestPrompt(); KeytoolHarness keytool = new KeytoolHarness(console, Keytool.Command.LIST, true, storeData); assertThat(keytool.run(null, false, false), equalTo(0)); assertThat( console.getOutput(), equalTo( "test.password.1\n" + "test.password.2\n" ) ); assertThat(console.hasInputLeft(), is(false)); assertThat(keytool.ksExists(), is(true)); assertThat(keytool.fileBytes.length(), is(not(0))); }
@Test public void removeKey() throws Exception { BytesArray storeData = new BytesArray(128); KeystoreWrapper ks = KeystoreWrapper.newStore().build(); ks.setSecureSetting("test.password.1", "bar"); ks.setSecureSetting("test.password.2", "foo"); ks.saveKeystore(new FastByteArrayOutputStream(storeData)); TestPrompt console = new TestPrompt(); KeytoolHarness keytool = new KeytoolHarness(console, Keytool.Command.REMOVE, true, storeData); assertThat(keytool.run("test.password.1", false, false), equalTo(0)); assertThat(console.getOutput(), equalTo("")); assertThat(console.hasInputLeft(), is(false)); assertThat(keytool.ksExists(), is(true)); assertThat(keytool.fileBytes.length(), is(not(0))); ks = KeystoreWrapper.loadStore(new FastByteArrayInputStream(keytool.fileBytes)).build(); assertThat(ks.containsEntry("test.password.1"), is(false)); assertThat(ks.getSecureSetting("test.password.2"), equalTo("foo")); }
@Test public void addExistingKeyForce() throws Exception { BytesArray storeData = new BytesArray(128); KeystoreWrapper ks = KeystoreWrapper.newStore().build(); ks.setSecureSetting("test.password.1", "blah"); ks.saveKeystore(new FastByteArrayOutputStream(storeData)); TestPrompt console = new TestPrompt(); console.addInput("blerb"); KeytoolHarness keytool = new KeytoolHarness(console, Keytool.Command.ADD, true, storeData); assertThat(keytool.run("test.password.1", false, true), equalTo(0)); assertThat(console.getOutput(), equalTo("")); assertThat(console.hasInputLeft(), is(false)); assertThat(keytool.ksExists(), is(true)); assertThat(keytool.fileBytes.length(), is(not(0))); ks = KeystoreWrapper.loadStore(new FastByteArrayInputStream(keytool.fileBytes)).build(); assertThat(ks.getSecureSetting("test.password.1"), equalTo("blerb")); }
@Test public void addExistingKeyOverwrite() throws Exception { BytesArray storeData = new BytesArray(128); KeystoreWrapper ks = KeystoreWrapper.newStore().build(); ks.setSecureSetting("test.password.1", "blah"); ks.saveKeystore(new FastByteArrayOutputStream(storeData)); TestPrompt console = new TestPrompt(); console.addInput("y").addInput("blerb"); KeytoolHarness keytool = new KeytoolHarness(console, Keytool.Command.ADD, true, storeData); assertThat(keytool.run("test.password.1", false, false), equalTo(0)); assertThat(console.getOutput(), equalTo("")); assertThat(console.hasInputLeft(), is(false)); assertThat(keytool.ksExists(), is(true)); assertThat(keytool.fileBytes.length(), is(not(0))); ks = KeystoreWrapper.loadStore(new FastByteArrayInputStream(keytool.fileBytes)).build(); assertThat(ks.getSecureSetting("test.password.1"), equalTo("blerb")); }