关于cas单点登录的问题

hwoarang77 2011-07-29 10:05:33
请教各位高手 关于cas取用户信息的问题 我想取更多的信息
客户端还有服务器端jdbc验证能实现 用户名使用CASFilter能取到
我现在想我想取更多的信息
我发下各种配置

首先是cas-server的deployerConfigContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="authenticationManager"
class="org.jasig.cas.authentication.AuthenticationManagerImpl">
<property name="credentialsToPrincipalResolvers">
<list>
<bean
class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" >
<property name="attributeRepository" ref="attributeRepository" />
</bean>
<bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
</list>
</property>

<property name="authenticationHandlers">
<list>
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" />
<!-- jdbc -->
<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="sql" value="select flag from tiger where code=?" />
<property name="dataSource" ref="dataSource" />
</bean>
</list>
</property>
</bean>
<!-- jdbc DataSource -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://68.137.59.182:3306/dbgateway</value></property>
<property name="username"><value>new</value></property>
<property name="password"><value>fitpass</value></property>
</bean>


<bean id="userDetailsService" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap">
<value>

</value>
</property>
</bean>

<bean id="attributeRepository"
class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
<constructor-arg index="0" ref="dataSource"/>

<constructor-arg index="1" value="select * from tiger where {0}"/>
<property name="queryAttributeMapping">
<map>

<entry key="code" value="code"/>
</map>
</property>
<property name="resultAttributeMapping">
<map>
<entry key="code" value="code"/>
<entry key="city" value="city"/>
<entry key="flag" value="flag"/>
</map>
</property>
</bean>

<bean
id="serviceRegistryDao"
class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl" />
</beans>


...全文
492 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaoxibo 2013-04-06
  • 打赏
  • 举报
回复
引用 4 楼 zcbenniao 的回复:
我的搞定了,原来是数据库设定问题,表没有忽略大小写,造成SQL出错,楼主看看是否同样问题啊
怎么更正的?
zcbenniao 2011-08-02
  • 打赏
  • 举报
回复
我的搞定了,原来是数据库设定问题,表没有忽略大小写,造成SQL出错,楼主看看是否同样问题啊
zcbenniao 2011-08-01
  • 打赏
  • 举报
回复
我也遇到了同样的错误,求解
hwoarang77 2011-07-29
  • 打赏
  • 举报
回复
然后是cas_server\WEB-INF\view\jsp\protocol\2.0下casServiceValidationSuccess.jsp这个文件

<%@ page session="false" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %><cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
<cas:authenticationSuccess>
<cas:user>${fn:escapeXml(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.id)}</cas:user>

<c:if test="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes) > 0}">
<cas:attributes>
<c:forEach var="attr" items="${assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes}">
<cas:attribute>
<cas:name>${fn:escapeXml(attr.key)}</cas:name>
<cas:value>${fn:escapeXml(attr.value)}</cas:value>
</cas:attribute>
</c:forEach>
</cas:attributes>
</c:if>
</cas:authenticationSuccess>

</cas:serviceResponse>
然后我在客户端取不到信息 报空指针异常
AttributePrincipal principal=(AttributePrincipal) request.getUserPrincipal();
String string = principal.getAttributes().get("city").toString();

错如如下

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.engine.ActionExecutionException: Exception thrown executing [AnnotatedAction@53ecec targetAction = org.jasig.cas.web.flow.AuthenticationViaFormAction@825459, attributes = map['method' -> 'submit']] in state 'submit' of flow 'login-webflow' -- action execution attributes were 'map['method' -> 'submit']'; nested exception is java.lang.NullPointerException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:115)
org.inspektr.common.web.ClientInfoThreadLocalFilter.doFilterInternal(ClientInfoThreadLocalFilter.java:48)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


root cause

org.springframework.webflow.engine.ActionExecutionException: Exception thrown executing [AnnotatedAction@53ecec targetAction = org.jasig.cas.web.flow.AuthenticationViaFormAction@825459, attributes = map['method' -> 'submit']] in state 'submit' of flow 'login-webflow' -- action execution attributes were 'map['method' -> 'submit']'; nested exception is java.lang.NullPointerException
org.springframework.webflow.engine.ActionExecutor.execute(ActionExecutor.java:64)
org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:156)
org.springframework.webflow.engine.State.enter(State.java:191)
org.springframework.webflow.engine.Transition.execute(Transition.java:212)
org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)
org.springframework.webflow.engine.impl.RequestControlContextImpl.signalEvent(RequestControlContextImpl.java:205)
org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:161)
org.springframework.webflow.engine.State.enter(State.java:191)
org.springframework.webflow.engine.Transition.execute(Transition.java:212)
org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)
org.springframework.webflow.engine.impl.RequestControlContextImpl.signalEvent(RequestControlContextImpl.java:205)
org.springframework.webflow.engine.impl.FlowExecutionImpl.signalEvent(FlowExecutionImpl.java:202)
org.springframework.webflow.executor.FlowExecutorImpl.resume(FlowExecutorImpl.java:222)
org.springframework.webflow.executor.support.FlowRequestHandler.handleFlowRequest(FlowRequestHandler.java:111)
org.springframework.webflow.executor.mvc.FlowController.handleRequestInternal(FlowController.java:165)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:115)
org.inspektr.common.web.ClientInfoThreadLocalFilter.doFilterInternal(ClientInfoThreadLocalFilter.java:48)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


root cause

java.lang.NullPointerException
org.jasig.cas.authentication.principal.AbstractPersonDirectoryCredentialsToPrincipalResolver.resolvePrincipal(AbstractPersonDirectoryCredentialsToPrincipalResolver.java:55)
org.jasig.cas.authentication.AuthenticationManagerImpl.authenticate(AuthenticationManagerImpl.java:124)
org.jasig.cas.CentralAuthenticationServiceImpl.createTicketGrantingTicket(CentralAuthenticationServiceImpl.java:417)
org.jasig.cas.web.flow.AuthenticationViaFormAction.submit(AuthenticationViaFormAction.java:107)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:592)
org.springframework.webflow.util.DispatchMethodInvoker.invoke(DispatchMethodInvoker.java:99)
org.springframework.webflow.action.MultiAction.doExecute(MultiAction.java:133)
org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:192)
org.springframework.webflow.engine.AnnotatedAction.execute(AnnotatedAction.java:146)
org.springframework.webflow.engine.ActionExecutor.execute(ActionExecutor.java:59)
org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:156)
org.springframework.webflow.engine.State.enter(State.java:191)
org.springframework.webflow.engine.Transition.execute(Transition.java:212)
org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)
org.springframework.webflow.engine.impl.RequestControlContextImpl.signalEvent(RequestControlContextImpl.java:205)
org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:161)
org.springframework.webflow.engine.State.enter(State.java:191)
org.springframework.webflow.engine.Transition.execute(Transition.java:212)
org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)
org.springframework.webflow.engine.impl.RequestControlContextImpl.signalEvent(RequestControlContextImpl.java:205)
org.springframework.webflow.engine.impl.FlowExecutionImpl.signalEvent(FlowExecutionImpl.java:202)
org.springframework.webflow.executor.FlowExecutorImpl.resume(FlowExecutorImpl.java:222)
org.springframework.webflow.executor.support.FlowRequestHandler.handleFlowRequest(FlowRequestHandler.java:111)
org.springframework.webflow.executor.mvc.FlowController.handleRequestInternal(FlowController.java:165)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:115)
org.inspektr.common.web.ClientInfoThreadLocalFilter.doFilterInternal(ClientInfoThreadLocalFilter.java:48)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

请问大家怎么解决。。。
ab370259970 2011-07-29
  • 打赏
  • 举报
回复
顶 求解

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧