##CAS4.0配置Mysql数据库,认证失败
真崩溃啊,看别人的视频都能成功,自己研究一下午了,也还是不行。问题出在哪儿呢?请大神指教。


三个jar包:


代码片.

<?xml version="1.0" encoding="UTF-8"?>
<!--Licensed to Jasig under one or more contributor licenseagreements. See the NOTICE file distributed with this workfor additional information regarding copyright ownership.Jasig licenses this file to you under the Apache License,Version 2.0 (the "License"); you may not use this fileexcept in compliance with the License.  You may obtain acopy of the License at the following location:http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied.  See the License for thespecific language governing permissions and limitationsunder the License.-->
<!--
| deployerConfigContext.xml centralizes into one file some of the declarative configuration that
| all CAS deployers will need to modify.
|
| This file declares some of the Spring-managed JavaBeans that make up a CAS deployment.
| The beans declared in this file are instantiated at context initialization time by the Spring
| ContextLoaderListener declared in web.xml.  It finds this file because this
| file is among those declared in the context parameter "contextConfigLocation".
|
| By far the most common change you will need to make in this file is to change the last bean
| declaration to replace the default authentication handler with
| one implementing your approach for authenticating usernames and passwords.
+--><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:c="http://www.springframework.org/schema/c"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:util="http://www.springframework.org/schema/util"xmlns:sec="http://www.springframework.org/schema/security"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsdhttp://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"><!--| The authentication manager defines security policy for authentication by specifying at a minimum| the authentication handlers that will be used to authenticate credential. While the AuthenticationManager| interface supports plugging in another implementation, the default PolicyBasedAuthenticationManager should| be sufficient in most cases.+--><!-- 认证管理器authenticationManager--><bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager"><constructor-arg><map><!--| IMPORTANT| Every handler requires a unique name.| If more than one instance of the same handler class is configured, you must explicitly| set its name to something other than its default name (typically the simple class name).--><!-- 这个保留,试试去掉行不行:不影响登界面但是用户数据库认证还是通不过<entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />--><!--这个被我注释掉了,20200703,目的是指定自己的本地数据库进行访问,<entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" />--><!--这个没调试好,只要打开网页就访问不到!!!!!!!!!!!! (因为dbAuthHandler里写的东西有问题,改了就好了)第一个操作点!!!:key-ref指定自己的本地数据库访问,配置如下--><entry key-ref="dbAuthHandler" value-ref="primaryPrincipalResolver"/></map></constructor-arg><!-- Uncomment the metadata populator to allow clearpass to capture and cache the passwordThis switch effectively will turn on clearpass.<property name="authenticationMetaDataPopulators"><util:list><bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator"c:credentialCache-ref="encryptedMap" /></util:list></property>--><!--| Defines the security policy around authentication. Some alternative policies that ship with CAS:|| * NotPreventedAuthenticationPolicy - all credential must either pass or fail authentication| * AllAuthenticationPolicy - all presented credential must be authenticated successfully| * RequiredHandlerAuthenticationPolicy - specifies a handler that must authenticate its credential to pass--><property name="authenticationPolicy"><bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" /></property></bean><!-- Required for proxy ticket mechanism. --><bean id="proxyAuthenticationHandler"class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"p:httpClient-ref="httpClient" /><!--| TODO: Replace this component with one suitable for your enviroment.|| This component provides authentication for the kind of credential used in your environment. In most cases| credential is a username/password pair that lives in a system of record like an LDAP directory.| The most common authentication handler beans:|| * org.jasig.cas.authentication.LdapAuthenticationHandler| * org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler| * org.jasig.cas.adaptors.x509.authentication.handler.support.X509CredentialsAuthenticationHandler| * org.jasig.cas.support.spnego.authentication.handler.support.JCIFSSpnegoAuthenticationHandler--><!-- 下边这个配置是默认静态配置用户名和密码,那就在浏览器的CAS服务的登陆框中输入用户名casuser和密码Mellon,登录看看效果,就会出现验证成功的页面,如下图。你也可以在文件中自己配置自己的用户名和密码。--><!--第二个操作点!!!:将默认的用户名和密码注释,其实上边的此种登陆方式已经被注释掉了,这里留着也没影响--><bean id="primaryAuthenticationHandler"class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler"><property name="users"><map><entry key="casuser" value="Mellon"/><entry key="admin" value="admin"/></map></property></bean><!-- Required for proxy ticket mechanism --><bean id="proxyPrincipalResolver"class="org.jasig.cas.authentication.principal.BasicPrincipalResolver" /><!--| Resolves a principal from a credential using an attribute repository that is configured to resolve| against a deployer-specific store (e.g. LDAP).--><bean id="primaryPrincipalResolver"class="org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver" ><property name="attributeRepository" ref="attributeRepository" /></bean><!--Bean that defines the attributes that a service may return.  This example uses the Stub/Mock version.  A real implementationmay go against a database or LDAP server.  The id should remain "attributeRepository" though.+--><bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao"p:backingMap-ref="attrRepoBackingMap" /><util:map id="attrRepoBackingMap"><entry key="uid" value="uid" /><entry key="eduPersonAffiliation" value="eduPersonAffiliation" /> <entry key="groupMembership" value="groupMembership" /></util:map><!-- Sample, in-memory data store for the ServiceRegistry. A real implementationwould probably want to replace this with the JPA-backed ServiceRegistry DAOThe name of this bean should remain "serviceRegistryDao".+--><bean id="serviceRegistryDao" class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl"p:registeredServices-ref="registeredServicesList" /><util:list id="registeredServicesList"><bean class="org.jasig.cas.services.RegexRegisteredService"p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols"p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001" /><!--Use the following definition instead of the above to further restrict accessto services within your domain (including sub domains).Note that example.com must be replaced with the domain you wish to permit.This example also demonstrates the configuration of an attribute filterthat only allows for attributes whose length is 3.--><!--<bean class="org.jasig.cas.services.RegexRegisteredService"><property name="id" value="1" /><property name="name" value="HTTP and IMAP on example.com" /><property name="description" value="Allows HTTP(S) and IMAP(S) protocols on example.com" /><property name="serviceId" value="^(https?|imaps?)://([A-Za-z0-9_-]+\.)*example\.com/.*" /><property name="evaluationOrder" value="0" /><property name="attributeFilter"><bean class="org.jasig.cas.services.support.RegisteredServiceRegexAttributeFilter" c:regex="^\w{3}$" /> </property></bean>--></util:list><bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" /><bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor" p:monitors-ref="monitorsList" /><util:list id="monitorsList"><bean class="org.jasig.cas.monitor.MemoryMonitor" p:freeMemoryWarnThreshold="10" /><!--NOTEThe following ticket registries support SessionMonitor:* DefaultTicketRegistry* JpaTicketRegistryRemove this monitor if you use an unsupported registry.--><bean class="org.jasig.cas.monitor.SessionMonitor"p:ticketRegistry-ref="ticketRegistry"p:serviceTicketCountWarnThreshold="5000"p:sessionCountWarnThreshold="100000" /></util:list><!-- 再在这个xml中新加入2个bean配置, 第三个操作点!!!:1、指定c3p0数据源(连接池);
注意,改了一下user,改成了username就会报404,所以必须是user    --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"p:driverClass="com.mysql.jdbc.Driver"p:jdbcUrl="jdbc:mysql://127.0.0.1:3306/myproject?characterEncoding=uft8"p:user="root"p:password="123123" /><!-- 第四个操作点!!!:2、查询匹配的字段。-->    <bean id="dbAuthHandler"class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"p:dataSource-ref="dataSource"p:sql="SELECT password FROM sec_user WHERE username = ?" /></beans>

CAS4.0配置Mysql数据库,认证失败相关推荐

  1. 【入门】Spring-Boot项目配置Mysql数据库

    前言 前面参照SpringBoot官网,自动生成了简单项目点击打开链接 配置数据库和代码遇到的问题 问题1:cannot load driver class :com.mysql.jdbc.Drive ...

  2. django mysql开发_【python-Django开发】Django 配置MySQL数据库讲解!!!

    官方文档请阅读:https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-db-api-drivers 配置MySQL数据库 1. 新建M ...

  3. 配置MySQL数据库单机多实例

    一.什么是MySQL多实例 简单的说就是在一台机器上开启多个不同的服务端口(例如:3306.3307),运行多个mysql服务进程,这些服务进程通过不同的socket监听不同的服务端口来提供各自的服务 ...

  4. 【django】配置MySQL数据库【3】

    一.新建MySQL数据库 1.登录数据库 $mysql -u root -p 2.新建mgdb数据库 $create database mgdb default charset=utf8; 3.新建M ...

  5. 配置mysql数据库时出再错误:LookupError No installed app with label admin(亲测)

    版本: windows10+py37+django2.2 错误: 项目启动时出现,No installed app with label 'admin' 解决办法: 安装最新的 pip install ...

  6. LINUX 下 配置MySQL数据库集群

    LINUX 下 配置MySQL数据库集群 MySQL数据库集群进行正确配置步骤(1) 此文章主要向大家讲述的是对MySQL数据库集群进行正确配置的实际操作步骤,以及对其概念的讲述,如果你对其相关的实际 ...

  7. dw2019连接mysql数据库_Dreamweaver 8.0连接Mysql数据库全攻略

    1 Dreamweaver 8.0 连接 Mysql 数据库全攻略 一.所需安装文件清单: 1 . Dreamweaver8.0 2 . SP2DBFix1.0.2.mxp ( Dreamweaver ...

  8. jdbctemplate mysql 配置_Spring Boot 初级入门教程(十四) —— 配置 MySQL 数据库和使用 JdbcTemplate 测试...

    经过前面几篇文章,包已经可以打了,不管是 jar 包还是 war 包都已测试通过,jsp 页面也可以访问了,但页面上的数据都是在配置文件中写死的,不爽 ~ 到目前为止,最重要的配置还没做,那就是连数据 ...

  9. Python3.7中,Django配置MySql数据库

    上一节中讲了Python3.7搭建Django框架项目 ,并且项目能够运行起来,Django框架中默认配置的数据库是sqlite,sqlite数据库虽然小巧,但是对于大型项目时sqlite就会有瓶颈, ...

最新文章

  1. 高可用 Redis 服务架构分析与搭建
  2. leetcode算法题--两数之和
  3. hdu4982 暴搜+剪枝(k个数和是n,k-1个数的和是平方数)
  4. ucos iii学习笔记——为什么选择ucos iii
  5. go操作网页元素_7天用Go动手写/从零实现分布式缓存GeeCache
  6. 零元学Expression Blend 4 ndash; Chapter 21 以实作案例学习MouseDragElementBehavior
  7. Hive安装报错:Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient的解决办法
  8. python中交换a和b的值_交换A和B之间的元素以获得和相等
  9. 通过Python实现简单的计算器
  10. centos7下的elasticsearch-6.2.4安装
  11. 现代抽象UI素材背景3D流畅的造型(样条)|轻松地为Web创建3D体验
  12. 主线程中慎用WaitForSingleObject (WaitForMultipleObjects)
  13. 机械公差与配合 常见问题
  14. 货币金融学(4): 商业银行业务/央行
  15. C++Builder:定时器Timer控件
  16. 1.两数之和(python)
  17. 小学期助教感受-Funcode游戏编程
  18. 【Hack The Box】windows练习-- Silo
  19. 在Outlook2007中设置QQ邮箱为IMAP/SMTP服务器
  20. 2022换工作面经--开课吧

热门文章

  1. dpi和css,DPI和像素、厘米、英寸之间的关系和换算及CSS中的长度单位、位深度、ppi...
  2. 快速传输大文件,怎么通过网络传大文件给对方(1G以上)
  3. Mega2560(Arduino)Bootloader烧录指南
  4. 苹果M1 芯片机密遭窃,苹果急了:还资料,赔钱!
  5. 红米5无法连接到计算机,红米手机连不上电脑如何解决_红米手机连接电脑的操作步骤...
  6. windows10图片打开找不到内置图片查看器
  7. GaussDB T / A
  8. 开发票服务器返回信息为空,使用 getinvoicebatch 批量接口获取发票信息,返回成功,但数据是空的...
  9. python文字转语音输出_Python文字转语音
  10. abp修改默认返回格式