提交 8be277a2 authored 作者: mysinmyc's avatar mysinmyc

handling issues when authenticator not set

上级 72e7f15f
...@@ -1990,7 +1990,20 @@ public class ErrorCode { ...@@ -1990,7 +1990,20 @@ public class ErrorCode {
*/ */
public static final int ROW_NOT_FOUND_IN_PRIMARY_INDEX = 90143; public static final int ROW_NOT_FOUND_IN_PRIMARY_INDEX = 90143;
// next are 90122, 90144 /**
* The error with code <code>90144</code> is thrown when
* user trying to login into a database with AUTHREALM set and
* the target database doesn't have an authenticator defined
* <p>Authenticator experimental feature can be enabled by
* </p>
* <pre>
* SET AUTHENTICATOR TRUE
* </pre>
*/
public static final int AUTHENTICATOR_NOT_AVAILABLE = 90144;
// next are 90122, 90145
private ErrorCode() { private ErrorCode() {
// utility class // utility class
......
...@@ -93,7 +93,6 @@ public class Engine implements SessionFactory { ...@@ -93,7 +93,6 @@ public class Engine implements SessionFactory {
} }
if (user == null) { if (user == null) {
if (database.validateFilePasswordHash(cipher, ci.getFilePasswordHash())) { if (database.validateFilePasswordHash(cipher, ci.getFilePasswordHash())) {
if (ci.getProperty("AUTHREALM")== null) { if (ci.getProperty("AUTHREALM")== null) {
user = database.findUser(ci.getUserName()); user = database.findUser(ci.getUserName());
if (user != null) { if (user != null) {
...@@ -102,21 +101,18 @@ public class Engine implements SessionFactory { ...@@ -102,21 +101,18 @@ public class Engine implements SessionFactory {
} }
} }
} else { } else {
try {
Authenticator authenticator = database.getAuthenticator(); Authenticator authenticator = database.getAuthenticator();
if (authenticator==null) { if (authenticator==null) {
DbException er = DbException.get(ErrorCode.WRONG_USER_OR_PASSWORD); throw DbException.get(ErrorCode.AUTHENTICATOR_NOT_AVAILABLE, name);
database.getTrace(Trace.DATABASE).error(er,"no authenticator for database users"); } else {
}else { try {
AuthenticationInfo authenticationInfo=new AuthenticationInfo(ci); AuthenticationInfo authenticationInfo=new AuthenticationInfo(ci);
user = database.getAuthenticator().authenticate(authenticationInfo, database); user = database.getAuthenticator().authenticate(authenticationInfo, database);
}
} catch (AuthenticationException authenticationError) { } catch (AuthenticationException authenticationError) {
database.getTrace(Trace.DATABASE).error(authenticationError, database.getTrace(Trace.DATABASE).error(authenticationError,
"an error occurred during authentication; user: \"" + "an error occurred during authentication; user: \"" +
ci.getUserName() + "\""); ci.getUserName() + "\"");
}finally { }
ci.cleanAuthenticationInfo();
} }
} }
} }
...@@ -133,6 +129,8 @@ public class Engine implements SessionFactory { ...@@ -133,6 +129,8 @@ public class Engine implements SessionFactory {
database.removeSession(null); database.removeSession(null);
throw er; throw er;
} }
//Prevent to set _PASSWORD
ci.cleanAuthenticationInfo();
checkClustering(ci, database); checkClustering(ci, database);
Session session = database.createSession(user); Session session = database.createSession(user);
if (session == null) { if (session == null) {
......
...@@ -174,6 +174,7 @@ ...@@ -174,6 +174,7 @@
90141=Serializer cannot be changed because there is a data table: {0} 90141=Serializer cannot be changed because there is a data table: {0}
90142=Step size must not be zero 90142=Step size must not be zero
90143=Row {1} not found in primary index {0} 90143=Row {1} not found in primary index {0}
90144=Athenticator not enabled on database {0}
HY000=General error: {0} HY000=General error: {0}
HY004=Unknown data type: {0} HY004=Unknown data type: {0}
HYC00=Feature not supported: {0} HYC00=Feature not supported: {0}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论