Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
[#486][resolves #504]

Signed-off-by: Mark Paluch <[email protected]>
  • Loading branch information
mp911de committed Apr 6, 2022
1 parent dc18841 commit 2710606
Showing 1 changed file with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public final class PostgresqlConnectionFactoryProvider implements ConnectionFact

/**
* Ssl mode alias (JDBC style). Default: disabled
*
* @since 0.8.13
*/
public static final Option<SSLMode> SSL_MODE_ALIAS = Option.valueOf("sslmode");

Expand Down Expand Up @@ -285,25 +287,8 @@ private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder,
}
});

mapper.from(SSL_MODE).map(it -> {

if (it instanceof String) {
return SSLMode.fromValue(it.toString());
}

return (SSLMode) it;

}).to(builder::sslMode).otherwise(() -> {

mapper.from(SSL_MODE_ALIAS).map(it -> {

if (it instanceof String) {
return SSLMode.fromValue(it.toString());
}

return (SSLMode) it;

}).to(builder::sslMode);
mapper.from(SSL_MODE).map(PostgresqlConnectionFactoryProvider::toSSLMode).to(builder::sslMode).otherwise(() -> {
mapper.from(SSL_MODE_ALIAS).map(PostgresqlConnectionFactoryProvider::toSSLMode).to(builder::sslMode);
});

mapper.from(SSL_CERT).to(builder::sslCert);
Expand All @@ -330,6 +315,14 @@ private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder,
}).to(builder::sslHostnameVerifier);
}

private static SSLMode toSSLMode(Object it) {
if (it instanceof String) {
return SSLMode.fromValue(it.toString());
}

return (SSLMode) it;
}

@SuppressWarnings("unchecked")
private static Map<String, String> convertToMap(Object options) {
if (options instanceof Map) {
Expand Down

0 comments on commit 2710606

Please sign in to comment.