提交 546c50f7 authored 作者: mysinmyc's avatar mysinmyc

fix datasource login failures

上级 17400f7b
...@@ -276,7 +276,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -276,7 +276,7 @@ public class ConnectionInfo implements Cloneable {
private void preservePasswordForAuthentication(Object password) { private void preservePasswordForAuthentication(Object password) {
if ((!isRemote() || isSSL()) && prop.containsKey("AUTHREALM") && password!=null) { 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; ...@@ -15,6 +15,7 @@ import java.util.UUID;
import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
import javax.security.auth.login.Configuration; import javax.security.auth.login.Configuration;
import javax.sql.DataSource;
import org.h2.engine.ConnectionInfo; import org.h2.engine.ConnectionInfo;
import org.h2.engine.Database; import org.h2.engine.Database;
...@@ -22,6 +23,7 @@ import org.h2.engine.Engine; ...@@ -22,6 +23,7 @@ import org.h2.engine.Engine;
import org.h2.engine.Role; import org.h2.engine.Role;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.User; import org.h2.engine.User;
import org.h2.jdbcx.JdbcConnectionPool;
import org.h2.security.auth.DefaultAuthenticator; import org.h2.security.auth.DefaultAuthenticator;
import org.h2.security.auth.impl.AssignRealmNameRole; import org.h2.security.auth.impl.AssignRealmNameRole;
import org.h2.security.auth.impl.JaasCredentialsValidator; import org.h2.security.auth.impl.JaasCredentialsValidator;
...@@ -128,6 +130,7 @@ public class TestAuthentication extends TestBase { ...@@ -128,6 +130,7 @@ public class TestAuthentication extends TestBase {
testStaticUserCredentials(); testStaticUserCredentials();
testUserRegistration(); testUserRegistration();
testSet(); testSet();
testDatasource();
} }
protected void testInvalidPassword() throws Exception { protected void testInvalidPassword() throws Exception {
...@@ -162,6 +165,20 @@ public class TestAuthentication extends TestBase { ...@@ -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 { protected void testAssignRealNameRole() throws Exception {
String realmNameRoleName = "@" + getRealmName().toUpperCase(); String realmNameRoleName = "@" + getRealmName().toUpperCase();
Role realmNameRole = database.findRole(realmNameRoleName); Role realmNameRole = database.findRole(realmNameRoleName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论