/** * Copies TLS key & certificate configuration to a given set of server options. * <p> * If <em>config</em> contains key & certificate configuration it is added to * the given server options and the <em>ssl</em> flag is set to {@code true}. * * @param serverOptions The options to add configuration to. */ protected final void addTlsKeyCertOptions(final NetServerOptions serverOptions) { KeyCertOptions keyCertOptions = getConfig().getKeyCertOptions(); if (keyCertOptions != null) { serverOptions.setSsl(true).setKeyCertOptions(keyCertOptions); } }
private void addTlsKeyCertOptions(final ProtonClientOptions clientOptions) { if (clientOptions.getKeyCertOptions() == null) { KeyCertOptions keyCertOptions = config.getKeyCertOptions(); if (keyCertOptions != null) { clientOptions.setSsl(true).setKeyCertOptions(keyCertOptions); clientOptions.addEnabledSaslMechanism(ProtonSaslExternalImpl.MECH_NAME); } } }
/** * Test a valid PFX configuration. */ @Test public void testPfxConfig() { final TestConfig cfg = new TestConfig(); cfg.setKeyStorePath(PREFIX_KEY_PATH + "honoKeyStore.p12"); cfg.setKeyStorePassword("honokeys"); final KeyCertOptions options = cfg.getKeyCertOptions(); Assert.assertNotNull(options); Assert.assertThat(options, instanceOf(PfxOptions.class)); }
/** * Test a valid PEM configuration. */ @Test public void testPemConfig() { final TestConfig cfg = new TestConfig(); cfg.setKeyPath(PREFIX_KEY_PATH + "hono-messaging-key.pem"); cfg.setCertPath(PREFIX_KEY_PATH + "hono-messaging-cert.pem"); final KeyCertOptions options = cfg.getKeyCertOptions(); Assert.assertNotNull(options); Assert.assertThat(options, instanceOf(PemKeyCertOptions.class)); }
/** * Specify key and cert, but override type PKCS12. */ @Test public void testInvalidConfig1() { final TestConfig cfg = new TestConfig(); cfg.setKeyPath(PREFIX_KEY_PATH + "hono-messaging-key.pem"); cfg.setCertPath(PREFIX_KEY_PATH + "hono-messaging-cert.pem"); cfg.setKeyFormat(FileFormat.PKCS12); final KeyCertOptions options = cfg.getKeyCertOptions(); Assert.assertNull(options); }
/** * Specify a keystore, but override type PEM. */ @Test public void testInvalidConfig2() { final TestConfig cfg = new TestConfig(); cfg.setKeyStorePath(PREFIX_KEY_PATH + "honoKeyStore.p12"); cfg.setKeyStorePassword("honokeys"); cfg.setKeyFormat(FileFormat.PEM); final KeyCertOptions options = cfg.getKeyCertOptions(); Assert.assertNull(options); }
@Override public KeyCertOptions clone() { return this; // I ask for forgiveness }
@Override public PgConnectOptions setKeyCertOptions(KeyCertOptions options) { return (PgConnectOptions)super.setKeyCertOptions(options); }
public TrustAndKeyProvider(TrustOptions trust, KeyCertOptions keyCert) { this.trust = trust; this.keyCert = keyCert; }
/** * @return key and cert options for the wrapped provider implementation. */ public KeyCertOptions keyCertOptions() { return keyCert; }
@Override public MqttServerOptions setKeyCertOptions(KeyCertOptions options) { super.setKeyCertOptions(options); return this; }
@Override public MqttClientOptions setKeyCertOptions(KeyCertOptions options) { super.setKeyCertOptions(options); return this; }
/** * @return the key pair options */ @GenIgnore public KeyCertOptions getKeyPairOptions() { return keyPairOptions; }
@Override public AmqpBridgeOptions setKeyCertOptions(KeyCertOptions options) { super.setKeyCertOptions(options); return this; }
@Override public ProtonServerOptions setKeyCertOptions(KeyCertOptions options) { super.setKeyCertOptions(options); return this; }
@Override public ProtonClientOptions setKeyCertOptions(KeyCertOptions options) { super.setKeyCertOptions(options); return this; }
@Override public WebClientOptions setKeyCertOptions(KeyCertOptions options) { return (WebClientOptions) super.setKeyCertOptions(options); }