上一篇:
官方文档:
1.添加依赖
在cas-4.2.0\cas-server-support-jdbc目录下找到
QueryAndEncodeDatabaseAuthenticationHandler.java
将@Component("queryAndEncodeDatabaseAuthenticationHandler")注释掉
因为目前没有用到这个功能,不注释掉在后续启动tomcat时会报错
在cas-4.2.0\cas-server-support-jdbc目录下打开命令提示符界面输入
gradle assemble
得到cas-server-support-jdbc-4.2.0.jar
将cas-server-support-jdbc-4.2.0.jar和oracle驱动拷贝到apache-tomcat-7.0.68\webapps\cas\WEB-INF\lib
2.创建表
仅供测试用
DROP TABLE "PLATFORM"."P_USER";CREATE TABLE "PLATFORM"."P_USER" ("USERNAME" VARCHAR2(255 BYTE) NULL ,"PASSWORD" VARCHAR2(255 BYTE) NULL )LOGGINGNOCOMPRESSNOCACHE;-- ------------------------------ Records of P_USER-- ----------------------------INSERT INTO "PLATFORM"."P_USER" VALUES ('123', '111');
3.配置
按照官方文档即可
在deployerConfigContext.xml里添加
注释掉
在cas.properties里添加
# == Basic database connection pool configuration ==database.driverClass=org.postgresql.Driver database.url=jdbc:postgresql://database.example.com/cas?ssl=true database.user=somebody database.password=meaningless database.pool.minSize=6 database.pool.maxSize=18# Maximum amount of time to wait in ms for a connection to become# available when the pool is exhausteddatabase.pool.maxWait=10000# Amount of time in seconds after which idle connections# in excess of minimum size are pruned.database.pool.maxIdleTime=120# Number of connections to obtain on pool exhaustion condition.# The maximum pool size is always respected when acquiring# new connections.database.pool.acquireIncrement=6# == Connection testing settings ==# Period in s at which a health query will be issued on idle# connections to determine connection liveliness.database.pool.idleConnectionTestPeriod=30# Query executed periodically to test healthdatabase.pool.connectionHealthQuery=select 1# == Database recovery settings ==# Number of times to retry acquiring a _new_ connection# when an error is encountered during acquisition.database.pool.acquireRetryAttempts=5# Amount of time in ms to wait between successive aquire retry attempts.database.pool.acquireRetryDelay=2000cas.jdbc.authn.query.sql=SELECT u.PASSWORD password FROM P_USER u WHERE u.USERNAME=?
4.测试
启动tomcat
访问:
输入用户名,错误的密码
输入用户名,正确的密码