wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to implementing good security in Servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to implementing good security in Servlet?" Watch "How to implementing good security in Servlet?" New topic
Author

How to implementing good security in Servlet?

Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Hello Friends,,

how to implementing good security, example for authentication in Servlet?..
Assume that i have application which has Create, Read, Update, and Delete method..
Admin could accessed all methods..
but Employee just could read the data..
How to good implementing that requirements?..
Do i have to provides 2 Servlet with 2 forms?..
or could i have one servlet with one form?..

i interested Spring Security which has Method security implements..
could i do like Spring Security in Servlet?..
i uses JBoss 5.1 + JSP + Servlet + EJB3..

please give me any suggestion..
Thanks in advance ..


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

You can also use ACEGI security framework for spring framework Its available at

http://www.acegisecurity.org/


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
The easiest would be to use the authentication/authorization framework that's built into the Servlet API. It implements a username/password/role scheme that makes authentication information available through the HttpServletRequest's getRemoteUser and isUserInRole methods.


Ping & DNS - my free Android networking tools app
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Thanks for the replies..


How to set username/password/role scheme in HttpServletRequest?..
assume that i have login application..
the users who wants to login to my application must filled the Login (username, and password)..
and the users who can login to my application is admin and employers?..
how to set that user's role (either admin/employee) to HttpServletRequest?..

Would you like to give me an example?..

Thanks in advance..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
Some of the details are specific to your servlet container, while some others are generic for all web apps. See http://faq.javaranch.com/java/ServletsFaq#security for further information.
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

@Ulf Dittmer

Thanks sir..

i uses JBoss 5.0..
Okay.. Firstly i'll try it in Tomcat6.. then i'll implement it in JBoss..
Hope it will run well..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to implementing good security in Servlet?
 
Similar Threads
Spring Security - Method level Permission
Spring Web Flow 2 Web Development
I am confused, please show me a way
authenication user using spring security
Does Spring Web Flow 2 have role based authorization to execute flow feature?