77import jakarta .enterprise .inject .Alternative ;
88
99import org .eclipse .microprofile .config .ConfigProvider ;
10- import org .slf4j .Logger ;
11- import org .slf4j .LoggerFactory ;
1210
1311@ Dependent
1412@ Alternative
@@ -20,17 +18,11 @@ public class ConfigCredentialsProvider implements CredentialsProvider {
2018 static final String BEARER_TOKEN = "bearer-token" ;
2119 static final String API_KEY = "api-key" ;
2220
23- private static final Logger LOGGER = LoggerFactory .getLogger (ConfigCredentialsProvider .class );
24-
25- public ConfigCredentialsProvider () {
26-
27- }
28-
2921 @ Override
3022 public Optional <String > getApiKey (CredentialsContext input ) {
3123 return ConfigProvider .getConfig ()
3224 .getOptionalValue (
33- AbstractAuthProvider .getCanonicalAuthConfigPropertyName (API_KEY , input . getOpenApiSpecId ( ),
25+ AbstractAuthProvider .getCanonicalAuthConfigPropertyName (API_KEY , getConfigKey ( input ),
3426 input .getAuthName ()),
3527 String .class );
3628
@@ -40,7 +32,7 @@ public Optional<String> getApiKey(CredentialsContext input) {
4032 public Optional <String > getBasicUsername (CredentialsContext input ) {
4133 return ConfigProvider .getConfig ()
4234 .getOptionalValue (
43- AbstractAuthProvider .getCanonicalAuthConfigPropertyName (USER_NAME , input . getOpenApiSpecId ( ),
35+ AbstractAuthProvider .getCanonicalAuthConfigPropertyName (USER_NAME , getConfigKey ( input ),
4436 input .getAuthName ()),
4537 String .class );
4638 }
@@ -49,7 +41,7 @@ public Optional<String> getBasicUsername(CredentialsContext input) {
4941 public Optional <String > getBasicPassword (CredentialsContext input ) {
5042 return ConfigProvider .getConfig ()
5143 .getOptionalValue (
52- AbstractAuthProvider .getCanonicalAuthConfigPropertyName (PASSWORD , input . getOpenApiSpecId ( ),
44+ AbstractAuthProvider .getCanonicalAuthConfigPropertyName (PASSWORD , getConfigKey ( input ),
5345 input .getAuthName ()),
5446 String .class );
5547 }
@@ -58,11 +50,15 @@ public Optional<String> getBasicPassword(CredentialsContext input) {
5850 public Optional <String > getBearerToken (CredentialsContext input ) {
5951 return ConfigProvider .getConfig ()
6052 .getOptionalValue (
61- AbstractAuthProvider .getCanonicalAuthConfigPropertyName (BEARER_TOKEN , input . getOpenApiSpecId ( ),
53+ AbstractAuthProvider .getCanonicalAuthConfigPropertyName (BEARER_TOKEN , getConfigKey ( input ),
6254 input .getAuthName ()),
6355 String .class );
6456 }
6557
58+ protected String getConfigKey (CredentialsContext input ) {
59+ return input .getOpenApiSpecId ();
60+ }
61+
6662 @ Override
6763 public Optional <String > getOauth2BearerToken (CredentialsContext input ) {
6864 return Optional .empty ();
0 commit comments