0

Problem with page login

asked 2012-04-17 04:49:54 +0800

trubala gravatar image trubala
6

tune authorization through the spring security, login page made ​​using ZK framework.
There are no errors in the assembly, when the browser (Chrome) says:
This page is found cyclic redirects
Error 310 (net :: ERR_TOO_MANY_REDIRECTS): There were too many redirects.

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/root-context.xml
            /WEB-INF/security.xml
        </param-value>
    </context-param>
    
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <listener>
        <description>ZK listener for session cleanup</description>
        <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
    </listener>
  
    <servlet>
        <description>ZK loader for ZUML pages</description>
        <servlet-name>zkLoader</servlet-name>
        <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
        <init-param>
            <param-name>update-uri</param-name>
            <param-value>/zkau</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zul</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zhtml</url-pattern>
    </servlet-mapping>
  
    <filter>
        <filter-name>hibernateSessionInViewFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>hibernateSessionInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
  
    <servlet>
        <description>The asynchronous update engine for ZK</description>
        <servlet-name>auEngine</servlet-name>
        <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>auEngine</servlet-name>
        <url-pattern>/zkau/*</url-pattern>
    </servlet-mapping>
      
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>/zul/login.zul</welcome-file>
    </welcome-file-list>
</web-app>

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" 
xsi:schemaLocation="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.0.xsd">


    <http auto-config="true">
        <intercept-url pattern="/**" access="ROLE_ADMIN"/>
        <intercept-url pattern="/zul/login.zul" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
        <form-login login-page="/zul/login.zul" 
        default-target-url="/zul/test.zul"
        always-use-default-target="true" 
        authentication-failure-url="/zul/login.zul?login_error=1"/>
      <!--  <form-login login-page="/login.zul" authentication-failure-url="/login.zul?login_error=1"/> -->
    </http>
    <beans:bean id="MyUserDetails" class="com.mycompany.app.web.MyUserDetailsService" />
    
    <beans:bean id="MyAuth" class="com.mycompany.app.web.AuthController"/>
    
    <authentication-manager alias="authenticationManager">
        <!-- <authentication-provider user-service-ref="MyUserDetails"/> -->
        <authentication-provider ref="MyAuth"/>
    </authentication-manager>
</beans:beans>

login.zul

<?page title="Авторизация" contentType="text/html;charset=UTF-8"?>
<zk>
	<window title="Test ZK" border="normal" position="center"
		mode="overlapped">
		<h:form id="f" name="f" action="j_spring_security_check"
			method="POST" xmlns:h="native">
			<hbox>
				Логин:
				<textbox id="u" name="j_username" />
			</hbox>
			<hbox>
				Пароль:
				<textbox id="p" type="password" name="j_password" />
			</hbox>
			<hbox>
				<h:input type="submit" value="Войти" />
				<h:input type="reset" value="Очистить" />
			</hbox>
		</h:form>
	</window>
</zk>

delete flag offensive retag edit
Be the first one to reply this discussion!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-04-17 04:49:54 +0800

Seen: 546 times

Last updated: Apr 17 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More