-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Hi!
I'm using your Oauth2Server and I have stumbled with a 500 bug while running the Token fetching, specifically in RequestParameter.java , method fetch, when it says:
Map<String, String> params = new HashMap<String, String>();
Map<String, String> parameterMap = request.getParameterMap();
params.putAll(parameterMap);
String token = request.getParameter("access_token")
The call to request.getParameterMap() is defined in the Request implementation HttpServletRequestAdapter, like this:
@SuppressWarnings("unchecked")
@Override
public Map<String, String> getParameterMap() {
return request.getParameterMap();
}
where request is a HttpServletRequest variable.
This is worng because the HttpServletRequest method getParameter returns a Map<String,String[]> instead of a Map<String,String> to admit multiple parameters values.
Since we are are only interested on single parameters values in this program (there can only be one access token value), I have fixed the bug changing this function :
@SuppressWarnings("unchecked")
@Override
public Map<String, String> getParameterMap() {
Map<String,String[]> allParametersValuesMap = request.getParameterMap();
Map<String,String> firstParameterValueMap = new HashMap<String,String>();
for (String key: allParametersValuesMap.keySet()) {
firstParameterValueMap.put(key,( (String []) allParametersValuesMap.get(key))[0]);
}
return firstParameterValueMap;
}
Hope this helps, sorry for my english :(
Metadata
Metadata
Assignees
Labels
No labels