You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2014/06/13 18:23:36 UTC

git commit: [CXF-5311] Support for default media type

Repository: cxf
Updated Branches:
  refs/heads/master 607f93599 -> 7d4f8ea0c


[CXF-5311] Support for default media type


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

Branch: refs/heads/master
Commit: 7d4f8ea0ca7f66cea41ae8bb52aedfeefa66bbfc
Parents: 607f935
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Fri Jun 13 17:23:15 2014 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Fri Jun 13 17:23:15 2014 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/rs/security/oauth2/jwt/JwtUtils.java     | 4 +++-
 .../oauth2/jwt/jaxrs/AbstractJwsReaderProvider.java         | 9 +++++++++
 .../security/oauth2/jwt/jaxrs/JwsClientResponseFilter.java  | 2 +-
 .../oauth2/jwt/jaxrs/JwsContainerRequestFilter.java         | 2 +-
 4 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7d4f8ea0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtUtils.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtUtils.java
index c674453..61c9544 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtUtils.java
@@ -23,13 +23,15 @@ public final class JwtUtils {
         
     }
     
-    public static String checkContentType(String contentType) {
+    public static String checkContentType(String contentType, String defaultType) {
         if (contentType != null) {
             int paramIndex = contentType.indexOf(';');
             String typeWithoutParams = paramIndex == -1 ? contentType : contentType.substring(0, paramIndex);
             if (typeWithoutParams.indexOf('/') == -1) {
                 contentType = "application/" + contentType;
             }
+        } else {
+            contentType = defaultType;
         }
         return contentType;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/7d4f8ea0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/AbstractJwsReaderProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/AbstractJwsReaderProvider.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/AbstractJwsReaderProvider.java
index e03d5dc..a911ac9 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/AbstractJwsReaderProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/AbstractJwsReaderProvider.java
@@ -34,6 +34,7 @@ public class AbstractJwsReaderProvider {
     
     private JwsSignatureVerifier sigVerifier;
     private JwsSignatureProperties sigProperties;
+    private String defaultMediaType;
     
     public void setSigVerifier(JwsSignatureVerifier sigVerifier) {
         this.sigVerifier = sigVerifier;
@@ -64,6 +65,14 @@ public class AbstractJwsReaderProvider {
         PublicKey pk = CryptoUtils.loadPublicKey(propLoc, bus);
         return new PublicKeyJwsSignatureVerifier(pk);
     }
+
+    public String getDefaultMediaType() {
+        return defaultMediaType;
+    }
+
+    public void setDefaultMediaType(String defaultMediaType) {
+        this.defaultMediaType = defaultMediaType;
+    }
     
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/7d4f8ea0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsClientResponseFilter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsClientResponseFilter.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsClientResponseFilter.java
index 0646722..715f65f 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsClientResponseFilter.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsClientResponseFilter.java
@@ -41,7 +41,7 @@ public class JwsClientResponseFilter extends AbstractJwsReaderProvider implement
         p.verifySignatureWith(theSigVerifier);
         byte[] bytes = p.getDecodedJwsPayloadBytes();
         res.setEntityStream(new ByteArrayInputStream(bytes));
-        String ct = JwtUtils.checkContentType(p.getJwtHeaders().getContentType());
+        String ct = JwtUtils.checkContentType(p.getJwtHeaders().getContentType(), getDefaultMediaType());
         if (ct != null) {
             res.getHeaders().putSingle("Content-Type", ct);
             res.getHeaders().putSingle("Content-Length", Integer.toString(bytes.length));

http://git-wip-us.apache.org/repos/asf/cxf/blob/7d4f8ea0/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsContainerRequestFilter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsContainerRequestFilter.java b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsContainerRequestFilter.java
index 093fc3c..3f05670 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsContainerRequestFilter.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JwsContainerRequestFilter.java
@@ -44,7 +44,7 @@ public class JwsContainerRequestFilter extends AbstractJwsReaderProvider impleme
         byte[] bytes = p.getDecodedJwsPayloadBytes();
         context.setEntityStream(new ByteArrayInputStream(bytes));
         
-        String ct = JwtUtils.checkContentType(p.getJwtHeaders().getContentType());
+        String ct = JwtUtils.checkContentType(p.getJwtHeaders().getContentType(), getDefaultMediaType());
         if (ct != null) {
             context.getHeaders().putSingle("Content-Type", ct);
             context.getHeaders().putSingle("Content-Length", Integer.toString(bytes.length));