如何从环境属性/ Payara容器读取@LdapIdentityStoreDefinition的bindDnPassword值

设置LdapIdentityStoreDefinition属性如下:

@LdapIdentityStoreDefinition(
        url = "",bindDnPassword = "${ALIAS=somepassword}",// this is not working . 
        callerSearchBase = "",callerSearchFilter = "",groupSearchFilter = ""
)

在Payara服务器中创建别名somepasword,如下所示:

create-password-alias somepassword
Enter the alias password>
Enter the alias password again>
Command create-password-alias executed successfully.

正在运行的应用程序上出现异常:

 [2019-11-26T14:46:42.101-0500] [Payara 5.191] [WARNING] [] [javax.enterprise.system.container.web.com.sun.web.security] [tid: _ThreadID=29 _ThreadName=http-thread-pool::http-listener-1(2)] [timeMillis: 1574797602101] [levelValue: 900] [[
      JASPIC: http msg authentication fail
    javax.el.PropertyNotFoundException: ELResolver cannot handle a null base Object with identifier 'somepassword'
 at com.sun.el.lang.ELSupport.throwUnhandled(ELSupport.java:68)
        at com.sun.el.parser.AstIdentifier.getvalue(AstIdentifier.java:126)
        at com.sun.el.parser.AstAssign.getvalue(AstAssign.java:57)
        at com.sun.el.ValueExpressionImpl.getvalue(ValueExpressionImpl.java:226)
        at javax.el.ELProcessor.getvalue(ELProcessor.java:129)
wahaha1021 回答:如何从环境属性/ Payara容器读取@LdapIdentityStoreDefinition的bindDnPassword值

据我所知,您不能直接在@LdapIdentityStoreDefinition中使用环境属性。但是,可以通过Microprofile Config API解决此问题。

请参阅以下论坛主题以供参考:Product list category page with missing quantity selection and add to cart button at end.

,

@LdapIdentityStoreDefinition注释尝试将bindDnPassword的值解释为EL表达式。这与别名的Payara表达式冲突,并且为您提供了例外。

一种解决方法是定义一个引用别名的系统属性,然后从EL表达式中检索该系统属性。

例如您可以在Payara Server配置中指定使用以下asadmin命令引用别名的系统属性passwordproperty

create-system-properties --target=server-config passwordproperty=${ALIAS\=somepassword}

请记住,您必须定位配置,例如server-config。如果您定位实例(例如server),则不会评估别名。

在管理控制台中,您将在server-config -> System properties中定义属性。不在server (Admin Server) -> Properties -> System properties中,不会对别名进行评估。

然后您可以定义bindDnPassword = "${System.getProperty('passwordproperty')}",它将被评估为系统属性的值,该系统属性将被评估为别名的值。

我希望有直接的方法可以从EL表达式中评估别名,但没有。您可能会在Payara github上提出一个增强请求,看来从EL表达式评估Payara表达式将是一个有用的功能。

本文链接:https://www.f2er.com/3026044.html

大家都在问