Skip to content
Permalink
Browse files

[CONJ-742] ensure plugin using Driver classloader

  • Loading branch information
rusher committed Oct 30, 2019
1 parent ed382fa commit 4e0705bb306a5f7efef222c6886e3a561b13ab60
@@ -22,11 +22,16 @@

package org.mariadb.jdbc.authentication;

import org.mariadb.jdbc.Driver;

import java.sql.*;
import java.util.*;

public class AuthenticationPluginLoader {

private static ServiceLoader<AuthenticationPlugin> loader =
ServiceLoader.load(AuthenticationPlugin.class, Driver.class.getClassLoader());

/**
* Get authentication plugin from type String. Customs authentication plugin can be added
* implementing AuthenticationPlugin and registering new type in resources services.
@@ -39,16 +44,16 @@ public static AuthenticationPlugin get(String type) throws SQLException {
if (type == null || type.isEmpty()) {
return null;
}
ServiceLoader<AuthenticationPlugin> loader = ServiceLoader.load(AuthenticationPlugin.class);

for (AuthenticationPlugin implClass : loader) {
if (type.equals(implClass.type())) {
return implClass;
}
}
throw new SQLException(
"Client does not support authentication protocol requested by server. "
+ "plugin type was = "
+ type,
+ "plugin type was = '"
+ type + "'",
"08004",
1251);
}
@@ -21,6 +21,8 @@

package org.mariadb.jdbc.credential;

import org.mariadb.jdbc.Driver;

import java.sql.*;
import java.util.*;

@@ -30,6 +32,9 @@
*/
public class CredentialPluginLoader {

private static ServiceLoader<CredentialPlugin> loader =
ServiceLoader.load(CredentialPlugin.class, Driver.class.getClassLoader());

/**
* Get current Identity plugin according to option `identityType`.
*
@@ -41,7 +46,7 @@ public static CredentialPlugin get(String type) throws SQLException {
if (type == null || type.isEmpty()) {
return null;
}
ServiceLoader<CredentialPlugin> loader = ServiceLoader.load(CredentialPlugin.class);

for (CredentialPlugin implClass : loader) {
if (type.equals(implClass.type())) {
return implClass;

0 comments on commit 4e0705b

Please sign in to comment.
You can’t perform that action at this time.