- 浏览: 531117 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (278)
- freemarker (6)
- flex应用 (12)
- Ext应用 (11)
- 软件 (16)
- java (61)
- 报表 (6)
- 框架基础 (6)
- 登录页面素材 (7)
- oracle (1)
- cas (10)
- lucene (6)
- linux (11)
- 视频 (10)
- springmvc (3)
- 视频服务器相关 (12)
- 开发工具 (7)
- IOS (20)
- 网站相关 (4)
- Java 任务调度系统带图形界面的 (1)
- maven (2)
- android (29)
- hadoop (3)
- SpagoBI (3)
- docx4j (4)
- 多线程 (2)
- storm (2)
- mobile 框架 (3)
- scala (1)
- socket (1)
- saiku (1)
最新评论
-
ZXCLTN:
1.streams目录,在里面放些flv,mp3之类的文件,这 ...
red5 整合到tomcat中(二) -
ZXCLTN:
写的没偷没尾的,还不如提供整个项目下载
red5 整合到tomcat中(二) -
01jiangwei01:
测试方法1:测试50个线 ...
hibernate 乐观锁 测试 -
01jiangwei01:
测试方法1:测试50个线程,同时并发访问。目标:只有一个通过, ...
hibernate 乐观锁 测试 -
xiaobadi:
你每次登陆都是跳到http://localhost:8081/ ...
cas 系统实例 服务端配置(二) 自定义登录
1,修改org.jasig.cas.web.flow.InitialFlowSetupAction.java将pathPopulated属性改为public
2,在web.xm中添加
<servlet-mapping> <servlet-name>cas</servlet-name> <url-pattern>/noflow</url-pattern> </servlet-mapping>
3,在cas-servlet.xml中添加
<bean id="noflowLoginController" class="org.jasig.cas.web.my.noflowlogin.noFlowLoginAction" p:argumentExtractors-ref="argumentExtractors" p:warnCookieGenerator-ref="warnCookieGenerator" p:centralAuthenticationService-ref="centralAuthenticationService" p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator" p:initialFlowSetupAction-ref="initialFlowSetupAction" ></bean>
修改bean,黑体为新增
<bean id="handlerMappingC" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/logout"> logoutController </prop> <prop key="/serviceValidate"> serviceValidateController </prop> <prop key="/validate"> legacyValidateController </prop> <prop key="noflow"> noflowLoginController </prop> <prop key="/proxy"> proxyController </prop> <prop key="/proxyValidate"> proxyValidateController </prop> <prop key="/samlValidate"> samlValidateController </prop> <prop key="/services/add.html"> addRegisteredServiceSimpleFormController </prop> <prop key="/services/edit.html"> editRegisteredServiceSimpleFormController </prop> <prop key="/services/loggedOut.html"> serviceLogoutViewController </prop> <prop key="/services/viewStatistics.html"> viewStatisticsController </prop> <prop key="/services/*">manageRegisteredServicesMultiActionController</prop> <prop key="/openid/*">openIdProviderController</prop> <prop key="/authorizationFailure.html">passThroughController</prop> <prop key="/403.html">passThroughController</prop> </props> </property> <property name="alwaysUseFullPath" value="true" /> <!-- uncomment this to enable sending PageRequest events. <property name="interceptors"> <list> <ref bean="pageRequestHandlerInterceptorAdapter" /> </list> </property> --> </bean>
4,noFlowLoginAction类的具体内容为:
import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.NotEmpty; import org.jasig.cas.CentralAuthenticationService; import org.jasig.cas.authentication.principal.Credentials; import org.jasig.cas.authentication.principal.Service; import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; import org.jasig.cas.ticket.TicketException; import org.jasig.cas.web.flow.InitialFlowSetupAction; import org.jasig.cas.web.support.ArgumentExtractor; import org.jasig.cas.web.support.CookieRetrievingCookieGenerator; import org.jasig.cas.web.support.WebUtils; import org.springframework.util.StringUtils; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.AbstractController; import org.springframework.web.servlet.view.RedirectView; public class noFlowLoginAction extends AbstractController { @NotNull private CentralAuthenticationService centralAuthenticationService; @NotNull private CookieRetrievingCookieGenerator warnCookieGenerator; @NotNull private CookieRetrievingCookieGenerator ticketGrantingTicketCookieGenerator; private InitialFlowSetupAction initialFlowSetupAction; /** Extractors for finding the service. */ @NotEmpty private List<ArgumentExtractor> argumentExtractors; protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { String uName = request.getParameter("username"); String password = request.getParameter("password"); Credentials credentials =new UsernamePasswordCredentials(uName,password); if (!this.initialFlowSetupAction.pathPopulated) { final String contextPath = request.getContextPath(); final String cookiePath = StringUtils.hasText(contextPath) ? contextPath + "/" : "/"; logger.info("Setting path for cookies to: " + cookiePath); this.warnCookieGenerator.setCookiePath(cookiePath); this.ticketGrantingTicketCookieGenerator.setCookiePath(cookiePath); this.initialFlowSetupAction.pathPopulated = true; } final Service service = WebUtils.getService( this.argumentExtractors, request); String ticketGrantingTicketId=""; String serviceTicket = ""; try { ticketGrantingTicketId = this.centralAuthenticationService.createTicketGrantingTicket(credentials); /*** * 产生新的票据,并将票据及服务记录在缓存中 */ serviceTicket= this.centralAuthenticationService.grantServiceTicket(ticketGrantingTicketId,service); this.ticketGrantingTicketCookieGenerator.removeCookie(response); this.ticketGrantingTicketCookieGenerator.addCookie(request, response, ticketGrantingTicketId); this.warnCookieGenerator.addCookie(request, response, "true"); } catch (TicketException e) { e.printStackTrace(); } return new ModelAndView(new RedirectView(request.getParameter("service")+"?ticket="+serviceTicket)); } public void setWarnCookieGenerator(final CookieRetrievingCookieGenerator warnCookieGenerator) { this.warnCookieGenerator = warnCookieGenerator; } public void setArgumentExtractors( final List<ArgumentExtractor> argumentExtractors) { this.argumentExtractors = argumentExtractors; } public final void setCentralAuthenticationService(final CentralAuthenticationService centralAuthenticationService) { this.centralAuthenticationService = centralAuthenticationService; } public void setTicketGrantingTicketCookieGenerator( final CookieRetrievingCookieGenerator ticketGrantingTicketCookieGenerator) { this.ticketGrantingTicketCookieGenerator = ticketGrantingTicketCookieGenerator; } public void setInitialFlowSetupAction( InitialFlowSetupAction initialFlowSetupAction) { this.initialFlowSetupAction = initialFlowSetupAction; } }
5,使用方法是:
<form action="http://localhost:8081/casserver/noflow" method="post"> <table> <input type="hidden" id="targetService" name="service" value="http://localhost:8081/casclient4/sso/index.jsp"> <input type="hidden" name="failpae" value="http://localhost:8081/casclient4/index.jsp"> <table> <tr> <td>用户名:</td> <td><input type="text" name="username"></td> </tr> <tr> <td>密 码:</td> <td><input type="password" name="password"></td> </tr> <tr><td>验证码</td> <td><input type="text" /><img src="http://localhost:8081/casserver/random" class="sign_img fl mt5" /></td></tr> <tr> <td colspan="2"><input type="submit" value="登陆" /></td> </tr> </table> </table> </form>
6,你可以自己测试了
评论
4 楼
wqmain
2013-04-28
你好,按照你的配置,我下面这行在运行是报错:
serviceTicket = this.centralAuthenticationService.grantServiceTicket(ticketGrantingTicketId, service);
报错如下:
debug发现参数service为空,但argumentExtractors集合是有内容的,请问原因?我cas服务端版本3.5 访问方式:http://localhost/cas/noflow?username=abc&password=123
serviceTicket = this.centralAuthenticationService.grantServiceTicket(ticketGrantingTicketId, service);
报错如下:
java.lang.IllegalArgumentException: 'resourceOperatedUpon' cannot be null. Check the correctness of @Audit annotation at the following audit point: execution(public abstract java.lang.String org.jasig.cas.CentralAuthenticationService.grantServiceTicket(java.lang.String,org.jasig.cas.authentication.principal.Service)) at com.github.inspektr.audit.AuditActionContext.assertNotNull(AuditActionContext.java:81) at com.github.inspektr.audit.AuditActionContext.<init>(AuditActionContext.java:64) at com.github.inspektr.audit.AuditTrailManagementAspect.executeAuditCode(AuditTrailManagementAspect.java:149) at com.github.inspektr.audit.AuditTrailManagementAspect.handleAuditTrail(AuditTrailManagementAspect.java:139) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597)
debug发现参数service为空,但argumentExtractors集合是有内容的,请问原因?我cas服务端版本3.5 访问方式:http://localhost/cas/noflow?username=abc&password=123
3 楼
kevinpan45
2012-11-07
你好,Credentials credentials =new UsernamePasswordCredentials(uName,password);这个代码提示没有这种构造方法。我用这样的方法构造,但是用credentials 生成ticket的时候
ticketGrantingTicketId = this.centralAuthenticationService
.createTicketGrantingTicket(credentials);
报了这个异常
TicketCreationException: error.authentication.credentials.bad
请问你的CAS SERVER是什么版本
引用
ticketGrantingTicketId = this.centralAuthenticationService
.createTicketGrantingTicket(credentials);
报了这个异常
引用
TicketCreationException: error.authentication.credentials.bad
请问你的CAS SERVER是什么版本
2 楼
01jiangwei01
2012-06-05
查看“cas 系统实例 客户端配置” 解决你的问题
1 楼
tiansskk
2012-05-09
不错很有用,那如何在客户端取值?
发表评论
-
cas 进阶篇二
2013-02-16 22:45 1194保存,并重新启动服务,输入用户名密码,进行登录。 4,通 ... -
cas 进阶篇一
2013-02-16 22:42 1424可以自己参考网站http://www.ja-sig.org ... -
cas 关注资料
2012-04-18 13:50 105网址一:http://hi.baidu.com/%D3%D2% ... -
cas 系统实例 客户配置(四) 访问受保护资源跳转到自定义登录页面
2012-03-20 15:25 3619方法和简单。就是在客户端web.xml的配置中。 <f ... -
cas 系统实例 配置及使用
2012-03-15 17:46 1285我个人想法使用方式是: 登录,采用客户端登录 找回密码:采 ... -
cas 系统实例 服务端配置(三) 退出到指定页面
2012-03-15 17:34 2457CAS退出默认是转向CAS内置的退出页面,在实际应用中需要跳转 ... -
cas 系统实例 服务端配置(二) 自定义登录
2012-03-15 16:55 6385学习一下,自定义登录 在web.xml中增加remoteLo ... -
cas 系统实例 客户端配置
2012-03-15 16:49 26931.解压后把modules下面的包放到我们的web应用中 2 ... -
cas 系统实例 服务端配置(一)
2012-03-01 15:39 2874最近在研究cas 并对其进行改版,终于有所成就,写出来与大 ... -
cas 简单配置 不用证书
2012-02-24 16:17 2157cas单点登录配置速成 服务端配置 ca ...
相关推荐
NULL 博文链接:https://01jiangwei01.iteye.com/blog/1434200
包含cas源码、cas使用说明文档(包含配置信息)、连接数据库所需jar包、cas服务端自定义返回值等
详细描述了cas 自定义登陆页面的配置与demo
NULL 博文链接:https://starbhhc.iteye.com/blog/2302902
[置顶] SSO单点登录系列3:cas-server端配置认证方式实践(数据源+自定义java类认证) http://blog.csdn.net/ae6623/article/details/8851801 [置顶] SSO单点登录系列2:cas客户端和cas服务端交互原理动画图解,cas...
直接可以对cas-server项目进行打不,部署到tomcat,即可使用,记得修改cas-server的数据库连接地址哦 单点登录服务端项目cas-server 单点登录服务端项目cas-server 单点登录服务端项目cas-server 单点登录服务端项目...
这是我的博文http://blog.csdn.net/jadyer/article/details/46916169中的完整代码
cas原理 webflow mvc ioc 登陆流程
cas4.2.7服务端+cas客户端+示例程序+环境搭建之客户端war包 一切跑不起来的程序和走不通的...该客户端的这个URL还演示了如何调用cas服务端获取当前登录用户的相关信息(由服务端负责从数据库中读取后返回给cas客户端)。
服务端 的war内我已经对WEB-INF文件夹中的web.xml文件、deployerConfigContext.xml文件、view目录内的jsp文件以及classes的services下的json配置文件做过修改。除了cas默认支持的功能外,该war包还实现了:登录页面...
CAS单点登录服务端部署
CAS4.1.4服务端和客户端实例,直接修改配置即可运行,详细参见博文:http://blog.csdn.net/chenhai201/article/details/50623395
这是boot2.0+shiro+pac4j+cas 整合项目 cas还可以自定义登陆页和认证校验数据库
CAS 是 Central Authentication Service 的缩写 —— 中央认证服务,一种独立开放指令协议,是 Yale 大学发起的一个企业级开源项目,旨在为 Web 应用系统提供一种可靠的 SSO 解决方案。 CAS 支持以下特性: CAS v1, ...
cas4.0版本的 单点登录 自定义页面。希望对你有用,最低资源分,辛苦分。有问题可以交流学习。谢谢
对应博客:https://blog.csdn.net/fancheng614/article/details/84038266
这是已经调整过的cas服务端,maven项目 已完成内容 登录页面已做调整 验证码功能 记住我功能 多数据源支持(根据传入参数client确定用哪个数据源和sql语句) 运行该项目 先建立sys_account表,直接导入sys_...
CAS(Central Authentication Service)是一款不错的针对 Web 应用的单点登录框架,本文介绍了 CAS 的原理、协议、在 Tomcat 中的配置和使用,研究如何采用 CAS 实现轻量级单点登录解决方案。 CAS 是 Yale 大学发起的...
完整项目在https://download.csdn.net/download/u010588262/10327539 这个资源是新增功能之后的main文件夹 对应博客系列:https://blog.csdn.net/u010588262/article/category/7548325 对应博客这篇:...