简体   繁体   English

使用 Java 登录的小写字母用户无法连接到 Firebird 3.0

[英]Can't connect to Firebird 3.0 with user with small letters in login with Java

I connect with names in capital letters, but it does not want to connect with small letters in the login.我用大写字母连接名字,但它不想在登录时用小写字母连接。

Here is a small test这是一个小测试

String ENCODING = "WIN1251";
String CONNECTION_URL = "jdbc:firebirdsql:localhost:C:/ProgramData/test.FDB";
Properties properties = new Properties();
properties.setProperty("encoding", ENCODING);
properties.setProperty("roleName", "GUEST");
properties.setProperty("user", "smoll2");
properties.setProperty("password", "1234567a");
DriverManager.getConnection(CONNECTION_URL, properties);
java.sql.SQLInvalidAuthorizationSpecException: Your user name and password are not defined. Ask your database administrator to set up a Firebird login. [SQLState:28000, ISC error code:335544472]
    at org.firebirdsql.gds.ng.FbExceptionBuilder$Type$4.createSQLException(FbExceptionBuilder.java:572)
    at org.firebirdsql.gds.ng.FbExceptionBuilder.toFlatSQLException(FbExceptionBuilder.java:302)
    at org.firebirdsql.gds.ng.wire.AbstractWireOperations.readStatusVector(AbstractWireOperations.java:138)
    at org.firebirdsql.gds.ng.wire.AbstractWireOperations.processOperation(AbstractWireOperations.java:202)
    at org.firebirdsql.gds.ng.wire.AbstractWireOperations.readOperationResponse(AbstractWireOperations.java:161)
    at org.firebirdsql.gds.ng.wire.version13.V13WireOperations.authReceiveResponse(V13WireOperations.java:122)
    at org.firebirdsql.gds.ng.wire.version10.V10Database.authReceiveResponse(V10Database.java:569)
    at org.firebirdsql.gds.ng.wire.WireConnection.identify(WireConnection.java:309)
    at org.firebirdsql.gds.ng.wire.FbWireDatabaseFactory.performConnect(FbWireDatabaseFactory.java:51)
    at org.firebirdsql.gds.ng.wire.FbWireDatabaseFactory.connect(FbWireDatabaseFactory.java:39)
    at org.firebirdsql.gds.ng.wire.FbWireDatabaseFactory.connect(FbWireDatabaseFactory.java:32)
    at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:141)
    at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:550)
    at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:65)
    at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:124)
    at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:137)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)

There are basically four situations where this authentication error will happen:基本上有四种情况会发生此身份验证错误:

  1. The user does not exist or has the wrong password用户不存在或密码错误
  2. You created the user with a case-sensitive username, eg using CREATE USER "smoll2"... .您使用区分大小写的用户名创建了用户,例如使用CREATE USER "smoll2"...
  3. You created the user with the Legacy_UserManager, and are using Jaybird 4, which by default no longer authenticates with Legacy_Auth您使用 Legacy_UserManager 创建了用户,并且使用的是 Jaybird 4,默认情况下不再使用 Legacy_Auth 进行身份验证
  4. The user is marked inactive用户被标记为非活动

I assume case 1 doesn't apply here, but otherwise you need to create the user or change its password.我假设案例 1 不适用于此处,否则您需要创建用户或更改其密码。

For case 2, it is important to realise that - since Firebird 3.0 - usernames are identifiers, and follow the same rules as identifiers.对于案例 2,重要的是要意识到 - 因为 Firebird 3.0 - 用户名是标识符,并且遵循与标识符相同的规则。 Which means unquoted names are stored in uppercase, and match case-insensitively (by means of uppercasing), while quoted names are stored exactly and are compared as is.这意味着未引用的名称以大写形式存储,并且不区分大小写匹配(通过大写),而引用的名称被精确存储并按原样进行比较。 If you created the user case-sensitively ( CREATE USER "smoll2"... ), then you need to authenticate with a quoted user name:如果您创建的用户区分大小写( CREATE USER "smoll2"... ),那么您需要使用带引号的用户名进行身份验证:

properties.setProperty("user", "\"smoll2\"");

If you don't do this, you are actually authenticating against the user SMOLL2 (which doesn't exist).如果您不这样做,您实际上是针对用户 SMOLL2(不存在)进行身份验证。

For case 3, since Firebird 3.0, Firebird provides multiple authentication plugins with accompanying user managers.对于案例 3,从 Firebird 3.0 开始,Firebird 提供了多个身份验证插件以及随附的用户管理器。 Users exist per user manager.每个用户管理器都存在用户。 Since Jaybird 4, Jaybird by default only authenticates with plugins Srp256 and Srp (which share the Srp user manager).从 Jaybird 4 开始,Jaybird 默认只使用插件 Srp256 和 Srp(共享 Srp 用户管理器)进行身份验证。 If you created your user with the Legacy_UserManager (either because it is the first configured in UserManager in firebird.conf, or because you used the using plugin Legacy_UserManager clause when creating the user), you cannot authenticate with the default settings of Jaybird, because it doesn't try the Legacy_Auth user plugin.如果您使用 Legacy_UserManager 创建用户(因为它是 firebird.conf 中UserManager中的第一个配置,或者因为您在创建用户时使用了using plugin Legacy_UserManager子句),您无法使用 Jaybird 的默认设置进行身份验证,因为它不尝试 Legacy_Auth 用户插件。

There are two solutions for this case:这种情况有两种解决方案:

  1. Drop the user with the Legacy_UserManager and create it with the Srp user manager使用 Legacy_UserManager 删除用户并使用 Srp 用户管理器创建它

  2. Configure Jaybird to also try Legacy_Auth:将 Jaybird 配置为也尝试 Legacy_Auth:

     properties.setProperty("authPlugins", "Srp256,Srp,Legacy_Auth");

    If you only want to try Legacy_Auth, you can remove Srp256 and Srp from the list.如果您只想尝试 Legacy_Auth,您可以从列表中删除 Srp256 和 Srp。

As a variation of case 3, this can also occur if you have a custom user manager and authentication plugin which is not supported by Jaybird.作为案例 3 的变体,如果您有 Jaybird 不支持的自定义用户管理器和身份验证插件,也会发生这种情况。

Finally case 4, a user can be inactive (either because it was created with the INACTIVE clause, or altered to inactive).最后是第 4 种情况,用户可能处于非活动状态(因为它是使用INACTIVE子句创建的,或者被更改为非活动状态)。 An inactive user is not allowed to authenticate.不允许非活动用户进行身份验证。 The inactive state is ignored for Legacy_UserManager/Legacy_Auth. Legacy_UserManager/Legacy_Auth 忽略不活动的 state。 If a user is inactive, you can activate it again with:如果用户处于非活动状态,您可以通过以下方式再次激活它:

alter user smoll2 set active

Be aware that it could also be a combination of 2 and 3 (using a case-sensitive username and Legacy_UserManager).请注意,它也可以是 2 和 3 的组合(使用区分大小写的用户名Legacy_UserManager)。 You can verify which user you have, if it is active, and for which user manager, by executing the following query as SYSDBA or a user with RDB$ADMIN role in the current database and the security database:您可以通过在当前数据库和安全数据库中以 SYSDBA 或具有 RDB$ADMIN 角色的用户身份执行以下查询来验证您拥有的用户(如果它是活动的)以及哪个用户管理器:

select sec$user_name, sec$active, sec$plugin from sec$users;

For Legacy_UserManager, the SEC$ACTIVE column is NULL, as it doesn't support the active/inactive state.对于 Legacy_UserManager, SEC$ACTIVE列是 NULL,因为它不支持活动/非活动 state。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM