Merge branch 'BF-2527' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
Showing
1 changed file
with
10 additions
and
5 deletions
... | @@ -60,6 +60,7 @@ import net.sf.json.JSONObject; | ... | @@ -60,6 +60,7 @@ import net.sf.json.JSONObject; |
60 | public class DirectControlServlet extends HttpServlet { | 60 | public class DirectControlServlet extends HttpServlet { |
61 | public static final String module = DirectControlServlet.class.getName(); | 61 | public static final String module = DirectControlServlet.class.getName(); |
62 | public static final Map<String, String> serviceURLMappings = new HashMap<String, String>(); | 62 | public static final Map<String, String> serviceURLMappings = new HashMap<String, String>(); |
63 | private String sessionTokenName = "_AUTHTOKEN"; | ||
63 | 64 | ||
64 | public void init(ServletConfig config) throws ServletException { | 65 | public void init(ServletConfig config) throws ServletException { |
65 | // get the mapping file for this webapp | 66 | // get the mapping file for this webapp |
... | @@ -67,6 +68,10 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -67,6 +68,10 @@ public class DirectControlServlet extends HttpServlet { |
67 | String mappingFile = context.getInitParameter("serviceURLMappings"); | 68 | String mappingFile = context.getInitParameter("serviceURLMappings"); |
68 | Debug.logError("Mapping file: " + mappingFile, module); | 69 | Debug.logError("Mapping file: " + mappingFile, module); |
69 | 70 | ||
71 | if (context.getInitParameter("sessionTokenName") != null) { | ||
72 | sessionTokenName = context.getInitParameter("sessionTokenName"); | ||
73 | } | ||
74 | |||
70 | if (mappingFile == null) { | 75 | if (mappingFile == null) { |
71 | Debug.logError("No mapping file configured", module); | 76 | Debug.logError("No mapping file configured", module); |
72 | } else { | 77 | } else { |
... | @@ -117,19 +122,19 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -117,19 +122,19 @@ public class DirectControlServlet extends HttpServlet { |
117 | if (!"CALL".equals(method)) context.put("_method", method); | 122 | if (!"CALL".equals(method)) context.put("_method", method); |
118 | JSON json = new JSON(new StringReader(request.getParameter("model"))); | 123 | JSON json = new JSON(new StringReader(request.getParameter("model"))); |
119 | Map<String,Object> items = json.JSONObject(); | 124 | Map<String,Object> items = json.JSONObject(); |
120 | authToken = (String) items.get("_AUTHTOKEN"); | 125 | authToken = (String) items.get("sessionId"); |
121 | for (String key : items.keySet()) { | 126 | for (String key : items.keySet()) { |
122 | if (!"_AUTHTOKEN".equals(key)) { | 127 | if (!"sessionId".equals(key)) { |
123 | context.put(key, items.get(key)); | 128 | context.put(key, items.get(key)); |
124 | Debug.logInfo("parameter '" + key + "'=" + items.get(key), module); | 129 | Debug.logInfo("parameter '" + key + "'=" + items.get(key), module); |
125 | } | 130 | } |
126 | } | 131 | } |
127 | } else { | 132 | } else { |
128 | authToken = request.getParameter("_AUTHTOKEN"); | 133 | authToken = request.getParameter("sessionId"); |
129 | for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) { | 134 | for (Enumeration<String> params = request.getParameterNames(); params.hasMoreElements();) { |
130 | String param = params.nextElement(); | 135 | String param = params.nextElement(); |
131 | Object[] values = request.getParameterValues(param); | 136 | Object[] values = request.getParameterValues(param); |
132 | if (!"_AUTHTOKEN".equals(param)) { | 137 | if (!"sessionId".equals(param)) { |
133 | context.put(param, values.length == 1 ? values[0] : values); | 138 | context.put(param, values.length == 1 ? values[0] : values); |
134 | Debug.logInfo("parameter '" + param + "'=" + context.get(param), module); | 139 | Debug.logInfo("parameter '" + param + "'=" + context.get(param), module); |
135 | } | 140 | } |
... | @@ -155,7 +160,7 @@ public class DirectControlServlet extends HttpServlet { | ... | @@ -155,7 +160,7 @@ public class DirectControlServlet extends HttpServlet { |
155 | } | 160 | } |
156 | } | 161 | } |
157 | 162 | ||
158 | // If the _AUTHTOKEN parameter is set, attempt to look up the corresponding | 163 | // If the sessionId parameter is set, attempt to look up the corresponding |
159 | // UserLogin and apply it to the service context | 164 | // UserLogin and apply it to the service context |
160 | if (authToken != null) { | 165 | if (authToken != null) { |
161 | GenericValue authTokenEntity = EntityUtil.getFirst( | 166 | GenericValue authTokenEntity = EntityUtil.getFirst( | ... | ... |
-
Please register or sign in to post a comment