public static void toJson(JksOptions obj, java.util.Map<String, Object> json) { if (obj.getPassword() != null) { json.put("password", obj.getPassword()); } if (obj.getPath() != null) { json.put("path", obj.getPath()); } if (obj.getValue() != null) { json.put("value", java.util.Base64.getEncoder().encodeToString(obj.getValue().getBytes())); } } }
/** * Copy constructor * * @param other the options to copy */ public JksOptions(JksOptions other) { super(); this.password = other.getPassword(); this.path = other.getPath(); this.value = other.getValue(); }
@Test public void testDefaultJKSOptionsJson() { JksOptions def = new JksOptions(); JksOptions json = new JksOptions(new JsonObject()); assertEquals(def.getPassword(), json.getPassword()); assertEquals(def.getPath(), json.getPath()); assertEquals(def.getValue(), json.getValue()); }
@Test public void testJKSOptionsJson() throws Exception { JksOptions options = new JksOptions(new JsonObject()); assertEquals(null, options.getPassword()); assertEquals(null, options.getPath()); assertEquals(null, options.getValue()); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); String value = TestUtils.randomAlphaString(100); options = new JksOptions(new JsonObject(). put("password", password). put("path", path). put("value", value.getBytes())); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(Buffer.buffer(value), options.getValue()); }
return null; return new KeyStoreHelper(loadJKSOrPKCS12("JKS", jks.getPassword(), value), jks.getPassword()); } else if (options instanceof PfxOptions) { PfxOptions pkcs12 = (PfxOptions) options;
@Test public void testJKSOptions() throws Exception { JksOptions options = new JksOptions(); assertNull(options.getPath()); String randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setPath(randString)); assertEquals(randString, options.getPath()); assertNull(options.getPassword()); randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setPassword(randString)); assertEquals(randString, options.getPassword()); }
assertEquals(ssl, options.isSsl()); assertNotSame(keyStoreOptions, options.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) options.getKeyCertOptions()).getPassword()); assertEquals(ksPath, ((JksOptions) options.getKeyCertOptions()).getPath()); assertNotSame(trustStoreOptions, options.getTrustOptions()); assertEquals(tsPassword, ((JksOptions) options.getTrustOptions()).getPassword()); assertEquals(tsPath, ((JksOptions) options.getTrustOptions()).getPath()); assertEquals(1, options.getEnabledCipherSuites().size());
assertEquals(ssl, options.isSsl()); assertNotSame(keyStoreOptions, options.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) options.getKeyCertOptions()).getPassword()); assertEquals(ksPath, ((JksOptions) options.getKeyCertOptions()).getPath()); assertNotSame(trustStoreOptions, options.getTrustOptions()); assertEquals(tsPassword, ((JksOptions) options.getTrustOptions()).getPassword()); assertEquals(tsPath, ((JksOptions) options.getTrustOptions()).getPath()); assertEquals(1, options.getEnabledCipherSuites().size());
assertEquals(ssl, options.isSsl()); assertNotSame(keyStoreOptions, options.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) options.getKeyCertOptions()).getPassword()); assertEquals(ksPath, ((JksOptions) options.getKeyCertOptions()).getPath()); assertNotSame(trustStoreOptions, options.getTrustOptions()); assertEquals(tsPassword, ((JksOptions) options.getTrustOptions()).getPassword()); assertEquals(tsPath, ((JksOptions) options.getTrustOptions()).getPath()); assertEquals(1, options.getEnabledCipherSuites().size());
@Test public void testCopyJKSOptions() throws Exception { JksOptions options = new JksOptions(); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); Buffer value = Buffer.buffer(TestUtils.randomAlphaString(100)); options.setPassword(password); options.setPath(path); options.setValue(value); options = new JksOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new JksOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }
assertEquals(ssl, options.isSsl()); assertNotSame(keyStoreOptions, options.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) options.getKeyCertOptions()).getPassword()); assertEquals(ksPath, ((JksOptions) options.getKeyCertOptions()).getPath()); assertNotSame(trustStoreOptions, options.getTrustOptions()); assertEquals(tsPassword, ((JksOptions) options.getTrustOptions()).getPassword()); assertEquals(tsPath, ((JksOptions) options.getTrustOptions()).getPath()); assertEquals(1, options.getEnabledCipherSuites().size());
public static void toJson(JksOptions obj, java.util.Map<String, Object> json) { if (obj.getPassword() != null) { json.put("password", obj.getPassword()); } if (obj.getPath() != null) { json.put("path", obj.getPath()); } if (obj.getValue() != null) { json.put("value", java.util.Base64.getEncoder().encodeToString(obj.getValue().getBytes())); } } }
/** * Copy constructor * * @param other the options to copy */ public JksOptions(JksOptions other) { super(); this.password = other.getPassword(); this.path = other.getPath(); this.value = other.getValue(); }
assertEquals(ssl, copy.isSsl()); assertNotSame(keyStoreOptions, copy.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) copy.getKeyCertOptions()).getPassword()); assertNotSame(trustStoreOptions, copy.getTrustOptions()); assertEquals(tsPassword, ((JksOptions)copy.getTrustOptions()).getPassword()); assertEquals(1, copy.getEnabledCipherSuites().size()); assertTrue(copy.getEnabledCipherSuites().contains(enabledCipher));
assertEquals(ssl, copy.isSsl()); assertNotSame(keyStoreOptions, copy.getKeyCertOptions()); assertEquals(ksPassword, ((JksOptions) copy.getKeyCertOptions()).getPassword()); assertNotSame(trustStoreOptions, copy.getTrustOptions()); assertEquals(tsPassword, ((JksOptions)copy.getTrustOptions()).getPassword()); assertEquals(1, copy.getEnabledCipherSuites().size()); assertTrue(copy.getEnabledCipherSuites().contains(enabledCipher));
@Test public void testDefaultJKSOptionsJson() { JksOptions def = new JksOptions(); JksOptions json = new JksOptions(new JsonObject()); assertEquals(def.getPassword(), json.getPassword()); assertEquals(def.getPath(), json.getPath()); assertEquals(def.getValue(), json.getValue()); }
return null; return new KeyStoreHelper(loadJKSOrPKCS12("JKS", jks.getPassword(), value), jks.getPassword()); } else if (options instanceof PfxOptions) { PfxOptions pkcs12 = (PfxOptions) options;
@Test public void testJKSOptionsJson() throws Exception { JksOptions options = new JksOptions(new JsonObject()); assertEquals(null, options.getPassword()); assertEquals(null, options.getPath()); assertEquals(null, options.getValue()); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); String value = TestUtils.randomAlphaString(100); options = new JksOptions(new JsonObject(). put("password", password). put("path", path). put("value", value.getBytes())); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(Buffer.buffer(value), options.getValue()); }
@Test public void testJKSOptions() throws Exception { JksOptions options = new JksOptions(); assertNull(options.getPath()); String randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setPath(randString)); assertEquals(randString, options.getPath()); assertNull(options.getPassword()); randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setPassword(randString)); assertEquals(randString, options.getPassword()); }
@Test public void testCopyJKSOptions() throws Exception { JksOptions options = new JksOptions(); String password = TestUtils.randomAlphaString(100); String path = TestUtils.randomAlphaString(100); Buffer value = Buffer.buffer(TestUtils.randomAlphaString(100)); options.setPassword(password); options.setPath(path); options.setValue(value); options = new JksOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new JksOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }