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/02/11 17:50:22 UTC
svn commit: r1567214 -
/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
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