I have seen a lot of examples on how to inject password aliases in microprofile using:
@ConfigProperty(name = “appsecret”)
private String secret;
Is this available in Payara Server or is this MicroProfile only?
If yes, is there a way to get ConfigProvider and fetch a password alias using from code rather than using annotations?
Password aliases are a feature of Payara Server as Payara Server is fully compatible with MicroProfile. You can read technical documentation about Password Aliases within Payara here: Password Aliases Overview :: Payara Community Documentation
Yes this is possible by using the MicroProfile Config ConfigProvider. More information about this is contained within the “Obtain Config programmatically” section of this MicroProfile newsletter: Eclipse MicroProfile Config – what is it? | The Eclipse Foundation
To answer your question directly, yes it is possible to access password aliases from code without annotations. For example, with a password alias where the alias name is
Payara you can use the following code to access the password alias programmatically.
Config config = ConfigProvider.getConfig();
String userId = config.getValue("Payara", String.class);