forked from pgjdbc/pgjdbc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuthenticationPluginManager.java
32 lines (25 loc) · 1.01 KB
/
AuthenticationPluginManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* Copyright (c) 2021, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
package org.postgresql.core;
import org.postgresql.PGProperty;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
public class AuthenticationPluginManager {
private static final Logger LOGGER = Logger.getLogger(AuthenticationPluginManager.class.getName());
public static AuthenticationPlugin getAuthenticationPlugin(Properties info) throws Exception {
String authenticationClassName = PGProperty.AUTHENTICATION_PLUGIN_CLASS_NAME.getSetString(info);
if ( authenticationClassName == null ) {
return new PasswordAuthentication();
} else {
try {
return (AuthenticationPlugin) Class.forName(authenticationClassName).getDeclaredConstructor().newInstance();
} catch (Exception ex ) {
LOGGER.log(Level.FINE, "Unable to load Authentication Plugin" + ex.getMessage() );
throw ex;
}
}
}
}