static void toJson(PfxOptions 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 PfxOptions(PfxOptions other) { super(); this.password = other.getPassword(); this.path = other.getPath(); this.value = other.getValue(); }
@Test public void testDefaultPKCS12OptionsJson() { PfxOptions def = new PfxOptions(); PfxOptions json = new PfxOptions(new JsonObject()); assertEquals(def.getPassword(), json.getPassword()); assertEquals(def.getPath(), json.getPath()); assertEquals(def.getValue(), json.getValue()); }
return null; return new KeyStoreHelper(loadJKSOrPKCS12("PKCS12", pkcs12.getPassword(), value), pkcs12.getPassword()); } else if (options instanceof PemKeyCertOptions) { PemKeyCertOptions keyCert = (PemKeyCertOptions) options;
@Test public void testPKCS12OptionsJson() throws Exception { PfxOptions options = new PfxOptions(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 PfxOptions(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 testPKCS12Options() throws Exception { PfxOptions options = new PfxOptions(); 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 testCopyPKCS12Options() throws Exception { PfxOptions options = new PfxOptions(); 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 PfxOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new PfxOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }
static void toJson(PfxOptions 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 PfxOptions(PfxOptions other) { super(); this.password = other.getPassword(); this.path = other.getPath(); this.value = other.getValue(); }
@Test public void testDefaultPKCS12OptionsJson() { PfxOptions def = new PfxOptions(); PfxOptions json = new PfxOptions(new JsonObject()); assertEquals(def.getPassword(), json.getPassword()); assertEquals(def.getPath(), json.getPath()); assertEquals(def.getValue(), json.getValue()); }
return null; return new KeyStoreHelper(loadJKSOrPKCS12("PKCS12", pkcs12.getPassword(), value), pkcs12.getPassword()); } else if (options instanceof PemKeyCertOptions) { PemKeyCertOptions keyCert = (PemKeyCertOptions) options;
@Test public void testPKCS12OptionsJson() throws Exception { PfxOptions options = new PfxOptions(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 PfxOptions(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 testPKCS12Options() throws Exception { PfxOptions options = new PfxOptions(); 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 testCopyPKCS12Options() throws Exception { PfxOptions options = new PfxOptions(); 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 PfxOptions(options); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); options = new PfxOptions(options.toJson()); assertEquals(password, options.getPassword()); assertEquals(path, options.getPath()); assertEquals(value, options.getValue()); }
kpPassword = ((JksOptions) ksOptions).getPassword(); } else if (ksOptions instanceof PfxOptions) { kpPassword = ((PfxOptions) ksOptions).getPassword();