整合H4A
# 天宫框架集成H4A
# 登录流程
# 退出流程
# 后端集成
# 1. 添加数据库返回码
数据库表 SYS_LANGUAGE
如果没有请执行一下
INSERT INTO SYS_LANGUAGE(ID, LANG_CODE, DESCRIPTION, LANG_TYPE, LANG_1, LANG_2, LANG_3, LANG_4) VALUES (18, '20101', NULL, 'ht', 'h4aToken异常, 请重新登录', 'h4aToken error, please login again', NULL, NULL);
INSERT INTO SYS_LANGUAGE(ID, LANG_CODE, DESCRIPTION, LANG_TYPE, LANG_1, LANG_2, LANG_3, LANG_4) VALUES (19, '20102', NULL, 'ht', 'h4aToken后台登录异常, 请联系管理员', 'h4aToken backend login exception, please contact the administrator', NULL, NULL);
INSERT INTO SYS_LANGUAGE(ID, LANG_CODE, DESCRIPTION, LANG_TYPE, LANG_1, LANG_2, LANG_3, LANG_4) VALUES (20, '20103', NULL, 'ht', 'h4a后端没有配置h4a, 请联系管理员', 'The H4a backend is not configured with H4a. Please contact the administrator', NULL, NULL);
INSERT INTO SYS_LANGUAGE(ID, LANG_CODE, DESCRIPTION, LANG_TYPE, LANG_1, LANG_2, LANG_3, LANG_4) VALUES (21, '20104', NULL, 'ht', 'h4a获取权限失败,请联系管理员', 'H4a failed to obtain permissions, please contact the administrator', NULL, NULL);
1
2
3
4
2
3
4
# 2. 主启动类加上注解
@SpringBootApplication
@EnableH4aLogin
public class MainApplication{
}
1
2
3
4
5
2
3
4
5
# 3. 获取权限平台的菜单目录树
控制台启动后有链接, 浏览器请求后可以直接下载 menu.json
http://localhost:[端口]/h4a/downMenuTree/MAIN
1
将文件放在resource/config/ 下面
# 4. resource目录下添加配置文件
给两个文件示范, 以南京体检为例, 简称NJTJ
# h4a-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<application>
<module name="h4aIdentity">
<group name="wsCache">
<!-- cacheControl 值为off为开启缓存,值为on为关闭缓存 -->
<configValue key="cacheControl">on</configValue>
<!--cacheTime和cacheClearTime值为缓存设置的参数,默认值即可-->
<configValue key="cacheTime">300000000</configValue>
<configValue key="cacheClearTime">1</configValue>
<!--initialDelay和clearCachePeriod参数默认值即可,无需修改-->
<configValue key="initialDelay">0</configValue>
<configValue key="clearCachePeriod">1440</configValue>
</group>
</module>
<module name="passportSSO">
<group name="passport">
<!--appID是应用的ID号-->
<configValue key="appID">ZSCQ</configValue>
<!--appSlidingTime是应用的过期时间-->
<configValue key="appSlidingTime">0</configValue>
<!--idAuthenticationMode是系统支持(要求)认证返回的认证模式-->
<!--参数值forms是表单认证-->
<configValue key="idAuthenticationMode">forms</configValue>
<!--paramT参数默认值即可,无需修改-->
<configValue key="paramT">token</configValue>
<!--defaultAuthenticationMode是默认认证方式-->
<!--formsAuthentication是表单认证-->
<configValue key="defaultAuthenticationMode">FormsAuthentication</configValue>
</group>
<group name="url">
<!-- logoffAutoRedirect参数即注销是否允许自动跳转 -->
<configValue key="logoffAutoRedirect">false</configValue>
<!--请修改为应用系统的主页访问地址,实际地址为应用的相对访问路径,如http://localhost:8080/default/login.jsp,应填写为/login.jsp -->
<configValue key="logoffToDefaultUriString"></configValue>
<!-- logOffCallBackUrl的uri是注销回调地址 -->
<configValue key="logOffCallBackUrl">/h4a/logout</configValue>
<!-- H4A登录时,如有多个身份,如需选择某个身份登录,选择身份页面配置,例:/sso/selectIdentity.jsp -->
<configValue key="select_identity_page"> </configValue>
</group>
<group name="defaultAuthenticationMode">
<configValue key="*.jpg">Anonymous</configValue>
<!-- 默认值即可-->
<configValue key="*.gif">Anonymous</configValue><!--默认值即可-->
<configValue key="/anonymous.html">Anonymous</configValue><!--默认值即可-->
<!--WindowsAuthentication是域认证,默认值-->
<configValue key="/WindowsAuthentication/*.jsp">WindowsAuthentication</configValue>
<configValue key="/WindowsAuthentication/test*">WindowsAuthentication</configValue>
</group>
<!-- 不需passport filter拦截的页面在次配置,没有不拦截页面,configValue key="url"的值为空 -->
<group name="notInterceptUrl">
<!-- start , end , center三种选择 -->
<configValue key="position">start</configValue>
<!-- 多个情况下,中间使用","分隔 -->
<configValue key="url"></configValue>
<!-- URL解密实现方法,继承cn.gov.customs.casp.sdk.h4a.sso.IPassportDecryption -->
<configValue key="decryption"></configValue>
</group>
</module>
<module name="SSOAddress">
<group name="ssoAddress">
<!-- 海关H4AIPassportSSO接口实现类相对路径,如不继承IPassportSSO接口则不用填写实现类路径 -->
<!-- 如果配置了自己应用的登录登出,可在自己应用中放入个性化登录数据、信息等, 例如test.cn.gov.customs.ssoDemo.PassPortSSO;请根据实际情况判断是否实现此接口 -->
<configValue key="PassportManager"></configValue>
</group>
</module>
<module name="h4a_default">
<group name="wcf_default">
<configValue key="default_cache_max_capacity">10000</configValue><!--默认值-->
<configValue key="default_BaseView">CCIC_VIEW</configValue><!--基本视觉-->
<configValue key="default_Application_nam">NJTJ</configValue><!--应用名称-->
<configValue key="orgValue">中国海关\\南京海关</configValue><!--应用名称-->
<!--<configValue key="orgValue">海关总署</configValue>-->
</group>
<group name="Intercepter_load_switch">
<configValue key="Intercepter_Control">false</configValue><!--默认值即可-->
</group>
</module>
<module name="object_param">
<!-- FrameworkUserInit.initUserObject 中使用的动态配置参数:getBeanObjectsDetail_lastParam为 oguBeanReaderHelper.getBeanObjectsDetail最后一个参数;organizationCategory_lastParam为iOguBeanReader.getBeanObjectParentOrganizations最后一个参数 -->
<group name="parameter_obj">
<configValue key="getBeanObjectsDetail_lastParam">PERSON_ID,SIDELINE</configValue>
<configValue key="organizationCategory_lastParam">CUSTOMS_CODE</configValue>
</group>
</module>
</application>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# sdk-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<application>
<module name="h4aIdentity">
<!-- 海关H4A接口服务地址示例,以下为示例地址。请按照实际环境进行配置,请与H4A人员联系 -->
<group name="wsAddress">
<!-- 身份服务:OguReaderService;授权服务:AccreditReaderService;应用注册服务:RegisterAppService -->
<configValue key="OguReaderService">http://192.168.202.101/CupaaCenterService/OguReaderService.svc</configValue>
<configValue key="AccreditReaderService">http://192.168.202.101:8085/CupaaDistributedService/AccreditReaderService.svc</configValue>
<configValue key="RegisterAppService">http://192.168.202.101/AppRegisterService/RegisterAppReaderService.svc</configValue>
</group>
</module>
<module name="passportSSO">
<!-- 海关H4A单点登录地址示例,以下为示例地址。请按照实际环境进行配置 -->
<group name="url">
<!--示例: H4A供参考-->
<!-- authenticateUrl uri是认证地址-->
<configValue key="authenticateUrl">http://192.168.202.101/Passport/SsoLogin.aspx</configValue>
<configValue key="logOffUrl">http://192.168.202.101/Passport/LogOff.aspx</configValue>
</group>
</module>
</application>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 前端集成
# 文件 .env
# 登录启用 H4A
VITE_TG_LOGIN_H4A = 'true'
# H4A 访问的前端地址: 如果访问地址有变更,请配置如下字段
VITE_H4A_URL = 'http://localhost:60002/#/login'
1
2
3
4
5
2
3
4
5
# 注意事项
- 公司权限平台无需部署
- 权限平台的菜单树如有更新, 需要一起更新menu.json
- 用户数据从H4A获取
# 错误说明
错误码 | 说明 | 解决办法 |
---|---|---|
20101 | h4aToken异常, 请重新登录 | h4a登录成功返回的token后端验证不通过, 这个要排查h4a配置文件 |
20102 | h4aToken后台登录异常, 请联系管理员 | 后端解析token成功, 登录获取h4a的菜单失败, 这个要排查h4a配置文件 |
20103 | h4a后端没有配置h4a, 请联系管理员 | 后端代码没有整合h4a, 参考上面的整合方法 |
上次更新: 2023/11/12 11:02:35