Different Login pages for mobile and desktop while using Spring Security

I'm using spring-security web authentication with spring-mvc, all is well so far, but now i am developing a mobile version of my application for that i have designed a different set of pages for mobile site which includes a different login page. now my i have problems configuring that

here's my applicationContext-security.xml

<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 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" lowercase-comparisons="false"> <intercept-url pattern="/images/**" filters="none" /> <intercept-url pattern="/Stylesheets/**" filters="none" /> <intercept-url pattern="/JavaScript/**" filters="none" /> <intercept-url pattern="/scripts/**" filters="none" /> <intercept-url pattern="/favicon.ico" access="ROLE_ANONYMOUS" /> <intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN"/> <intercept-url pattern="/mobile/**" access="ROLE_USER,ROLE_ADMIN"/> <form-login login-page="/login.htm" authentication-success-handler-ref="customHandler" authentication-failure-url="/login.htm?error=true" default-target-url="/home.htm" login-processing-url="/j_security_check" /> <remember-me user-service-ref="userDAO" key="e37f4b31-0c46-11dd-bd0b-0800200c9a66"/> </http> <beans:bean id="customHandler" class="com.example.auth.AuthenticationHandler"> </beans:bean> <authentication-manager> <authentication-provider user-service-ref="userDAO"> <!-- TODO skipped to allow password emailing instead of password change and security TODO question hell.. --> <!-- <password-encoder ref="passwordEncoder"/> --> </authentication-provider> </authentication-manager> </beans:beans>

now how can i have multiple login pages according to the different request, i mean if the pages of mobile folder than the user should be shown the mobile login page. i have seen similar questions on stackoverflow but those were login pages according to different roles, but in my case i want diff login for different pages.

hi, thanks for the solution it seems that it will work fine for me. i have now switched to spring security 3.1 but it is giving me an exception. can you please help me resolve this.

Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#4' while setting bean property 'sourceList' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#4': Cannot create inner bean '(inner bean)' of type [org.springframework.security.web.authentication.logout.LogoutFilter] while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#6': Cannot resolve reference to bean 'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0': Cannot create inner bean '(inner bean)' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#7': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Property 'sessionFactory' is required for bean '(inner bean)#7'

-------------Problems Reply------------

If you have the posibility to switch t spring security 3.1, you can simply define 2 http elements 1. If you can not switch, you can not configure it fully via the namespace, but have to register an entry-point-ref and somd <sec:custom-filter> elements.

You will have to provide a custom authentication entry point and make a decision there. This SO answer could be a starting point you can use.

Category:spring Views:0 Time:2012-03-08

Related post

  • Customise Login Page Based on Required Roles with Grails Spring Security 2012-01-13

    I have a grails 2.0 app with the spring-security-core 1.2.6 plugin. I have different pages that have a @Secured annotation with different roles (ROLE_USER and ROLE_ADMIN). This works but when I try to access either a user or admin secure page I get r

  • Spring+Spring security+tiles. How to set form-login with tiles page definition? 2011-01-27

    I have spring_tiles web application and now trying to add spring security to it: That is a peace of my TilesConfig.xml: <definition name="loginPage" extends="commonPage"> <put-attribute name="body" value="/WEB-INF/tiles/jsp/login_body.jsp" /

  • In Extjs While updating in Grid if Session Timeout how to redirect to login page? 2010-10-29

    How to identify the sessiontime out issue while updating the value in the grid and redirect to login page.. my application (java spring hibernate with extjs) i.e.. i am updating the extjs grid record and while submitting the changes, if the session i

  • Grails Spring Security Core Plugin - adding flash message to login page 2010-11-15

    I am using the Grails Spring Security Core Plugin to secure a certain action using the following annotation. @Secured(['IS_AUTHENTICATED_REMEMBERED']) This causes the action to redirect to my login page if the user is not logged in. Once they are log

  • Getting Access is denied in login page 2011-10-13

    i am using spring security 3 with JSF 2 ICEFaces 2 and i configured my application as follows: All the pages are protected (requires authentication) except for login. Login page is non filtered, so any user can access it. the problem: when trying to

  • Jersey with Spring-Security DB login keeps redirecting to Login Page 2012-05-03

    I have a jersey (rest) spring app using spring-security with database login. I have it redirecting to the login page and once I enter in a valid username and password it redirects back to the login page. Is there other code I need to write and/or is

  • ajax login with spring webMVC and spring security 2010-08-09

    I've been using Spring Security 3.0 for our website login mechanism using a dedicated login webpage. Now I need that login webpage to instead be a lightbox/popup window on every webpage in our site where upon logging in I get an AJAX result whether i

  • how to get redirected to a method at login/logout before target-url called in spring-security, spring mvc 2011-07-20

    I am trying to record current time of Login(in a method or object) once the Login is successful and assign LastLogin time to current login time at logout. I am using spring security for login, logout. But i don't know how to take control to a method

  • jsf spring security login error message 2012-01-18

    I'm using spring security 3 in my jsf2 web app. How can I show a bad credential message in my login form without appending a get param ?login_error to the authenticated-fail-login-page? I've tried using a phase listener like this tutorial says: http:

  • Mobile or desktop browser detection and redirect to respective web page 2011-07-12

    I m building a website in PHP which contains flash in it's index page. I want to redirect users who are accessing my site via any mobile browser or ipad,ipod,iphone to page m.index.php which doesn't contain flash(simple page) for loading purpose and

  • How to make facebook like button shows a mobile-optimized Facebook login page? 2011-09-15

    I have a mobile website designed to be shown in a iPhone app. There is a Facebook like button in that mobile web. If the user click the like button without logging in, the button will show a full-facebook login page, which looks like a disaster in mo

  • How to get mobile login page when using facebook graph api 2012-02-29

    I have a web app that authenticates via Facebook app login https://graph.facebook.com/oauth/access_token? client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET& grant_type=client_credentials that will redirect to (user is not already logged in)

  • Facebook API & iPhone-optimized login page 2012-01-13

    I'm trying to develop a mobile version of an existing site for use on the iPhone, and I'm using a straight hyperlink who's target is defined thusly: $fb = $this->facebook->getLoginUrl(array( 'redirect_uri' => $redirect, 'scope' => 'email,

  • FB.login popup on mobile web doesn't auto close once logged in 2012-03-27

    I have a Facebook connect site and am having issues with the Facebook login part on mobile browsers (ie: iPhone Safari, etc). Whenever I click the login button, it opens a new tab in Safari which takes me to a URL like this: https://s-static.ak.fbcdn

  • How to implement login page using Spring Security so that it works with Spring web flow? 2010-05-21

    I have a web application using Spring 2.5.6 and Spring Security 2.0.4. I have implemented a working login page, which authenticates the user against a web service. The authentication is done by defining a custom authentincation manager, like this:

  • Remote SQL login page C# 2010-06-10

    Hey, I am trying to create a login page that checks the username and password with the database on the server. The server is located in a different country. This is the code I have so far: #region Building the connection string string Server = "XX.XX

  • Twitter OAuth Login Page on the iPhone 2010-12-31

    I have Twitter integrated into my application, with the help of Sharekit. Everything works pretty well except, if the user happens to tap on the "Sign Up" link on the Login/allow page, it goes to a non-sign up error page. Either a "Sorry that page do

  • jQuery Mobile for mobile and desktop? 2011-02-19

    I'm developing a web app. MySql/PHP back-end, and HTML/jQuery front-end. I wanted to use jQuery UI framework. Now is see that jQuery Mobile is out, and I want to make the app accessible to mobile devices as much as possible. I Googled, but didn't fin

  • jQuery Mobile for desktop and mobile 2011-03-25

    What browsers on desktop jQuery Mobile supports? Can I develop single interface on jQuery Mobile both desktop and mobile? What do you think about web app with such interface for desktop users? I mean usability. So supported PC browsers: Chrome 10+ Fi

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.070 (s). 11 q(s)