Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gechengyang
nouiWithSpringMVC
Commits
57648e16
Commit
57648e16
authored
Aug 26, 2021
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加coas角色映射
parent
3ba8a50b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
CoasHandleController.java
...ss/presentation/noui/controller/CoasHandleController.java
+15
-7
coas.properties
src/main/resources/coas.properties
+3
-2
No files found.
src/main/java/org/sss/presentation/noui/controller/CoasHandleController.java
View file @
57648e16
...
@@ -18,6 +18,7 @@ import org.sss.presentation.noui.util.DataSecurityUtil;
...
@@ -18,6 +18,7 @@ import org.sss.presentation.noui.util.DataSecurityUtil;
import
org.sss.presentation.noui.util.HttpClientUtil
;
import
org.sss.presentation.noui.util.HttpClientUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -33,10 +34,18 @@ public class CoasHandleController {
...
@@ -33,10 +34,18 @@ public class CoasHandleController {
private
String
coas_server
;
private
String
coas_server
;
@Value
(
"${pushuser}"
)
@Value
(
"${pushuser}"
)
private
String
pushuser
;
private
String
pushuser
;
@Value
(
"${rol_mappings}"
)
private
String
rol_mappings
;
private
Map
<
String
,
String
>
codetable
;
private
Gson
gson
=
new
Gson
();
private
Gson
gson
=
new
Gson
();
@Autowired
@Autowired
private
NoUiVersion
noUiVersion
;
private
NoUiVersion
noUiVersion
;
@PostConstruct
public
void
init
()
{
codetable
=
gson
.
fromJson
(
rol_mappings
,
Map
.
class
);
}
@RequestMapping
(
value
=
"/oauth2/callback"
,
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@RequestMapping
(
value
=
"/oauth2/callback"
,
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
GET
})
public
ModelAndView
callback
(
@RequestParam
(
"type"
)
String
type
,
@RequestParam
(
"value"
)
String
value
,
@RequestHeader
(
value
=
"certdn"
,
required
=
false
)
String
certdn
,
ModelAndView
view
)
{
public
ModelAndView
callback
(
@RequestParam
(
"type"
)
String
type
,
@RequestParam
(
"value"
)
String
value
,
@RequestHeader
(
value
=
"certdn"
,
required
=
false
)
String
certdn
,
ModelAndView
view
)
{
try
{
try
{
...
@@ -51,19 +60,14 @@ public class CoasHandleController {
...
@@ -51,19 +60,14 @@ public class CoasHandleController {
url
+=
"&user_certdn={user_certdn}"
;
url
+=
"&user_certdn={user_certdn}"
;
}
}
log
.
info
(
"准备请求:"
+
url
+
"请求参数:"
+
body
);
log
.
info
(
"准备请求:"
+
url
+
"请求参数:"
+
body
);
// ResponseEntity<String> res = HttpClientUtil.post(coas_server + "get_token", body, String.class);
ResponseEntity
<
String
>
res
=
HttpClientUtil
.
post
(
url
,
null
,
String
.
class
,
body
);
ResponseEntity
<
String
>
res
=
HttpClientUtil
.
post
(
url
,
null
,
String
.
class
,
body
);
String
res_str
=
res
.
getBody
();
String
res_str
=
res
.
getBody
();
Map
<
String
,
Object
>
res_body
=
gson
.
fromJson
(
res_str
,
Map
.
class
);
Map
<
String
,
Object
>
res_body
=
gson
.
fromJson
(
res_str
,
Map
.
class
);
log
.
info
(
"调用coas的get_token接口响应:"
+
res_body
);
log
.
info
(
"调用coas的get_token接口响应:"
+
res_body
);
checkRes
(
res
,
(
String
)
res_body
.
get
(
"msgCode"
),
(
String
)
res_body
.
get
(
"message"
),
"get_token"
);
checkRes
(
res
,
(
String
)
res_body
.
get
(
"msgCode"
),
(
String
)
res_body
.
get
(
"message"
),
"get_token"
);
String
access_token
=
(
String
)
res_body
.
get
(
"access_token"
);
String
access_token
=
(
String
)
res_body
.
get
(
"access_token"
);
String
token_type
=
(
String
)
res_body
.
get
(
"token_type"
);
// log.info(String.format("准备调用coas的get_info接口.access_token=[%s],token_type=[%s]", access_token, token_type));
body
=
new
HashMap
<>();
body
=
new
HashMap
<>();
body
.
put
(
"access_token"
,
access_token
);
body
.
put
(
"access_token"
,
access_token
);
// res = HttpClientUtil.post(coas_server + "get_info", body, String.class);
url
=
coas_server
+
"oauth2/get_info?access_token={access_token}"
;
url
=
coas_server
+
"oauth2/get_info?access_token={access_token}"
;
log
.
info
(
"准备请求:"
+
url
+
"请求参数:"
+
body
);
log
.
info
(
"准备请求:"
+
url
+
"请求参数:"
+
body
);
res
=
HttpClientUtil
.
post
(
url
,
null
,
String
.
class
,
body
);
res
=
HttpClientUtil
.
post
(
url
,
null
,
String
.
class
,
body
);
...
@@ -99,7 +103,7 @@ public class CoasHandleController {
...
@@ -99,7 +103,7 @@ public class CoasHandleController {
}
}
@ResponseBody
@ResponseBody
@RequestMapping
(
value
=
"/coas/pushuser"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/coas/pushuser"
,
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
GET
}
)
public
Object
pushuser
(
@RequestBody
Map
<
String
,
String
>
dataMap
)
{
public
Object
pushuser
(
@RequestBody
Map
<
String
,
String
>
dataMap
)
{
//如果推送开关关闭,则不做推送动作
//如果推送开关关闭,则不做推送动作
if
(
"off"
.
equalsIgnoreCase
(
pushuser
)){
if
(
"off"
.
equalsIgnoreCase
(
pushuser
)){
...
@@ -118,7 +122,11 @@ public class CoasHandleController {
...
@@ -118,7 +122,11 @@ public class CoasHandleController {
body
.
put
(
"client_id"
,
client_id
);
body
.
put
(
"client_id"
,
client_id
);
body
.
put
(
"client_secret"
,
client_secret
);
body
.
put
(
"client_secret"
,
client_secret
);
body
.
put
(
"optype"
,
"CR"
);
body
.
put
(
"optype"
,
"CR"
);
body
.
put
(
"coasroleid"
,
coasroleid
);
if
(!
StringUtil
.
isEmpty
(
coasroleid
)
&&
codetable
.
containsKey
(
coasroleid
)){
body
.
put
(
"coasroleid"
,
codetable
.
get
(
coasroleid
));
}
else
{
body
.
put
(
"coasroleid"
,
"32"
);
}
body
.
put
(
"coasdeptid"
,
coasdeptid
);
body
.
put
(
"coasdeptid"
,
coasdeptid
);
body
.
put
(
"coascertdn"
,
certdn
);
body
.
put
(
"coascertdn"
,
certdn
);
body
.
put
(
"loginid"
,
loginid
);
body
.
put
(
"loginid"
,
loginid
);
...
...
src/main/resources/coas.properties
View file @
57648e16
client_id
=
ESFE
client_id
=
ESFE
client_secret
=
666666
client_secret
=
666666
coas_server
=
http://111.1.12.211:8088/coas/
coas_server
=
http://111.1.12.211:8088/coas/
pushuser
=
off
pushuser
=
off
\ No newline at end of file
rol_mappings
=
{'pbcopr':'30','pbcrel':'31','bnkadm':'32','bnkbmg':'32','BUS-1':'32','REL-1':'32','MAG-1':'32','BUS-2':'32','REL-2':'32','MAG-2':'32','BUS-3':'32','REL-3':'32','MAG-3':'32','BUS-4':'32','REL-4':'32','MAG-4':'32'}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment