Monday, October 8, 2012

Spring MVC, Security + Hibernate + DWR - Page 4



Spring MVC, Security + Hibernate + DWR, Let's PLay

OK, let's secure it ;)

The Spring security filter and Spring configuration:

in you web.xml edit the line to add a new file called spring-security.xml
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/dwr-context.xml,/WEB-INF/hibernate-context.xml,/WEB-INF/spring-security.xml</param-value>
<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 Order

as we are now having two filters (springSecurityFilterChain and OpenSessionInViewFilter) we need to set the filter order as, 1-security 2-Hibernate.
make sure you filter order look like this
<filter-mapping>
	<filter-name>springSecurityFilterChain</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
	<filter-name>hibernateFilter</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>

spring-security.xml

this file will configure spring security, we will use form authentication, the users will be configured using this file too.
<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.3.xsd">
 
	<http auto-config="true">
		<intercept-url pattern="/*" access="ROLE_USER" />
	</http>
 
	<authentication-manager>
	  <authentication-provider>
	    <user-service>
		<user name="mtz" password="123" authorities="ROLE_USER" />
	    </user-service>
	  </authentication-provider>
	</authentication-manager>
 
</beans:beans>
the idea here is that we are securing every URL, with:
username:mtz
password:123

Test it

deploy the project and you should see the following page
and you are done, thanks :)
download the full example

48 comments:

MooseyMersa said...

Thank you for a great tutorial. Took quite a while for me to get it to work, but this was more to do with running MySql on a non-default port (to do this you need to use a later version of the mysql-connector than provided in the download/repository and place it in a web-inf/lib folder).
In addition to make the logging work properly (to help solve the above problem) I needed to put the logging.properties and log4j.properties files in a web-inf/classes folder.

de said...

Great Article

Hibernate Training
Hibernate Online Training
Hibernate Training Courses
Java J2EE Training Institutes in Chennai
Java Training in Chennai

Java Training




Hibernate Dialect
Hibernate Interview Questions

unknown said...

we will go through the Spring Security setup & common features, when and where to apply, different authentication methods, securing password with encoding schemes, & integrating Spring Security in Spring MVC 4 and Hibernate based applications, exploring them with help of fully-working examples.spring security training in chennai

Mahesh said...

This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance the knowledge.Like it and help me to development very well. Thank you for this brief explanation and very nice information. Well got good knowledge.
Java Training in Gurgaon





Unknown said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

Best Java Training Institute Chennai


Java Training Institute Bangalore


saranya said...

Thanks for sharing a great thing.I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here.
uipath training in bangalore

Unknown said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

DevOps Training in Bangalore

gowsalya said...

Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
Digital Marketing online training

full stack developer training in pune

full stack developer training in annanagar

full stack developer training in tambaram

pooja said...

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
Hadoop Training in Chennai

Hadoop Training in Bangalore

Big data training in tambaram

Big data training in Sholinganallur

Big data training in annanagar

Big data training in Velachery

Big data training in Marathahalli

sai said...

Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
python training institute in chennai
python training in Bangalore
python training in pune

Mounika said...

I likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
python training in OMR
python training in chennai

nilashri said...

Wow, it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and I got more information from your blog.

Data Science training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune

Unknown said...

Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
java online training | java training in pune

java training in chennai | java training in bangalore

rama said...

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
Good discussion. Thank you.
Anexas
Six Sigma Training in Abu Dhabi
Six Sigma Training in Dammam
Six Sigma Training in Riyadh

rohil said...

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
Good discussion. Thank you.
Anexas
Six Sigma Training in Abu Dhabi
Six Sigma Training in Dammam
Six Sigma Training in Riyadh

simbu said...

Read all the information that i've given in above article. It'll give u the whole idea about it.

java training in chennai | java training in bangalore

java online training | java training in pune

nivatha said...

After reading your post I understood that last week was with full of surprises and happiness for you. Congratz! Even though the website is work related, you can update small events in your life and share your happiness with us too.

Data science course in tambaram | Data Science course in anna nagar
Data Science course in chennai | Data science course in Bangalore
Data Science course in marathahalli | Data Science course in btm

prabha said...

Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information. 
angularjs-Training in pune

angularjs-Training in chennai

angularjs Training in chennai

angularjs-Training in tambaram

angularjs-Training in sholinganallur

Anoushka Sakthi said...

Your article increases the curiosity to learn more about this topic. Keep sharing your information regularly for future reference.


Selenium Training in Chennai
selenium Classes in chennai
ios developer course in chennai
ios classes in chennai
JAVA Training Institutes in Chennai
Java Courses in Chennai

Sai Elakiyaa said...

Great stuff!! Keep doing and I would like to share with my friends.

Selenium Training in Chennai
Selenium Training
iOS Training in Chennai
Digital Marketing Training in Chennai
core java training in chennai
Salesforce Training in Chennai
Salesforce Training
Big Data Training in Chennai

priya rajesh said...

Excellent post, it will be definitely helpful for many people. Keep posting more like this.
Azure Training in Chennai
Microsoft Azure Training in Chennai
Data Science Course in Chennai
Data Science Training in Chennai
DevOps certification in Chennai
DevOps Training in Chennai
Azure Training in Velachery
Azure Training in Tambaram

jefrin said...

Good to read thanks for sharing
best machine learning training in chennai

karthick said...


Best post thanks for sharing

Machine Learning Course in Chennai | Machine Learning Training in Chennai

tamizh said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
devops online training

aws online training

data science with python online training

data science online training

rpa online training

Aaditya said...

Nice blog, good post, informative and helpful post and you are obviously very knowledgeable in this field. Very useful and solid content. Thanks for sharing


ExcelR Data Science in Bangalore

zaintech99 said...

It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content.
date analytics certification training courses
data science courses training

janitha said...

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant!
machine learning course malaysia

Data Science Course said...


I was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more.

Data Science Course

malaysiaexcelr01 said...

I finally found great post here.I will get back here. I just added your blog to my bookmark sites. thanks.Quality posts is the crucial to invite the visitors to visit the web page, that's what this web page is providing.



data science course malaysia

data science analytics rakshi said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!digital marketing course in singapore

jaanu said...

So luck to come across your excellent blog. Your blog brings me a great deal of fun.. Good luck with the site.
pmp certification malaysia

gautham said...

Your post is amazing business analyst course

dras said...

very nice post..
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting

imexpert said...

Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.

digital marketing courses mumbai

Mithun said...

Thanks for all your valuable Articles.Here Looking for JAVA Training with Placements Visit Here...
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

vivekvedha said...

"Valuable one...thanks for sharing..
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery

"

bill.wood said...

Unlike data science, machine learning is a set of techniques that allow computers to make decisions based on the given data. machine learning courses in hyderabad

Rashika said...

Good work and thank you for sharing this information. I congratulate your effort to do this.



Digital Marketing Training in Chennai | Certification | SEO Training Course | Digital Marketing Training in Bangalore | Certification | SEO Training Course | Digital Marketing Training in Hyderabad | Certification | SEO Training Course | Digital Marketing Training in Coimbatore | Certification | SEO Training Course | Digital Marketing Online Training | Certification | SEO Online Training Course

Tableau Training in Hyderabad said...


Nice article and thanks for sharing with us. Its very informative





AI Training in Hyderabad

Rohini said...

I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
machine learning courses in bangalore

data scientist course said...

I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more.
data scientist training and placement

data scientist course said...

Wonderful blog post. This is absolute magic from you! I have never seen a more wonderful post than this one. You've really made my day today with this. I hope you keep this up!
data scientist training and placement in hyderabad

Priya Rathod said...

Thank you very much for this great post.
Python Training in Hyderabad
Python Course in Hyderabad

Priya Rathod said...

Nice blog. I finally found great post here Very interesting to read this article and very pleased to find this site. Great work!
Data Science Training in Hyderabad
Data Science Course in Hyderabad

Unknown said...

It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing. data science course in surat

Pavithra Devi said...


Great post. Thanks for sharing such a useful blog.
IELTS Coaching in Velachery
IELTS Coaching in Chennai

Ramesh Sampangi said...

Informative blog and knowledgeable content. Keep posting more blogs with us.
Data Science Training Institute in Hyderabad

Programming Edu said...

Excellent post. Thank you for providing such an informative blog.

SkillUp Online provides Courses like Artificial Intelligence CoursesPython for Data Science CourseCloud Computing CoursesIBM coursesCybersecurity ProgramPower BI CertificationMicrosoft Azure Architect DesignGoogle Cloud Architect Certification and so on. To learn more about SkillUp Online IT certifications online Courses visit our website.