Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for a Simple Spring security example [closed]

Tags:

I am new to spring-security (Java) and I am looking for a good and simple example of:

  1. How to use spring security for login and logout

  2. Make sure that the session exists on every page and if not redirect to the login again

  3. How get access to the current User Session

My project is currently working with spring MVC, and hibernate.
I have built the loginAPI + loginDAO, I need now to combine the security and make some of the pages secured.

I searched for tutorials, but a lot of them are very complicated.

like image 766
MushMushon Avatar asked Feb 04 '11 15:02

MushMushon


People also ask

What is Spring Security with example?

Spring Security Configuration is using Builder Pattern and based on the authenticate method, some of the methods won't be available later on. For example, auth. userDetailsService() returns the instance of UserDetailsService and then we can't have any other options, such as we can't set DataSource after it.

How do I check Spring Security?

The first way to check for user roles in Java is to use the @PreAuthorize annotation provided by Spring Security. This annotation can be applied to a class or method, and it accepts a single string value that represents a SpEL expression. Before we can use this annotation, we must first enable global method security.

How do I find my Spring Security username and password?

As of Spring Security version 5.7. 1, the default username is user and the password is randomly generated and displayed in the console (e.g. 8e557245-73e2-4286-969a-ff57fe326336 ).


2 Answers

Well. This is I think by far is the best i have seen so far!
http://krams915.blogspot.com/2010/12/spring-security-mvc-integration_18.html

like image 113
fatnjazzy Avatar answered Oct 19 '22 21:10

fatnjazzy


You can look for a Single-Sign-On(e.g CAS) implementation in Spring Security. It'll serve your purpose completely.

Check Out :-

http://static.springsource.org/spring-security/site/docs/3.0.x/reference/cas.html

https://wiki.jasig.org/display/CASC/Using+the+CAS+Client+3.1+with+Spring+Security

like image 25
Abhishek De Avatar answered Oct 19 '22 20:10

Abhishek De