How to set user detail in session atttribute after login in spring secuiry xml

I implement Spring Security in a project. I want to put a custom object(domain object) in session at the time of login, so that I can check the user details from HttpServletRequest object in any controller.

Please help me, how to do it? My Spring security file is :

<http auto-config="true" use-expressions="true"> <intercept-url pattern="/login/**" access="permitAll" /> <intercept-url pattern="/forgotPassword/**" access="permitAll" /> <intercept-url pattern="/css/**" access="permitAll" /> <intercept-url pattern="/js/**" access="permitAll" /> <intercept-url pattern="/images/**" access="permitAll" /> <intercept-url pattern="/**" access="hasRole('ROLE_USER')" /> <!-- access denied page --> <access-denied-handler error-page="/403" /> <form-login login-page="/login" default-target-url="/listSensorData" authentication-failure-url="/login?login_error=1" username-parameter="username" password-parameter="password" login-processing-url="/loginSSuser" ></form-login> <logout logout-success-url="/login" invalidate-session="true" logout-url="/logout" /> </http> <authentication-manager alias="authenticationManager"> <authentication-provider user-service-ref="SsmsUserDetService" > </authentication-provider> </authentication-manager>

Category:java Views:1 Time:2018-10-06

Related post

  • how to set user account to turn off after 2 min of inactivity 2012-11-15

    I want to turn off my computer after a few minutes of inactivity and go back to my user screen. How do I do the in XP. --------------Solutions------------- Hi, You may setup a power plan on the computer and configure the below setting. Refer the link

  • Liferay 6. Redirect users to their private page after login 2011-04-17

    How to redirect users to their private page after login? Now it goes to /web/guest/home I want to make this dynamic like /web/<user>/home. is there an easy way? --------------Solutions------------- As far as I know, there is no "easy" way. You

  • How to get user name in session bean when redirected to error page? 2011-10-03

    Can anyone tell me how to get user name in session bean correctly? In our application we do it by calling this method: @Resource private EJBContext _context; private String getUserName() { return _context.getCallerPrincipal().getName(); } And this wo

  • how to set User sate in an Async method of silverlight 2011-03-16

    how to set User sate in an Async method of silverlight. --------------Solutions------------- I Got the Answer, Second parameter in Async call is an UserState, And we can read that in AsyncCompleted method.

  • how to set user name/password in httpget 2012-04-04

    I use Apache HttpComponents to access a web service, and don' know how to set user/password in the request, here is my code: URI url = new URI(query); HttpGet httpget = new HttpGet(url); DefaultHttpClient httpclient = new DefaultHttpClient(); Credent

  • How to get user's own videos list after I passed the access token of youtube with OAuth2 2011-06-16

    How to get user's own videos list after I passed the access token of youtube with AOuth2. --------------Solutions------------- Your question is too general. Did you read the oauth2 guide of google?

  • How to make user persist between sessions? 2009-06-09

    I use Silverlight Business Application (Application with RIA Services). Create new project. All setting by default.Compile and run it. In application I create new user. It's all right. Then I add a chackbox to LoginWindow.xaml: <CheckBox x:Name="i

  • Flickr gem : how to access user details? 2009-06-10 I'm trying the example in the home page of the flickr gem. require 'flickr' flickr ='MY_KEY') user = flickr.users('[email protected]') user.location while I'm able to get the user ob

  • Cakephp: How to read User Data in Session? 2010-10-11

    I wanna gather the latest information of a user from the User Model and store it in the session. so i am doing this // Before Render function beforeRender() { if($this->Session->check('Auth.User')) { $this->User->recursive = -1; $currentU

  • How to Set User-Agents in an HttpRequest (Unit Testing) 2009-02-12

    I've got a method that takes in an HttpRequest object and performs differently based on what User Agent is set. I'm trying to unit test it and am having a heck of a time tracking down how to set the User Agent string. I've tried the raw HttpRequest o

  • How to set users' all privileges to a path using C#? 2009-09-16

    How can I authorize the users' all privileges to a path in a web app? Just like the operation that I right-click a path, set users' all privileges in the security tab. --------------Solutions------------- In C#: System.IO.DirectoryInfo myDire

  • How to set user account to run build runner in Team City 2010-02-03

    I have a separate build configuration used to deploy built files. This configuration uses command line build runner. I have a bat file that copies output files to another computer share. The output files are produced by other build configuration. The

  • how to set user level 2010-06-08

    I am doing a system that require a login page. The problem is I dont know how to set the user level. For an example : if admin, can access all the page and if user can access only certain page. How to do that? --------------Solutions------------- Tha

  • How to set user's privileges from LDAP via OpenDS 2010-09-02

    I have setup a simple LDAP server using OpenDS. I would like to set the user privileges and I have no idea how to do it. Am I supposed to achieved this by modifying the ACL? If yes, how do I go about doing it? Or is there any options in OpenDS that a

  • How to set user control visibility, upon user role 2011-03-11

    I want to implement access control for usercontrols depending on user role(s), I want to do it on the control base class, in such way that on every user control I only need to set a string with allowed roles to see the user control This is how an use

  • How to set SMTP details in script? 2011-10-15

    As e-mails sent from my website usually go into Junk, I wanted to edit php.ini file to fix it, but it is not allowed by my hosting provider. They offered their own solution for this: The solution we can offer you is to use SMTP for your mailservice.

  • How to set User Defauts from command line arugment when it is "set of strings" 2012-02-09

    I want to set User defaults value from command line. I found the document about the User defaults and how to pass a value via command line. What I'm trying to do now is pass the "set of strings" as the value to an application. More speicfically, I wa

  • How to set "user cannot change password" AD attribute 2012-02-17

    I'm trying to figure out how to set the "User cannot change password" attribute of AD using VB.NET. I was originally hoping to use the UserAccountControl Flags found here but I realized you cannot set the PASSWD

  • How to pass user details between objects in 2010-08-16

    I'm redesigning an old VB6 application into and there is one thing I'm not sure on the best way to do. In the VB6 application whenever we created a new instance of a component, we would pass in the user details (user name and the like) so we n

  • how to set user agent for get_headers PHP function 2011-12-06

    I know It's easy to set user agent for curl but my code is based on get_headers, by default get_headers user agent is empty. thanks for any help. --------------Solutions------------- Maybe this? ini_set('user_agent', 'Mozilla/5.0'); get_headers only

  • How to direct a user to the referrer page after login? 2011-10-11

    Lets say the site has a user account system that uses sessions to login/verify etc. So let say i send somebody the link and they must be logged in to see it. So naturally the site will ask them the login but after login th

  • How to set an Arrays internal pointer to a specific position? PHP/XML 2009-04-27

    Im trying to build a little site using XML instead of a database. I would like to build a next and prev button which will work relative to the content I have displayed. I found the php function next() and prev() as well as current() but I do not know

  • how to set button to be visible only after i made changes in 2 dropdownlists in javascript 2012-03-02

    in aspx file I have <asp:DropDownList ID="DropDownList1" runat="server" > </asp:DropDownList> <asp:DropDownList ID="DropDownList2" runat="server"> </asp:DropDownList> <asp:Button ID="load_data" runat="server" Text="<%$ R

  • PHP: Returning a user to their original page after login 2009-12-31

    Are there any 'best practices' concerning how one should return a user to their original page after logging in to your website, specifically in PHP? e.g. if I'm viewing a StackOverflow question while not logged in, how would you ensure that I return

  • How to get back to the redirecting page after login (codeigniter)? 2012-08-30

    I have login controller in my CI app: function index() { if($this->session->userdata('logged_in')==TRUE) redirect('/success'); $data['error']=$this->session->flashdata('errormessage'); $this->load->view('auth',$data); } function pro

Copyright (C), All Rights Reserved.

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