/** * Create empty credentials with no certificates. * * @return empty credentials. */ public static ClientCertificateCredentials empty() { return newBuilder().build(); }
/** * Create a new builder initialized with fields of this object. * * @return a new builder. */ public Builder toBuilder() { return new Builder().clientCertificate(clientCertificate).clientKey(clientKey); }
/** * Create an empty builder. * * @return a new builder. */ public static Builder newBuilder() { return new Builder(); }
/** * Build a new X.509 credentials. * * @return the credentials. */ public ClientCertificateCredentials build() { return new ClientCertificateCredentials(clientCertificate, clientKey); } }
@Override public <T> T accept(final CredentialsVisitor<T> visitor) { return visitor.clientCertificate(this); }
/** * Create an SSL context with trusted certificates without client authentication. * * @return the SSL context */ public SSLContext withoutClientCertificate() { return clientCertificate(ClientCertificateCredentials.empty()); }
/** * Sets the connection credentials in JSON representation. * * @param jsonObject credentials in JSON representation. * @return this builder. */ default ConnectionBuilder credentialsFromJson(final JsonObject jsonObject) { return credentials(Credentials.fromJson(jsonObject)); }
@Override public String toString() { return getClass().getSimpleName() + " [" + "hashCode=" + hashCode() + "]"; }
private static void validateFormatOfCertificates(final Connection connection, final DittoHeaders dittoHeaders) { final Optional<String> trustedCertificates = connection.getTrustedCertificates(); final Optional<Credentials> credentials = connection.getCredentials(); // check if there are certificates to check if (trustedCertificates.isPresent() || credentials.isPresent()) { credentials.orElseGet(ClientCertificateCredentials::empty) .accept(SSLContextCreator.fromConnection(connection, dittoHeaders)); } }
/** * Create empty credentials with no certificates. * * @return empty credentials. */ public static ClientCertificateCredentials empty() { return newBuilder().build(); }
/** * Create a new builder initialized with fields of this object. * * @return a new builder. */ public Builder toBuilder() { return new Builder().clientCertificate(clientCertificate).clientKey(clientKey); }
/** * Create an empty builder. * * @return a new builder. */ public static Builder newBuilder() { return new Builder(); }
/** * Build a new X.509 credentials. * * @return the credentials. */ public ClientCertificateCredentials build() { return new ClientCertificateCredentials(clientCertificate, clientKey); } }
@Override public <T> T accept(final CredentialsVisitor<T> visitor) { return visitor.clientCertificate(this); }
/** * Create an SSL context with trusted certificates without client authentication. * * @return the SSL context */ public SSLContext withoutClientCertificate() { return clientCertificate(ClientCertificateCredentials.empty()); }
/** * Sets the connection credentials in JSON representation. * * @param jsonObject credentials in JSON representation. * @return this builder. */ default ConnectionBuilder credentialsFromJson(final JsonObject jsonObject) { return credentials(Credentials.fromJson(jsonObject)); }
@Override public String toString() { return getClass().getSimpleName() + " [" + "hashCode=" + hashCode() + "]"; }
private static void validateFormatOfCertificates(final Connection connection, final DittoHeaders dittoHeaders) { final Optional<String> trustedCertificates = connection.getTrustedCertificates(); final Optional<Credentials> credentials = connection.getCredentials(); // check if there are certificates to check if (trustedCertificates.isPresent() || credentials.isPresent()) { credentials.orElseGet(ClientCertificateCredentials::empty) .accept(SSLContextCreator.fromConnection(connection, dittoHeaders)); } }
static ClientCertificateCredentials fromJson(final JsonObject jsonObject) { final Builder builder = newBuilder(); jsonObject.getValue(JsonFields.CLIENT_CERTIFICATE).ifPresent(builder::clientCertificate); jsonObject.getValue(JsonFields.CLIENT_KEY).ifPresent(builder::clientKey); return builder.build(); }
static ClientCertificateCredentials fromJson(final JsonObject jsonObject) { final Builder builder = newBuilder(); jsonObject.getValue(JsonFields.CLIENT_CERTIFICATE).ifPresent(builder::clientCertificate); jsonObject.getValue(JsonFields.CLIENT_KEY).ifPresent(builder::clientKey); return builder.build(); }