Unverified 提交 4737951c authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #1191 from mysinmyc/fix_datasource

External authentication with datasource issue
......@@ -276,7 +276,7 @@ public class ConnectionInfo implements Cloneable {
private void preservePasswordForAuthentication(Object password) {
if ((!isRemote() || isSSL()) && prop.containsKey("AUTHREALM") && password!=null) {
prop.put("AUTHZPWD",password);
prop.put("AUTHZPWD",password instanceof char[] ? new String((char[])password) : password);
}
}
......
......@@ -15,6 +15,7 @@ import java.util.UUID;
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
import javax.security.auth.login.Configuration;
import javax.sql.DataSource;
import org.h2.engine.ConnectionInfo;
import org.h2.engine.Database;
......@@ -22,6 +23,7 @@ import org.h2.engine.Engine;
import org.h2.engine.Role;
import org.h2.engine.Session;
import org.h2.engine.User;
import org.h2.jdbcx.JdbcConnectionPool;
import org.h2.security.auth.DefaultAuthenticator;
import org.h2.security.auth.impl.AssignRealmNameRole;
import org.h2.security.auth.impl.JaasCredentialsValidator;
......@@ -128,6 +130,7 @@ public class TestAuthentication extends TestBase {
testStaticUserCredentials();
testUserRegistration();
testSet();
testDatasource();
}
protected void testInvalidPassword() throws Exception {
......@@ -162,6 +165,20 @@ public class TestAuthentication extends TestBase {
}
}
protected void testDatasource() throws Exception {
DataSource dataSource = JdbcConnectionPool.create(
getDatabaseURL() + ";AUTHREALM=" + getRealmName().toUpperCase(), getExternalUser(),
getExternalUserPassword());
Connection rightConnection = dataSource.getConnection();
try {
User user = session.getDatabase().findUser((getExternalUser() + "@" + getRealmName()).toUpperCase());
assertNotNull(user);
} finally {
rightConnection.close();
}
}
protected void testAssignRealNameRole() throws Exception {
String realmNameRoleName = "@" + getRealmName().toUpperCase();
Role realmNameRole = database.findRole(realmNameRoleName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论