• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Security filter question

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since the request from the client is first intercepted by the filter how can it sauthenticate the user since there is no info available bout the user.Do i need to call the database from the doFilter method to validate the credentials? If yes then whats the use of using the security filter as this task can be done without it as well?
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
the idea of security filter is that you can encapsulate security outside of your servlets/jsps.

By itercepting every request, filter can verify if the user already established a session with the system, if not, you can redirect to a login screen and validate user credentials (via database, ldap, etc.) before the user access any secured content.

That way, you can code your servlets an jsps "ignoring" security, trusting filters authentication. This scheme makes your app more maintainable and easy to code and understand.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using container managed security, there is no need for one.

If you're implementing your own security, a filter is a very easy way to check for the needed session objects or redirect to the login screen for every request without having to paste the same code into every servlet/jsp.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic