Cas5.3服务器集成DM8 达梦数据库

Posted 在奋斗的大道

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cas5.3服务器集成DM8 达梦数据库相关的知识,希望对你有一定的参考价值。

DM8达梦数据库相关准备

1、安装DM8达梦数据库并安装相关数据库实例

省略一千字***

2、新建ucas_auth_user表,并增加相关用户条记录

 
DROP TABLE IF EXISTS `ucas_auth_user`;
CREATE TABLE `ucas_auth_user`  (
  `sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `user_pin` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '登录名',
  `user_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
  `password` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
  `gender` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别(1:男,2:女)',
  `tel` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '常用电话',
  `phone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他联系电话',
  `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电子邮件',
  `state` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '2' COMMENT '状态(1:禁用,2:启用)',
  `created_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `created_dt` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `version` int(9) NULL DEFAULT 1 COMMENT '版本号',
  `updated_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `updated_dt` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `zone_org_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区域机构',
  `organiztion_sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部门sid',
  `value1` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备用字段1',
  `value2` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备用字段2',
  `value3` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备用字段3',
  `delete_flag` int(1) NULL DEFAULT 1 COMMENT '删除标识(1:未删除,2:已删除)',
  `session_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会话Id',
  `user_category` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户类别(系统管理员\\\\安全保密管理员\\\\安全审计员\\\\普通用户)',
  `unique_sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作日志记录uuid',
  PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic;
 
 
INSERT INTO `ucas_auth_user` VALUES ('1', 'admin', '超级管理员', 'e10adc3949ba59abbe56e057f20f883e', NULL, '13726252116', NULL, '123@1.com', '2', NULL, '2019-08-13 12:09:15', 38, NULL, '2020-04-07 15:57:33', NULL, '1', NULL, NULL, NULL, 1, 'TXJMgpVJc8Vtaox6Zg9qf2oSnnrh4pdV', 'SUPER_ADMIN,SYSTEM_ADMIN', NULL);

CAS5.3配置DM8达梦相关信息

1、将DM8 数据库驱动导入本地仓库

切换至DM(达梦数据库)安装目录,我的本地安装目录在:(D:\\dmdbms)。

找到drivers驱动文件夹下的jdbc文件夹,包含驱动如下截图:

 本次演示使用的是DM8 数据库,因此我使用的是DmJdbcDriver18.jar 驱动包。

2、导入本地Maven仓库

前提条件:将DmJdbcDriver18.jar 驱动包 拷贝至E:\\jar 文件夹下,执行如下指令:

mvn install:install-file -Dfile=E:\\jar\\DmJdbcDriver18.jar -DgroupId=dm.jdbc -DartifactId=DmJdbcDriver18 -Dversion=18 -Dpackaging=jar

3、CAS5.3 之pom.xml 文件添加DM8 驱动

cas-server-webapp${app.server}所在同级dependency节点中增加以下配置

        <!--数据库认证相关 start -->
		<dependency>
			<groupId>org.apereo.cas</groupId>
			<artifactId>cas-server-support-jdbc</artifactId>
			<version>${cas.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apereo.cas</groupId>
			<artifactId>cas-server-support-jdbc-drivers</artifactId>
			<version>${cas.version}</version>
		</dependency>
        <!--mysql数据库-->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql.driver.version}</version>
		</dependency>      
        <!-- 达梦数据库驱动  -->
		<dependency>
            <groupId>dm.jdbc</groupId>
            <artifactId>DmJdbcDriver18</artifactId>
            <version>18</version>
        </dependency>
        <!--数据库认证相关 end --> 

 

CAS5.3之application.properties配置 

打开cas-overlay-template-5.3\\src\\main\\resources\\application.properties文件

 增加DM8达梦用户查询配置

##
# CAS Authentication Credentials
#
#cas.authn.accept.users=casuser::Mellon
#cas.authn.jdbc.query[0].url=jdbc:mysql:/127.0.0.1:3306/ucas?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true     
#cas.authn.jdbc.query[0].user=root
#cas.authn.jdbc.query[0].password=digipower
#cas.authn.jdbc.query[0].sql=select * from ucas_auth_user where user_pin =?
#cas.authn.jdbc.query[0].fieldPassword=password
#cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
#cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect

cas.authn.jdbc.query[0].url=jdbc:dm://127.0.0.1:5256/SYSDBA     
cas.authn.jdbc.query[0].user=SYSDBA
cas.authn.jdbc.query[0].password=SYSDBA
cas.authn.jdbc.query[0].sql=select * from ucas_auth_user where user_pin =?
cas.authn.jdbc.query[0].fieldPassword=password
cas.authn.jdbc.query[0].driverClass=dm.jdbc.driver.DmDriver

#加密策略
#采用MD5加密
cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT
cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8
#MD5加密策略
cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5

CAS5.3验证

切换至cas5.3 源码目录,再次执行脚本构建任务

D:\\cas\\cas-overlay-template-5.3>.\\build.cmd run
[INFO] Scanning for projects...
[INFO]
[INFO] Using the MultiThreadedBuilder implementation with a thread count of 5
[INFO]
[INFO] ---------------------< org.apereo.cas:cas-overlay >---------------------
[INFO] Building cas-overlay 1.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cas-overlay ---
[INFO] Deleting D:\\cas\\cas-overlay-template-5.3\\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cas-overlay ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ cas-overlay ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cas-overlay ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\\cas\\cas-overlay-template-5.3\\src\\test\\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ cas-overlay ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ cas-overlay ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ cas-overlay ---
[INFO] Packaging webapp
[INFO] Assembling webapp [cas-overlay] in [D:\\cas\\cas-overlay-template-5.3\\target\\cas]
[info] Copying manifest...
[INFO] Processing war project
[INFO] Processing overlay [ id org.apereo.cas:cas-server-webapp-tomcat]
[INFO] Webapp assembled in [5741 msecs]
[INFO] Building war: D:\\cas\\cas-overlay-template-5.3\\target\\cas.war
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.18.RELEASE:repackage (default) @ cas-overlay ---
[INFO] Layout: WAR
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.636 s (Wall Clock)
[INFO] Finished at: 2021-10-26T11:57:28+08:00
[INFO] ------------------------------------------------------------------------
[36m

     _    ____  _____ ____  _____ ___     ____    _    ____
    / \\  |  _ \\| ____|  _ \\| ____/ _ \\   / ___|  / \\  / ___|
   / _ \\ | |_) |  _| | |_) |  _|| | | | | |     / _ \\ \\___ \\
  / ___ \\|  __/| |___|  _ <| |__| |_| | | |___ / ___ \\ ___) |
 /_/   \\_\\_|   |_____|_| \\_\\_____\\___/   \\____/_/   \\_\\____/


CAS Version: 5.3.16
CAS Commit Id: 1808d979b784500d4b4dd846003a0230f326b57d
CAS Build Date/Time: 2021-10-26T03:57:27.798Z
Spring Boot Version: 1.5.18.RELEASE
Spring Version: 4.3.25.RELEASE
Java Home: C:\\jdk1.8.0_211\\jre1.8.0_211
Java Vendor: Oracle Corporation
Java Version: 1.8.0_211
JVM Free Memory: 595 MB
JVM Maximum Memory: 910 MB
JVM Total Memory: 654 MB
JCE Installed: Yes
Node Version: v14.17.6
NPM Version: N/A
OS Architecture: amd64
OS Name: Windows 10
OS Version: 10.0
OS Date/Time: 2021-10-26T11:57:34.907
OS Temp Directory: C:\\Users\\zzg\\AppData\\Local\\Temp\\
------------------------------------------------------------
Apache Tomcat Version: Apache Tomcat/8.5.47
------------------------------------------------------------

浏览器访问CAS

http://localhost:8443/cas

输入DM8达梦用户表中的用户名admin,密码123456(使用MD5加密)点击登录

 

 

至此,CAS5.3结合DM8搭建完成。 

以上是关于Cas5.3服务器集成DM8 达梦数据库的主要内容,如果未能解决你的问题,请参考以下文章

docker-compose 之 达梦数据库(dm8)

银河麒麟服务器操作系统安装达梦数据库DM8教程

达梦数据库(DM8)常用SQL学习

达梦数据库适配:DM8+SpringBoot+HiKari+MyBatis3.4.6+tk.MyBatis+PageHelper

redhat7.6安装达梦DM8数据库详细部署讲解

达梦数据库(DM8)操作问题记录及解决