Solved

noob j_security_check question.

Posted on 2007-04-04
7
423 Views
Last Modified: 2008-03-03
1. to login, i use j_security_check... but what a bout logout?
2. If i wanted to keep track on which user login at what time, how do i insert the code in j_security_check so that it will do so?

0
Comment
Question by:InNoCenT_Ch1ld
  • 4
  • 3
7 Comments
 
LVL 26

Expert Comment

by:mrcoffee365
ID: 18855335
Oddly, logout doesn't really have a definition.

What we do is clear all the session attributes, clear the cookies, and destroy the session.  It has the desired effect.

You can't insert code into j_security_check -- it's entirely internal to Tomcat and has no public interface.

What you have to do is add code to your login handling to set data in a database, or sessions, or wherever you keep data, to keep track of your users.  We log it to a database, for example.

0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 18855371
but if i define the action to be the j_security_check already, where am i suppose to add my code to?
0
 
LVL 26

Accepted Solution

by:
mrcoffee365 earned 500 total points
ID: 18855510
You post to j_security_check, you never see the actual j_security_check code itself.

In your web.xml, you define the name of the page for login, and for an error in login.  The login page is just the presentation of the username/password form to the user, which is in a special location in your webapp (jsp/security/protected).   You can create cookies there, if that helps your app.

This page has a simple walk-through of how to set up form-based authentication in Tomcat:
http://www.onjava.com/lpt/a/1024

This is a more complex discussion of it:
http://www.devx.com/assets/download/6264.pdf

This one is a little easier to follow and has a nice diagram of the typical web app page setup with Tomcat login, a login page, and the login-protected web-app pages:
http://www.javapassion.com/j2ee/WebApplicationSecurity.pdf
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 18855526
tks
0
 
LVL 26

Expert Comment

by:mrcoffee365
ID: 18855540
You're welcome.

This is an area everyone has to work through, and there are a few different ways to use the login feature from Tomcat.  Post another question back on EE if you get stuck again.

Good luck!
0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 18855559
i'm using jdbcrealm with digest.. but i cant get it to work. if you know how, let me know, i will open a question.
0
 
LVL 26

Expert Comment

by:mrcoffee365
ID: 18857862
I haven't used it, but I've used login with Tomcat a lot, and I'm sure there are other people at EE with specific jdbc realm and digested password experience.  So sure, post the question.

When you do, it would help a lot if you posted the jdbc realm definition in your server.xml, the security parts of your web.xml, the login code you're trying to make work, and the error message you're getting.  Obfuscate any parts of the code you need to -- although I don't think that any of this should be an issue, unless IP addresses are involved somewhere.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now