大牛请进

正派青年演员 2013-03-26 05:41:52
前段时间一直忙着测试,这两天,老大又要我搞起单点登录,实在头疼,但是问题总得解决,鄙人脸皮比较厚,上次已经发过一帖了,但是没有得到实质性的解决。希望能有大牛能够指点迷津。

我的需求是,两个应用,分别是a.csdn.com和csdn.com两个域名,两个应用都有独立ip.也都有各自的服务器,一个是安装版的tomcat服务器和一个免安装版的tomcat服务器。
登录时,两个应用分别有独立的登录页面,所以,a登录了,即打开b网站,b也能登录,退出也是一样的。反之亦是如此。

所以,我觉得cas单点登录不适用于我的需求,而用cookie登录也不安全(最主要的还是自己没有弄明白怎么写)上次还试了试josso..也没有看明白。

我没有太多的开发经验,网上的确有很多资料,但是,自己一个人琢磨,英语又比较差,实在没法理解,也无法去写代码。单点登录,到底有多难?

求解?

谢谢,各位回帖大牛!
...全文
275 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ladooz 2013-10-21
  • 打赏
  • 举报
回复
引用 5 楼 AARON7744 的回复:
CAS单独作为一个module。 其他Project在配置文件里设置。
<?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:sec="http://www.springframework.org/schema/security" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

 	<!-- Load parameters from context.xml -->
  	<bean id="propertyConfigurer" class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"/>

	<sec:http entry-point-ref="casEntryPoint">
		<sec:intercept-url pattern="/xxx/xxx/**" filters="none" />
		<sec:intercept-url pattern="/xxx/**" filters="none" />
		<sec:intercept-url pattern="/xxx/**" access="ROLE_USER" />
		<sec:logout invalidate-session="true" logout-url="/logout" logout-success-url="/loggedOut.html"/>
		<sec:custom-filter position="CAS_FILTER" ref="casFilter" />
	</sec:http>
	
	<sec:authentication-manager alias="authenticationManager">
		<sec:authentication-provider ref="casAuthenticationProvider" />
	</sec:authentication-manager>
	 
	<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
		<property name="service" value="${casServiceUrl}/j_spring_cas_security_check" />
		<property name="sendRenew" value="false" />
	</bean>

	<bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
		<property name="authenticationManager" ref="authenticationManager" />
	</bean>

	<bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
		<property name="loginUrl" value="${casServerUrl}/login" />
		<property name="serviceProperties" ref="serviceProperties" />
	</bean>

	<bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
		<property name="authenticationUserDetailsService" ref="optaUserService" />
		<property name="serviceProperties" ref="serviceProperties" />
		<property name="ticketValidator">
			<bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
				<constructor-arg index="0" value="${casServerUrl}" />
			</bean>
		</property>
		<property name="key" value="an_id_for_this_auth_provider_only" />
	</bean>

	<bean id="userService" class="com.xxx.security.UserDetailService">
	    <property name="dataSource" ref="datasource"/>
	</bean>
	  
	<jee:jndi-lookup  id="datasource" jndi-name="jdbc/xxxx"/>

</beans>
这是我以前写过的一个配置文件,你可以参考一下,希望有帮助。
你好,想问下你的SpringSecurity和CAS的版本? 我现在同样要做单点登录,参照网上的配置,还是有问题,向你请教一下: 版本SpringSecurity3 + CAS3.5 要做到的效果:各子系统实现单点登录,登录页面使用各子系统的原来的登录页,可以修改。 可以做到和CAS一样的效果,就是访问一个被保护的资源,验证通过后跳转到这个被保护的资源。 我参考了网上一篇文章Cas自定义登录页面Ajax实现,经过修改后,现在可以在firebug看到服务端返回登录成功的数据,但是回调函数却不能执行,并且如果登陆成功,手动访问被保护资源还是需要再次登录,这个问题困扰了很长时间了。 怀疑是不是spring web flow的原因,首先要解决返回的回调函数不能执行,其次要解决怎么登陆成功后显示原来请求的页面。
正派青年演员 2013-03-27
  • 打赏
  • 举报
回复
引用 5 楼 AARON7744 的回复:
CAS单独作为一个module。 其他Project在配置文件里设置。
<?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:sec="http://www.springframework.org/schema/security" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

 	<!-- Load parameters from context.xml -->
  	<bean id="propertyConfigurer" class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"/>

	<sec:http entry-point-ref="casEntryPoint">
		<sec:intercept-url pattern="/xxx/xxx/**" filters="none" />
		<sec:intercept-url pattern="/xxx/**" filters="none" />
		<sec:intercept-url pattern="/xxx/**" access="ROLE_USER" />
		<sec:logout invalidate-session="true" logout-url="/logout" logout-success-url="/loggedOut.html"/>
		<sec:custom-filter position="CAS_FILTER" ref="casFilter" />
	</sec:http>
	
	<sec:authentication-manager alias="authenticationManager">
		<sec:authentication-provider ref="casAuthenticationProvider" />
	</sec:authentication-manager>
	 
	<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
		<property name="service" value="${casServiceUrl}/j_spring_cas_security_check" />
		<property name="sendRenew" value="false" />
	</bean>

	<bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
		<property name="authenticationManager" ref="authenticationManager" />
	</bean>

	<bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
		<property name="loginUrl" value="${casServerUrl}/login" />
		<property name="serviceProperties" ref="serviceProperties" />
	</bean>

	<bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
		<property name="authenticationUserDetailsService" ref="optaUserService" />
		<property name="serviceProperties" ref="serviceProperties" />
		<property name="ticketValidator">
			<bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
				<constructor-arg index="0" value="${casServerUrl}" />
			</bean>
		</property>
		<property name="key" value="an_id_for_this_auth_provider_only" />
	</bean>

	<bean id="userService" class="com.xxx.security.UserDetailService">
	    <property name="dataSource" ref="datasource"/>
	</bean>
	  
	<jee:jndi-lookup  id="datasource" jndi-name="jdbc/xxxx"/>

</beans>
这是我以前写过的一个配置文件,你可以参考一下,希望有帮助。
谢谢。我好好看看。
-AJ- 2013-03-27
  • 打赏
  • 举报
回复
CAS单独作为一个module。 其他Project在配置文件里设置。
<?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:sec="http://www.springframework.org/schema/security" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

 	<!-- Load parameters from context.xml -->
  	<bean id="propertyConfigurer" class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"/>

	<sec:http entry-point-ref="casEntryPoint">
		<sec:intercept-url pattern="/xxx/xxx/**" filters="none" />
		<sec:intercept-url pattern="/xxx/**" filters="none" />
		<sec:intercept-url pattern="/xxx/**" access="ROLE_USER" />
		<sec:logout invalidate-session="true" logout-url="/logout" logout-success-url="/loggedOut.html"/>
		<sec:custom-filter position="CAS_FILTER" ref="casFilter" />
	</sec:http>
	
	<sec:authentication-manager alias="authenticationManager">
		<sec:authentication-provider ref="casAuthenticationProvider" />
	</sec:authentication-manager>
	 
	<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
		<property name="service" value="${casServiceUrl}/j_spring_cas_security_check" />
		<property name="sendRenew" value="false" />
	</bean>

	<bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
		<property name="authenticationManager" ref="authenticationManager" />
	</bean>

	<bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
		<property name="loginUrl" value="${casServerUrl}/login" />
		<property name="serviceProperties" ref="serviceProperties" />
	</bean>

	<bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
		<property name="authenticationUserDetailsService" ref="optaUserService" />
		<property name="serviceProperties" ref="serviceProperties" />
		<property name="ticketValidator">
			<bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
				<constructor-arg index="0" value="${casServerUrl}" />
			</bean>
		</property>
		<property name="key" value="an_id_for_this_auth_provider_only" />
	</bean>

	<bean id="userService" class="com.xxx.security.UserDetailService">
	    <property name="dataSource" ref="datasource"/>
	</bean>
	  
	<jee:jndi-lookup  id="datasource" jndi-name="jdbc/xxxx"/>

</beans>
这是我以前写过的一个配置文件,你可以参考一下,希望有帮助。
正派青年演员 2013-03-27
  • 打赏
  • 举报
回复
引用 2 楼 AARON7744 的回复:
我觉得CAS没有任何问题。 不过,你想问的究竟是什么呢?
不好意思,昨天写完,没仔细检查就发出去了,我对cas的了解并不多,也不是特别理解 所以,最主要的问题是:如何将cas整合到两个应用中?
-AJ- 2013-03-26
  • 打赏
  • 举报
回复
引用 楼主 yy008871 的回复:
单点登录,到底有多难?
这是你要解决的问题么? 没法回答啊。
-AJ- 2013-03-26
  • 打赏
  • 举报
回复
我觉得CAS没有任何问题。 不过,你想问的究竟是什么呢?
长笛党希望 2013-03-26
  • 打赏
  • 举报
回复
我没有接触很多关于单点登录的项目,不过了解一些。个人愚见,这种情况可以用sso实现的。tomcat要配置ssl协议,sso建议不要用ip,可以用域名代替。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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