@CustomFormAuthenticationMechanismDefinition
我花了几天时间将自己更新到 Java EE 8,我在使用和@DatabaseIdentityStoreDefinition
一起使用时遇到了一个问题。
我正在使用 Glassfish v5、NetBeans 9 nightly 和 Java 8。
我所做的只是想更新security-soteria(Java EE Security 1.0 RI)测试文件夹中的app-mem-customform 示例,而我所做的更改是用于替换基于内存的 dummy 。@DatabaseIdentityStoreDefinition
IdentityStore
当我启动应用程序并尝试登录时,从 NetBeans 控制台获得了以下信息。
Info: Activating javax.security.enterprise.identitystore.DatabaseIdentityStoreDefinition identity store from com.hantsylabs.example.ee8.security.ApplicationConfig class
Info: Activating javax.security.enterprise.authentication.mechanism.http.CustomFormAuthenticationMechanismDefinition authentication mechanism from com.hantsylabs.example.ee8.security.ApplicationConfig class
Warning: RAR8705: Invalid value for property dynamic-reconfiguration-wait-timeout-in-seconds : null
Info: initializing database...
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: RAR7115: Unable to set ClientInfo for connection
Info: Initializing Soteria 1.0 for context '/security-custom-form-db'
Info: Registering WebSocket filter for url pattern /*
Info: Initializing Mojarra 2.3.2 ( 20170627-2139 e63598abf2ed2bb1a24674f308a734e0dce18a72) for context '/security-custom-form-db'
Info: Monitoring jndi:/server/security-custom-form-db/WEB-INF/faces-config.xml for modifications
Info: Loading application [_Security_1.0:_Custom_Form_Authentication_with__DatabaseIdentityStoreDefinition] at [/security-custom-form-db]
Info: _Security_1.0:_Custom_Form_Authentication_with__DatabaseIdentityStoreDefinition was successfully deployed in 3,288 milliseconds.
Warning: RAR8705: Invalid value for property dynamic-reconfiguration-wait-timeout-in-seconds : null
Info: RAR7115: Unable to set ClientInfo for connection
Info: authentication result:NOT_DONE
信息:身份验证结果: 来自我的未完成LoginBean
,打印返回的 AuthenticationStatus
.
我的安全配置文件是:
@CustomFormAuthenticationMechanismDefinition(
loginToContinue = @LoginToContinue(
loginPage = "/login.faces",
errorPage = "" // DRAFT API - must be set to empty for now
)
)
@DatabaseIdentityStoreDefinition(
dataSourceLookup = "${'java:global/MyDS'}",
callerQuery = "#{'select password from caller where name = ?'}",
groupsQuery = "select group_name from caller_groups where caller_name = ?",
hashAlgorithm = Pbkdf2PasswordHash.class,
priorityExpression = "#{100}",
hashAlgorithmParameters = {
"Pbkdf2PasswordHash.Iterations=3072",
"${applicationConfig.dyna}"
} // just for test / example
)
@ApplicationScoped
@Named
public class ApplicationConfig {
public String[] getDyna() {
return new String[]{"Pbkdf2PasswordHash.Algorithm=PBKDF2WithHmacSHA512", "Pbkdf2PasswordHash.SaltSizeBytes=64"};
}
}
我还包括DatabaseSetup
在应用程序启动时插入用户。该文件是从app-db sample复制的。
我的完整代码可以在这里找到。
@CustomFormAuthenticationMechanismDefinition
在项目中使用和@DatabaseIdentityStoreDefinition
无缝的正确方法是什么?
更新,我刚刚尝试使用@FormAuthenticationMechanismDefinition
,@DatabaseIdentityStoreDefinition
它有效,代码在这里。所以这是一个错误@CustomFormAuthenticationMechanismDefinition
。