Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-directcontrolservlet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
27c25626
authored
2014-03-31 13:06:18 -0500
by
Ean Schuessler
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Make token name configurable.
1 parent
7df44925
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
src/com/brainfood/ofbiz/DirectControlServlet.java
src/com/brainfood/ofbiz/DirectControlServlet.java
View file @
27c2562
...
...
@@ -60,6 +60,7 @@ import net.sf.json.JSONObject;
public
class
DirectControlServlet
extends
HttpServlet
{
public
static
final
String
module
=
DirectControlServlet
.
class
.
getName
();
public
static
final
Map
<
String
,
String
>
serviceURLMappings
=
new
HashMap
<
String
,
String
>();
private
String
sessionTokenName
=
"_AUTHTOKEN"
;
public
void
init
(
ServletConfig
config
)
throws
ServletException
{
// get the mapping file for this webapp
...
...
@@ -67,6 +68,10 @@ public class DirectControlServlet extends HttpServlet {
String
mappingFile
=
context
.
getInitParameter
(
"serviceURLMappings"
);
Debug
.
logError
(
"Mapping file: "
+
mappingFile
,
module
);
if
(
context
.
getInitParameter
(
"sessionTokenName"
)
!=
null
)
{
sessionTokenName
=
context
.
getInitParameter
(
"sessionTokenName"
);
}
if
(
mappingFile
==
null
)
{
Debug
.
logError
(
"No mapping file configured"
,
module
);
}
else
{
...
...
@@ -117,19 +122,19 @@ public class DirectControlServlet extends HttpServlet {
if
(!
"CALL"
.
equals
(
method
))
context
.
put
(
"_method"
,
method
);
JSON
json
=
new
JSON
(
new
StringReader
(
request
.
getParameter
(
"model"
)));
Map
<
String
,
Object
>
items
=
json
.
JSONObject
();
authToken
=
(
String
)
items
.
get
(
"
_AUTHTOKEN
"
);
authToken
=
(
String
)
items
.
get
(
"
sessionId
"
);
for
(
String
key
:
items
.
keySet
())
{
if
(!
"
_AUTHTOKEN
"
.
equals
(
key
))
{
if
(!
"
sessionId
"
.
equals
(
key
))
{
context
.
put
(
key
,
items
.
get
(
key
));
Debug
.
logInfo
(
"parameter '"
+
key
+
"'="
+
items
.
get
(
key
),
module
);
}
}
}
else
{
authToken
=
request
.
getParameter
(
"
_AUTHTOKEN
"
);
authToken
=
request
.
getParameter
(
"
sessionId
"
);
for
(
Enumeration
<
String
>
params
=
request
.
getParameterNames
();
params
.
hasMoreElements
();)
{
String
param
=
params
.
nextElement
();
Object
[]
values
=
request
.
getParameterValues
(
param
);
if
(!
"
_AUTHTOKEN
"
.
equals
(
param
))
{
if
(!
"
sessionId
"
.
equals
(
param
))
{
context
.
put
(
param
,
values
.
length
==
1
?
values
[
0
]
:
values
);
Debug
.
logInfo
(
"parameter '"
+
param
+
"'="
+
context
.
get
(
param
),
module
);
}
...
...
@@ -155,7 +160,7 @@ public class DirectControlServlet extends HttpServlet {
}
}
// If the
_AUTHTOKEN
parameter is set, attempt to look up the corresponding
// If the
sessionId
parameter is set, attempt to look up the corresponding
// UserLogin and apply it to the service context
if
(
authToken
!=
null
)
{
GenericValue
authTokenEntity
=
EntityUtil
.
getFirst
(
...
...
Please
register
or
sign in
to post a comment