cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1567214 - /cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
Date Tue, 11 Feb 2014 16:50:22 GMT
Author: sergeyb
Date: Tue Feb 11 16:50:21 2014
New Revision: 1567214

URL: http://svn.apache.org/r1567214
Log:
[CXF-5554] Correct check for media types

Modified:
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java?rev=1567214&r1=1567213&r2=1567214&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
Tue Feb 11 16:50:21 2014
@@ -132,16 +132,18 @@ public final class OAuthUtils {
         String enc = oAuthMessage.getBodyEncoding();
         enc = enc == null ? "UTF-8" : enc;
         
-        if (params.isEmpty() 
-            && MediaType.APPLICATION_FORM_URLENCODED.equals(oAuthMessage.getBodyType()))
{
-            InputStream stream = mc != null 
-                ? mc.getContent(InputStream.class) : oAuthMessage.getBodyAsStream();
-            String body = FormUtils.readBody(stream, enc);
-            MultivaluedMap<String, String> map = new MetadataMap<String, String>();
-            FormUtils.populateMapFromString(map, PhaseInterceptorChain.getCurrentMessage(),
body, enc, true, 
-                                            request);
-            for (String key : map.keySet()) {
-                oAuthMessage.addParameter(key, map.getFirst(key));
+        if (params.isEmpty())  {
+            MediaType bodyMediaType = MediaType.valueOf(oAuthMessage.getBodyType());
+            if (MediaType.APPLICATION_FORM_URLENCODED_TYPE.isCompatible(bodyMediaType)) {
+                InputStream stream = mc != null 
+                    ? mc.getContent(InputStream.class) : oAuthMessage.getBodyAsStream();
+                String body = FormUtils.readBody(stream, enc);
+                MultivaluedMap<String, String> map = new MetadataMap<String, String>();
+                FormUtils.populateMapFromString(map, PhaseInterceptorChain.getCurrentMessage(),
body, enc, true, 
+                                                request);
+                for (String key : map.keySet()) {
+                    oAuthMessage.addParameter(key, map.getFirst(key));
+                }
             }
         } else {
             // This path will most likely work only for the AuthorizationRequestService



Mime
View raw message