Skip to content
Permalink
Browse files
[CXF-5554] Correct check for media types
git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1567214 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Sergey Beryozkin committed Feb 11, 2014
1 parent 278e8a9 commit 643a6962ca28c2ad5b93ad0bff4309de372c261e
Showing 1 changed file with 12 additions and 10 deletions.
@@ -132,16 +132,18 @@ public static void addParametersIfNeeded(MessageContext mc,
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

0 comments on commit 643a696

Please sign in to comment.