diff --git a/client/integration-tests/auth-provider/src/main/java/io/quarkiverse/openapi/generator/it/auth/provider/CustomCredentialsProvider.java b/client/integration-tests/auth-provider/src/main/java/io/quarkiverse/openapi/generator/it/auth/provider/CustomCredentialsProvider.java index e2bc1b8a..070c7fd5 100644 --- a/client/integration-tests/auth-provider/src/main/java/io/quarkiverse/openapi/generator/it/auth/provider/CustomCredentialsProvider.java +++ b/client/integration-tests/auth-provider/src/main/java/io/quarkiverse/openapi/generator/it/auth/provider/CustomCredentialsProvider.java @@ -6,6 +6,7 @@ import jakarta.enterprise.inject.Specializes; import io.quarkiverse.openapi.generator.providers.ConfigCredentialsProvider; +import io.quarkiverse.openapi.generator.providers.CredentialsContext; @Dependent @Alternative diff --git a/client/integration-tests/override-credential-provider/src/main/java/io/quarkiverse/openapi/generator/it/creds/CustomCredentialsProvider.java b/client/integration-tests/override-credential-provider/src/main/java/io/quarkiverse/openapi/generator/it/creds/CustomCredentialsProvider.java index 8bbc39b6..48d36860 100644 --- a/client/integration-tests/override-credential-provider/src/main/java/io/quarkiverse/openapi/generator/it/creds/CustomCredentialsProvider.java +++ b/client/integration-tests/override-credential-provider/src/main/java/io/quarkiverse/openapi/generator/it/creds/CustomCredentialsProvider.java @@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory; import io.quarkiverse.openapi.generator.providers.ConfigCredentialsProvider; +import io.quarkiverse.openapi.generator.providers.CredentialsContext; @Dependent @Alternative diff --git a/client/oidc/src/main/java/io/quarkiverse/openapi/generator/oidc/providers/OAuth2AuthenticationProvider.java b/client/oidc/src/main/java/io/quarkiverse/openapi/generator/oidc/providers/OAuth2AuthenticationProvider.java index ec6107ad..8ae3a59b 100644 --- a/client/oidc/src/main/java/io/quarkiverse/openapi/generator/oidc/providers/OAuth2AuthenticationProvider.java +++ b/client/oidc/src/main/java/io/quarkiverse/openapi/generator/oidc/providers/OAuth2AuthenticationProvider.java @@ -13,6 +13,7 @@ import io.quarkiverse.openapi.generator.providers.AbstractAuthProvider; import io.quarkiverse.openapi.generator.providers.AuthUtils; +import io.quarkiverse.openapi.generator.providers.CredentialsContext; import io.quarkiverse.openapi.generator.providers.CredentialsProvider; import io.quarkiverse.openapi.generator.providers.OperationAuthInfo; @@ -38,7 +39,7 @@ public void filter(ClientRequestContext requestContext) throws IOException { bearerToken = this.getTokenForPropagation(requestContext.getHeaders()); } else { delegate.filter(requestContext); - bearerToken = this.getCredentialsProvider().getOauth2BearerToken(CredentialsProvider.CredentialsContext.builder() + bearerToken = this.getCredentialsProvider().getOauth2BearerToken(CredentialsContext.builder() .requestContext(requestContext) .openApiSpecId(getOpenApiSpecId()) .authName(getName()) diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/ApiKeyAuthenticationProvider.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/ApiKeyAuthenticationProvider.java index 2b2368e4..3cf740ba 100644 --- a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/ApiKeyAuthenticationProvider.java +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/ApiKeyAuthenticationProvider.java @@ -54,7 +54,7 @@ && isUseAuthorizationHeaderValue()) { } private String getApiKey(ClientRequestContext requestContext) { - return credentialsProvider.getApiKey(CredentialsProvider.CredentialsContext.builder() + return credentialsProvider.getApiKey(CredentialsContext.builder() .requestContext(requestContext) .openApiSpecId(getOpenApiSpecId()) .authName(getName()) diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BasicAuthenticationProvider.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BasicAuthenticationProvider.java index 22fc3f00..9085e207 100644 --- a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BasicAuthenticationProvider.java +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BasicAuthenticationProvider.java @@ -23,7 +23,7 @@ public BasicAuthenticationProvider(final String openApiSpecId, String name, List } private String getUsername(ClientRequestContext requestContext) { - return credentialsProvider.getBasicUsername(CredentialsProvider.CredentialsContext.builder() + return credentialsProvider.getBasicUsername(CredentialsContext.builder() .requestContext(requestContext) .openApiSpecId(getOpenApiSpecId()) .authName(getName()) @@ -31,7 +31,7 @@ private String getUsername(ClientRequestContext requestContext) { } private String getPassword(ClientRequestContext requestContext) { - return credentialsProvider.getBasicPassword(CredentialsProvider.CredentialsContext.builder() + return credentialsProvider.getBasicPassword(CredentialsContext.builder() .requestContext(requestContext) .openApiSpecId(getOpenApiSpecId()) .authName(getName()) diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java index ea68883c..511b9112 100644 --- a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java @@ -35,7 +35,7 @@ public void filter(ClientRequestContext requestContext) throws IOException { } private String getBearerToken(ClientRequestContext requestContext) { - return credentialsProvider.getBearerToken(CredentialsProvider.CredentialsContext.builder() + return credentialsProvider.getBearerToken(CredentialsContext.builder() .requestContext(requestContext) .openApiSpecId(getOpenApiSpecId()) .authName(getName()) diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsContext.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsContext.java new file mode 100644 index 00000000..3c47b092 --- /dev/null +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsContext.java @@ -0,0 +1,59 @@ +package io.quarkiverse.openapi.generator.providers; + +import jakarta.ws.rs.client.ClientRequestContext; + +public class CredentialsContext { + // requestContext The current request context in which set the authorization header token + private ClientRequestContext requestContext; + // openApiSpecId the OpenAPI Spec identification as defined by the OpenAPI Extension + private String openApiSpecId; + // authName The security schema for this Bearer Token definition + private String authName; + + public CredentialsContext(ClientRequestContext requestContext, String openApiSpecId, String authName) { + this.requestContext = requestContext; + this.openApiSpecId = openApiSpecId; + this.authName = authName; + } + + public ClientRequestContext getRequestContext() { + return requestContext; + } + + public String getOpenApiSpecId() { + return openApiSpecId; + } + + public String getAuthName() { + return authName; + } + + public static CredentialsContextBuilder builder() { + return new CredentialsContextBuilder(); + } + + public static class CredentialsContextBuilder { + private ClientRequestContext requestContext; + private String openApiSpecId; + private String authName; + + public CredentialsContextBuilder requestContext(ClientRequestContext requestContext) { + this.requestContext = requestContext; + return this; + } + + public CredentialsContextBuilder openApiSpecId(String openApiSpecId) { + this.openApiSpecId = openApiSpecId; + return this; + } + + public CredentialsContextBuilder authName(String authName) { + this.authName = authName; + return this; + } + + public CredentialsContext build() { + return new CredentialsContext(requestContext, openApiSpecId, authName); + } + } +} diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsProvider.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsProvider.java index 02c4fa78..83d15a74 100644 --- a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsProvider.java +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/CredentialsProvider.java @@ -1,7 +1,5 @@ package io.quarkiverse.openapi.generator.providers; -import jakarta.ws.rs.client.ClientRequestContext; - /** * Provider for security credentials. Clients can implement this interface to control how to provide security credentials in * runtime. @@ -48,60 +46,4 @@ public interface CredentialsProvider { * @return the Bearer Token to use when filtering the request */ String getOauth2BearerToken(CredentialsContext input); - - class CredentialsContext { - // requestContext The current request context in which set the authorization header token - private ClientRequestContext requestContext; - // openApiSpecId the OpenAPI Spec identification as defined by the OpenAPI Extension - private String openApiSpecId; - // authName The security schema for this Bearer Token definition - private String authName; - - public CredentialsContext(ClientRequestContext requestContext, String openApiSpecId, String authName) { - this.requestContext = requestContext; - this.openApiSpecId = openApiSpecId; - this.authName = authName; - } - - public ClientRequestContext getRequestContext() { - return requestContext; - } - - public String getOpenApiSpecId() { - return openApiSpecId; - } - - public String getAuthName() { - return authName; - } - - public static CredentialsContextBuilder builder() { - return new CredentialsContextBuilder(); - } - - public static class CredentialsContextBuilder { - private ClientRequestContext requestContext; - private String openApiSpecId; - private String authName; - - public CredentialsContextBuilder requestContext(ClientRequestContext requestContext) { - this.requestContext = requestContext; - return this; - } - - public CredentialsContextBuilder openApiSpecId(String openApiSpecId) { - this.openApiSpecId = openApiSpecId; - return this; - } - - public CredentialsContextBuilder authName(String authName) { - this.authName = authName; - return this; - } - - public CredentialsContext build() { - return new CredentialsContext(requestContext, openApiSpecId, authName); - } - } - } }