I have a problem with defining parameters for an @OpenIdAuthenticationMechanismDefinition annotation introduced in the jakarta-ee-security-api of Jakarta EE 10. My goal is to understand the correct usage of expression language.
See this example:
@OpenIdAuthenticationMechanismDefinition(
clientId = "123",
clientSecret = "xxx",
extraParameters = { "audience=abc", "team=def" }
)
public class MyBean {
...
}
In this example I set 3 params hard coded. The Jakrata EE jakarta-ee-security-api also supports a more dynamic way using the Expression Language and referring to a CDI bean providing such values:
@OpenIdAuthenticationMechanismDefinition(
clientId = "${configBean.clientId}",
clientSecret = "${configBean.clientSecret}",
extraParameters = { "audience=abc", "team=def" }
)
public class MyBean {
...
}
This works all fine. My problem in this example is the parameter extraParameters
which is expecting a string array. I did not manage to set this param by a config CDI Bean like in the following example code:
@OpenIdAuthenticationMechanismDefinition(
clientId = "${configBean.clientId}",
clientSecret = "${configBean.clientSecret}",
extraParameters = "${configBean.extraParameters}"
)
public class MyBean {
...
}
@ApplicationScoped
@Named
public class ConfigBean implements Serializable {
...
public String getClientId() {
return clientId;
}
public String getClientSecret() {
return clientSecret;
}
public String[] getExtraParameters() {
return { "audience=abc", "team=def" };
}
}
Running this code in Wildfly 27 causes the following exception:
jakarta.enterprise.inject.spi.DefinitionException: OpenIdAuthenticationMechanismDefinition.extraParameters() value '${configBean.extraParameters}' is not of the format key=value
The question is: How can I set the extraParameters
with expression language?
As you can see here there a also extra parameters defined ending with the sufix 'expression' expecting a String. But also with this param I did not found a solution to set a value with EL.