This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ed8eed  [CAMEL-15872] JWT Authorization Type Configuration Option to 
GraphQL Component (#4643)
1ed8eed is described below

commit 1ed8eed9d3dc3f604394eb6ecf5fc1616fecc747
Author: tapiiron <[email protected]>
AuthorDate: Mon Nov 23 18:00:21 2020 +0200

    [CAMEL-15872] JWT Authorization Type Configuration Option to GraphQL 
Component (#4643)
---
 .../src/main/docs/graphql-component.adoc              |  1 +
 .../camel/component/graphql/GraphqlEndpoint.java      | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/components/camel-graphql/src/main/docs/graphql-component.adoc 
b/components/camel-graphql/src/main/docs/graphql-component.adoc
index 61e383b..2263665 100644
--- a/components/camel-graphql/src/main/docs/graphql-component.adoc
+++ b/components/camel-graphql/src/main/docs/graphql-component.adoc
@@ -62,6 +62,7 @@ with the following path and query parameters:
 | *variables* (producer) | The JsonObject instance containing the operation 
variables. |  | JsonObject
 | *synchronous* (advanced) | Sets whether synchronous processing should be 
strictly used, or Camel is allowed to use asynchronous processing (if 
supported). | false | boolean
 | *accessToken* (security) | The access token sent in the Authorization 
header. |  | String
+| *jwtAuthorizationType* | The access token type sent in the Authorization 
header. Defaults to Bearer |  | String
 | *password* (security) | The password for Basic authentication. |  | String
 | *username* (security) | The username for Basic authentication. |  | String
 |===
diff --git 
a/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
 
b/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
index 6fcd20b..202baff 100644
--- 
a/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
+++ 
b/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
@@ -64,6 +64,8 @@ public class GraphqlEndpoint extends DefaultEndpoint {
     private String username;
     @UriParam(label = "security", secret = true)
     private String password;
+    @UriParam(label = "security", defaultValue = "Bearer")
+    private String jwtAuthorizationType;
     @UriParam
     private String query;
     @UriParam
@@ -110,8 +112,12 @@ public class GraphqlEndpoint extends DefaultEndpoint {
             httpClientBuilder.setProxy(new HttpHost(hostname, port));
         }
         if (accessToken != null) {
+            String authType = "Bearer";
+            if (this.jwtAuthorizationType != null) {
+                authType = this.jwtAuthorizationType;
+            }
             httpClientBuilder.setDefaultHeaders(
-                    Arrays.asList(new BasicHeader(HttpHeaders.AUTHORIZATION, 
"Bearer " + accessToken)));
+                    Arrays.asList(new BasicHeader(HttpHeaders.AUTHORIZATION, 
authType + " " + accessToken)));
         }
         if (username != null && password != null) {
             CredentialsProvider credentialsProvider = new 
BasicCredentialsProvider();
@@ -188,6 +194,17 @@ public class GraphqlEndpoint extends DefaultEndpoint {
     }
 
     /**
+     * The JWT Authorization type. Default is Bearer.
+     */
+    public void setJwtAuthorizationType(String jwtAuthorizationType) {
+        this.jwtAuthorizationType = jwtAuthorizationType;
+    }
+
+    public String getJwtAuthorizationType() {
+        return this.jwtAuthorizationType;
+    }
+
+    /**
      * The query text.
      */
     public void setQuery(String query) {

Reply via email to