cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Explicit support for serializing a single audience as String given that Google fails to recognize an array despite the spec text
Date Thu, 03 Dec 2015 16:38:01 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 44316035a -> c014597c2


Explicit support for serializing a single audience as String given that Google fails to recognize
an array despite the spec text


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c014597c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c014597c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c014597c

Branch: refs/heads/3.1.x-fixes
Commit: c014597c2d47243330d6119120a4a81c531cb62e
Parents: 4431603
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Dec 3 16:34:52 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Dec 3 16:37:30 2015 +0000

----------------------------------------------------------------------
 .../java/demo/jaxrs/server/BigQueryServer.java  |  2 +-
 .../cxf/rs/security/jose/jwt/JwtClaims.java     | 31 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c014597c/distribution/src/main/release/samples/jax_rs/big_query/src/main/java/demo/jaxrs/server/BigQueryServer.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/java/demo/jaxrs/server/BigQueryServer.java
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/java/demo/jaxrs/server/BigQueryServer.java
index 6c047ca..33b8d46 100644
--- a/distribution/src/main/release/samples/jax_rs/big_query/src/main/java/demo/jaxrs/server/BigQueryServer.java
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/java/demo/jaxrs/server/BigQueryServer.java
@@ -76,7 +76,7 @@ public final class BigQueryServer {
         JwsHeaders headers = new JwsHeaders(JoseType.JWT, SignatureAlgorithm.RS256);
         JwtClaims claims = new JwtClaims();
         claims.setIssuer(issuer);
-        claims.setAudiences(Collections.singletonList("https://www.googleapis.com/oauth2/v3/token"));
+        claims.setAudience("https://www.googleapis.com/oauth2/v3/token");
         
         long issuedAt = OAuthUtils.getIssuedAt();
         claims.setIssuedAt(issuedAt);

http://git-wip-us.apache.org/repos/asf/cxf/blob/c014597c/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
index a3c77b9..b924a55 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/JwtClaims.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.json.basic.JsonMapObject;
 
@@ -54,10 +55,40 @@ public class JwtClaims extends JsonMapObject {
         return (String)getClaim(JwtConstants.CLAIM_SUBJECT);
     }
     
+    /**
+     * Set a single audience value which will be serialized as a String
+     * @param audience the audience
+     */
+    public void setAudience(String audience) {
+        setClaim(JwtConstants.CLAIM_AUDIENCE, audience);
+    }
+    
+    /**
+     * Get a single audience value. If the audience claim value is an array then the
+     * first value will be returned.
+     * @return the audience
+     */
+    public String getAudience() {
+        List<String> audiences = getAudiences();
+        if (!StringUtils.isEmpty(audiences)) {
+            return audiences.get(0);
+        } else {
+            return null;
+        }
+    }
+    
+    /**
+     * Set an array of audiences
+     * @param audiences the audiences array
+     */
     public void setAudiences(List<String> audiences) {
         setClaim(JwtConstants.CLAIM_AUDIENCE, audiences);
     }
     
+    /**
+     * Get an array of audiences
+     * @return the audiences array
+     */
     public List<String> getAudiences() {
         Object audiences = getClaim(JwtConstants.CLAIM_AUDIENCE);
         if (audiences instanceof List<?>) {


Mime
View raw message