Как интегрировать аутентификацию CAS с Spring Security? - PullRequest
0 голосов
/ 22 марта 2012

Я интегрировал Spring Security в свой проект, и ранее я аутентифицировал детали пользователя с помощью hibernate. Теперь я должен сделать это с помощью CAS. Это мой текущий Spring security.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security 
        http://www.springframework.org/schema/security/spring-security-3.1.xsd
        ">



    <global-method-security pre-post-annotations="enabled" />

    <http pattern="/css/**" security="none"/>
    <http pattern="/images/**" security="none"/>
    <http pattern="/js/**" security="none"/>
    <http pattern="/index.jsp" security="none"/>
    <http pattern="/app/addNewUser.json" security="none"/>
    <http pattern="/dbcomplogin.jsp" security="none"/>
    <http pattern="/loggedout.jsp" security="none"/>

    <http use-expressions="true">
        <!--
             Allow all other requests. In a real application you should
             adopt a whitelisting approach where access is not allowed by default
          -->
        <intercept-url pattern="/**" access="isAuthenticated()" />
        <form-login login-page='/dbcomplogin.jsp'
          authentication-failure-url="/dbcomplogin.jsp?login_error=1"
          default-target-url="/index.jsp" />
        <logout logout-success-url="/loggedout.jsp" delete-cookies="JSESSIONID"/>
        <remember-me />

    </http>

    <beans:bean id="myUserService" class="com.tcs.ceg.services.impl.UserServiceImpl" />
    <authentication-manager>
    <authentication-provider user-service-ref="myUserService" />
    </authentication-manager>

</beans:beans>

в методе класса loadUserByUsername класса UserServiceImpl. Я использую вызов Hibernate для получения сведений о пользователе из БД, и я возвращал имя пользователя и пароль, если они существуют в БД.

Но теперь я должен сделать это, используя сервер CAS. Пожалуйста, скажите мне, что все, что мне нужно изменить, в моем файле spring-security.xml, чтобы, если пользователь не прошел аутентификацию, была открыта страница входа на сервер CAS и по щелчку на выходе произошел одиночный выход и страница выхода из CAS сервер откроется. Я новичок в CAS и весенней безопасности, поэтому, пожалуйста, помогите мне.

Ответы [ 2 ]

1 голос
/ 07 апреля 2012

У вас была возможность просмотреть эту ссылку: http://static.springsource.org/spring-security/site/docs/3.0.x/reference/cas.html?

В документации рассказывается, как настроить клиент CAS с Spring Security.

0 голосов
/ 22 марта 2012

Посмотрите на псевдоним, который вы используете для импорта пространства имен bean. Если ваш xml имеет конфигурацию как xmlns: beans = "http://www.springframework.org/schema/beans" xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance", используйте его с псевдонимом как bean: bean

...