cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Making sure JWS handlers can deal with the arbitrary payload
Date Fri, 13 Jun 2014 12:50:52 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 1cc014c39 -> 0f2a9fa0a


Making sure JWS handlers can deal with the arbitrary payload


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

Branch: refs/heads/master
Commit: 0f2a9fa0ab2026123f08f101452ece1be9601442
Parents: 1cc014c
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jun 13 13:50:27 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jun 13 13:50:27 2014 +0100

----------------------------------------------------------------------
 .../security/oauth2/jws/JwsCompactConsumer.java | 40 +++++---------
 .../security/oauth2/jws/JwsCompactProducer.java | 38 ++++++--------
 .../oauth2/jws/JwsJwtCompactConsumer.java       | 55 ++++++++++++++++++++
 .../oauth2/jws/JwsJwtCompactProducer.java       | 48 +++++++++++++++++
 .../oauth2/jwt/grant/JwtBearerGrantHandler.java | 10 ++--
 .../jwt/jaxrs/JwsMessageBodyProvider.java       | 10 ++--
 .../oauth2/jws/JwsCompactReaderWriterTest.java  | 22 ++++----
 7 files changed, 153 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactConsumer.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactConsumer.java
index d149587..430d4cc 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactConsumer.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactConsumer.java
@@ -21,22 +21,19 @@ package org.apache.cxf.rs.security.oauth2.jws;
 import java.io.UnsupportedEncodingException;
 
 import org.apache.cxf.common.util.Base64Exception;
-import org.apache.cxf.rs.security.oauth2.jwt.JwtClaims;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
-import org.apache.cxf.rs.security.oauth2.jwt.JwtToken;
-import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenJson;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtHeadersReader;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReader;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReaderWriter;
 import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
 import org.apache.cxf.rs.security.oauth2.utils.Base64UrlUtility;
 
 public class JwsCompactConsumer {
-    private JwtTokenReader reader = new JwtTokenReaderWriter();
+    private JwtHeadersReader reader = new JwtTokenReaderWriter();
     private String encodedSequence;
     private String encodedSignature;
     private String headersJson;
-    private String claimsJson;
-    private JwtToken token;
+    private String jwsPayload;
     private JwsSignatureProperties props;
     public JwsCompactConsumer(String encodedJws) {
         this(encodedJws, null, null);
@@ -47,7 +44,7 @@ public class JwsCompactConsumer {
     public JwsCompactConsumer(String encodedJws, JwtTokenReader r) {
         this(encodedJws, null, r);
     }
-    public JwsCompactConsumer(String encodedJws, JwsSignatureProperties props, JwtTokenReader
r) {
+    public JwsCompactConsumer(String encodedJws, JwsSignatureProperties props, JwtHeadersReader
r) {
         if (r != null) {
             this.reader = r;
         }
@@ -63,12 +60,11 @@ public class JwsCompactConsumer {
             encodedSignature = parts[2];
         }
         headersJson = decodeToString(parts[0]);
-        claimsJson = decodeToString(parts[1]);
-        
+        jwsPayload = decodeToString(parts[1]);
         encodedSequence = parts[0] + "." + parts[1];
         
     }
-    public String getUnsignedEncodedToken() {
+    public String getUnsignedEncodedPayload() {
         return encodedSequence;
     }
     public String getEncodedSignature() {
@@ -77,30 +73,18 @@ public class JwsCompactConsumer {
     public String getDecodedJsonHeaders() {
         return headersJson;
     }
-    public String getDecodedJsonClaims() {
-        return claimsJson;
-    }
-    public JwtTokenJson getDecodedJsonToken() {
-        return new JwtTokenJson(getDecodedJsonHeaders(), getDecodedJsonClaims());
+    public String getDecodedJwsPayload() {
+        return jwsPayload;
     }
     public byte[] getDecodedSignature() {
         return encodedSignature.isEmpty() ? new byte[]{} : decode(encodedSignature);
     }
     public JwtHeaders getJwtHeaders() {
-        return getJwtToken().getHeaders();
-    }
-    public JwtClaims getJwtClaims() {
-        return getJwtToken().getClaims();
-    }
-    public JwtToken getJwtToken() {
-        if (token == null) {
-            token = reader.fromJson(new JwtTokenJson(headersJson, claimsJson));
-        }
-        return token;
+        return getReader().fromJsonHeaders(headersJson);
     }
     public boolean verifySignatureWith(JwsSignatureVerifier validator) {
         enforceJweSignatureProperties();
-        if (!validator.verify(getJwtHeaders(), getUnsignedEncodedToken(), getDecodedSignature()))
{
+        if (!validator.verify(getJwtHeaders(), getUnsignedEncodedPayload(), getDecodedSignature()))
{
             throw new SecurityException();
         }
         return true;
@@ -118,7 +102,9 @@ public class JwsCompactConsumer {
         }
         
     }
-    
+    protected JwtHeadersReader getReader() {
+        return reader;
+    }
     private static byte[] decode(String encoded) {
         try {
             return Base64UrlUtility.decode(encoded);

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactProducer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactProducer.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactProducer.java
index d3b6931..cc41731 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactProducer.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactProducer.java
@@ -19,54 +19,48 @@
 package org.apache.cxf.rs.security.oauth2.jws;
 
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.rs.security.oauth2.jwt.JwtClaims;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtConstants;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
-import org.apache.cxf.rs.security.oauth2.jwt.JwtToken;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtHeadersWriter;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReaderWriter;
-import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenWriter;
 import org.apache.cxf.rs.security.oauth2.utils.Base64UrlUtility;
 
 public class JwsCompactProducer {
-    private JwtTokenWriter writer = new JwtTokenReaderWriter();
-    private JwtToken token;
+    private JwtHeadersWriter writer = new JwtTokenReaderWriter();
+    private JwtHeaders headers;
+    private String plainJwsPayload;
     private String signature;
     private String plainRep;
     
-    public JwsCompactProducer(JwtToken token) {
-        this(token, null);
+    public JwsCompactProducer(JwtHeaders headers, String payload) {
+        this(headers, null, payload);
     }
-    public JwsCompactProducer(JwtToken token, JwtTokenWriter w) {
-        this.token = token;
+    public JwsCompactProducer(JwtHeaders headers, JwtHeadersWriter w, String plainJwsPayload)
{
+        this.headers = headers;
         if (w != null) {
             this.writer = w;
         }
-    }
-    public JwsCompactProducer(JwtHeaders headers, JwtClaims claims) {
-        this(headers, claims, null);
-    }
-    public JwsCompactProducer(JwtHeaders headers, JwtClaims claims, JwtTokenWriter w) {
-        this(new JwtToken(headers, claims), w);
+        this.plainJwsPayload = plainJwsPayload;
     }
     
-    public String getUnsignedEncodedToken() {
+    public String getUnsignedEncodedJws() {
         if (plainRep == null) {
-            plainRep = Base64UrlUtility.encode(writer.headersToJson(token.getHeaders()))

+            plainRep = Base64UrlUtility.encode(writer.headersToJson(headers)) 
                 + "." 
-                + Base64UrlUtility.encode(writer.claimsToJson(token.getClaims()));
+                + Base64UrlUtility.encode(plainJwsPayload);
         }
         return plainRep;
     }
     
-    public String getSignedEncodedToken() {
+    public String getSignedEncodedJws() {
         boolean noSignature = StringUtils.isEmpty(signature);
         if (noSignature && !isPlainText()) {
             throw new IllegalStateException("Signature is not available");
         }
-        return getUnsignedEncodedToken() + "." + (noSignature ? "" : signature);
+        return getUnsignedEncodedJws() + "." + (noSignature ? "" : signature);
     }
     public void signWith(JwsSignatureProvider signer) { 
-        setSignatureOctets(signer.sign(token.getHeaders(), getUnsignedEncodedToken()));
+        setSignatureOctets(signer.sign(headers, getUnsignedEncodedJws()));
     }
     
     public void setSignatureText(String sig) {
@@ -79,6 +73,6 @@ public class JwsCompactProducer {
         this.signature = sig;
     }
     private boolean isPlainText() {
-        return JwtConstants.PLAIN_TEXT_ALGO.equals(token.getHeaders().getAlgorithm());
+        return JwtConstants.PLAIN_TEXT_ALGO.equals(headers.getAlgorithm());
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactConsumer.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactConsumer.java
new file mode 100644
index 0000000..2db9cd8
--- /dev/null
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactConsumer.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.rs.security.oauth2.jws;
+
+import org.apache.cxf.rs.security.oauth2.jwt.JwtClaims;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtToken;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenJson;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReader;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReaderWriter;
+
+public class JwsJwtCompactConsumer extends JwsCompactConsumer {
+    private JwtToken token;
+    public JwsJwtCompactConsumer(String encodedJws) {
+        this(encodedJws, null, null);
+    }
+    public JwsJwtCompactConsumer(String encodedJws, JwsSignatureProperties props) {
+        this(encodedJws, props, null);
+    }
+    public JwsJwtCompactConsumer(String encodedJws, JwtTokenReader r) {
+        this(encodedJws, null, r);
+    }
+    public JwsJwtCompactConsumer(String encodedJws, JwsSignatureProperties props, JwtTokenReader
r) {
+        super(encodedJws, props, r == null ? new JwtTokenReaderWriter() : r);
+    }
+    public JwtTokenJson getDecodedJsonToken() {
+        return new JwtTokenJson(getDecodedJsonHeaders(), getDecodedJwsPayload());
+    }
+    public JwtClaims getJwtClaims() {
+        return getJwtToken().getClaims();
+    }
+    public JwtToken getJwtToken() {
+        if (token == null) {
+            token = ((JwtTokenReaderWriter)getReader()).fromJson(
+                new JwtTokenJson(getDecodedJsonHeaders(), getDecodedJwsPayload()));
+        }
+        return token;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactProducer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactProducer.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactProducer.java
new file mode 100644
index 0000000..7d43a8d
--- /dev/null
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/JwsJwtCompactProducer.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.rs.security.oauth2.jws;
+
+import org.apache.cxf.rs.security.oauth2.jwt.JwtClaims;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtToken;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReaderWriter;
+import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenWriter;
+
+public class JwsJwtCompactProducer extends JwsCompactProducer {
+    
+    public JwsJwtCompactProducer(JwtToken token) {
+        this(token, null);
+    }
+    public JwsJwtCompactProducer(JwtHeaders headers, JwtClaims claims) {
+        this(headers, claims, null);
+    }
+    public JwsJwtCompactProducer(JwtHeaders headers, JwtClaims claims, JwtTokenWriter w)
{
+        this(new JwtToken(headers, claims), w);
+    }
+    public JwsJwtCompactProducer(JwtToken token, JwtTokenWriter w) {
+        super(token.getHeaders(), w, serializeClaims(token.getClaims(), w));
+    }
+    
+    private static String serializeClaims(JwtClaims claims, JwtTokenWriter writer) {
+        if (writer == null) {
+            writer = new JwtTokenReaderWriter();
+        }
+        return writer.claimsToJson(claims);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/JwtBearerGrantHandler.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/JwtBearerGrantHandler.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/JwtBearerGrantHandler.java
index 1d4f9f5..69c9848 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/JwtBearerGrantHandler.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/JwtBearerGrantHandler.java
@@ -26,7 +26,7 @@ import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
 import org.apache.cxf.rs.security.oauth2.common.UserSubject;
-import org.apache.cxf.rs.security.oauth2.jws.JwsCompactConsumer;
+import org.apache.cxf.rs.security.oauth2.jws.JwsJwtCompactConsumer;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtToken;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReader;
 import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
@@ -57,10 +57,10 @@ public class JwtBearerGrantHandler extends AbstractJwtHandler {
             throw new OAuthServiceException(OAuthConstants.INVALID_GRANT);
         }
         try {
-            JwsCompactConsumer jwsReader = getJwsReader(assertion);
+            JwsJwtCompactConsumer jwsReader = getJwsReader(assertion);
             JwtToken jwtToken = jwsReader.getJwtToken();
             super.validateSignature(jwtToken.getHeaders(),
-                                    jwsReader.getUnsignedEncodedToken(), 
+                                    jwsReader.getUnsignedEncodedPayload(), 
                                     jwsReader.getDecodedSignature());
             
                    
@@ -79,8 +79,8 @@ public class JwtBearerGrantHandler extends AbstractJwtHandler {
         
     }
 
-    protected JwsCompactConsumer getJwsReader(String assertion) {
-        return new JwsCompactConsumer(assertion, jwtReader);
+    protected JwsJwtCompactConsumer getJwsReader(String assertion) {
+        return new JwsJwtCompactConsumer(assertion, jwtReader);
     }
     
     public void setJwtReader(JwtTokenReader tokenReader) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsMessageBodyProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsMessageBodyProvider.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsMessageBodyProvider.java
index 3ab2626..0528f45 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsMessageBodyProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsMessageBodyProvider.java
@@ -38,8 +38,8 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.rs.security.oauth2.jws.JwsCompactConsumer;
-import org.apache.cxf.rs.security.oauth2.jws.JwsCompactProducer;
+import org.apache.cxf.rs.security.oauth2.jws.JwsJwtCompactConsumer;
+import org.apache.cxf.rs.security.oauth2.jws.JwsJwtCompactProducer;
 import org.apache.cxf.rs.security.oauth2.jws.JwsSignatureProperties;
 import org.apache.cxf.rs.security.oauth2.jws.JwsSignatureProvider;
 import org.apache.cxf.rs.security.oauth2.jws.JwsSignatureVerifier;
@@ -71,7 +71,7 @@ public class JwsMessageBodyProvider implements
         if (theSigVerifier == null) {
             throw new SecurityException();
         }
-        JwsCompactConsumer p = new JwsCompactConsumer(IOUtils.readStringFromStream(is), 
+        JwsJwtCompactConsumer p = new JwsJwtCompactConsumer(IOUtils.readStringFromStream(is),

                                                       sigProperties);
         p.verifySignatureWith(theSigVerifier);
         return p.getJwtToken();
@@ -96,9 +96,9 @@ public class JwsMessageBodyProvider implements
         if (theSigProvider == null) {
             throw new SecurityException();
         }
-        JwsCompactProducer p = new JwsCompactProducer(token);
+        JwsJwtCompactProducer p = new JwsJwtCompactProducer(token);
         p.signWith(theSigProvider);
-        IOUtils.copy(new ByteArrayInputStream(p.getSignedEncodedToken().getBytes("UTF-8")),
os);
+        IOUtils.copy(new ByteArrayInputStream(p.getSignedEncodedJws().getBytes("UTF-8")),
os);
     }
 
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/0f2a9fa0/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
index b356835..8378aab 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
@@ -88,7 +88,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
         jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY));
         
-        assertEquals(ENCODED_TOKEN_SIGNED_BY_MAC, jws.getSignedEncodedToken());
+        assertEquals(ENCODED_TOKEN_SIGNED_BY_MAC, jws.getSignedEncodedJws());
         
     }
     
@@ -104,10 +104,10 @@ public class JwsCompactReaderWriterTest extends Assert {
         claims.setExpiryTime(1300819380);
         claims.setClaim("http://claims.example.com/member", true);
         
-        JwsCompactProducer writer = new JwsCompactProducer(headers, claims);
-        String signed = writer.getSignedEncodedToken();
+        JwsCompactProducer writer = new JwsJwtCompactProducer(headers, claims);
+        String signed = writer.getSignedEncodedJws();
         
-        JwsCompactConsumer reader = new JwsCompactConsumer(signed);
+        JwsJwtCompactConsumer reader = new JwsJwtCompactConsumer(signed);
         assertEquals(0, reader.getDecodedSignature().length);
         
         JwtToken token = reader.getJwtToken();
@@ -116,7 +116,7 @@ public class JwsCompactReaderWriterTest extends Assert {
 
     @Test
     public void testReadJwsSignedByMacSpecExample() throws Exception {
-        JwsCompactConsumer jws = new JwsCompactConsumer(ENCODED_TOKEN_SIGNED_BY_MAC);
+        JwsJwtCompactConsumer jws = new JwsJwtCompactConsumer(ENCODED_TOKEN_SIGNED_BY_MAC);
         assertTrue(jws.verifySignatureWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY)));
         JwtToken token = jws.getJwtToken();
         JwtHeaders headers = token.getHeaders();
@@ -154,15 +154,15 @@ public class JwsCompactReaderWriterTest extends Assert {
         claims.setClaim("http://example.com/is_root", Boolean.TRUE);
         
         JwtToken token = new JwtToken(headers, claims);
-        JwsCompactProducer jws = new JwsCompactProducer(token, getWriter());
+        JwsCompactProducer jws = new JwsJwtCompactProducer(token, getWriter());
         jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY));
         
-        assertEquals(ENCODED_TOKEN_WITH_JSON_KEY_SIGNED_BY_MAC, jws.getSignedEncodedToken());
+        assertEquals(ENCODED_TOKEN_WITH_JSON_KEY_SIGNED_BY_MAC, jws.getSignedEncodedJws());
     }
     
     @Test
     public void testReadJwsWithJwkSignedByMac() throws Exception {
-        JwsCompactConsumer jws = new JwsCompactConsumer(ENCODED_TOKEN_WITH_JSON_KEY_SIGNED_BY_MAC);
+        JwsJwtCompactConsumer jws = new JwsJwtCompactConsumer(ENCODED_TOKEN_WITH_JSON_KEY_SIGNED_BY_MAC);
         assertTrue(jws.verifySignatureWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY)));
         JwtToken token = jws.getJwtToken();
         JwtHeaders headers = token.getHeaders();
@@ -193,12 +193,12 @@ public class JwsCompactReaderWriterTest extends Assert {
         PrivateKey key = CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED, RSA_PRIVATE_EXPONENT_ENCODED);
         jws.signWith(new PrivateKeyJwsSignatureProvider(key));
         
-        assertEquals(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY, jws.getSignedEncodedToken());
+        assertEquals(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY, jws.getSignedEncodedJws());
     }
     
     @Test
     public void testReadJwsSignedByPrivateKey() throws Exception {
-        JwsCompactConsumer jws = new JwsCompactConsumer(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY);
+        JwsJwtCompactConsumer jws = new JwsJwtCompactConsumer(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY);
         RSAPublicKey key = CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED, RSA_PUBLIC_EXPONENT_ENCODED);
         assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key)));
         JwtToken token = jws.getJwtToken();
@@ -215,7 +215,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         claims.setClaim("http://example.com/is_root", Boolean.TRUE);
         
         JwtToken token = new JwtToken(headers, claims);
-        return new JwsCompactProducer(token, getWriter());
+        return new JwsJwtCompactProducer(token, getWriter());
     }
 
     


Mime
View raw message