Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - How to authenticate under JBoss/JAAS from a public web app page?

 
Thread Tools Search this Thread
Old 03-27-2005, 07:08 PM   #1
Default How to authenticate under JBoss/JAAS from a public web app page?


I'm deploying a web app under JBoss with the usual '<security-constraint>'
based links to a JAAS login module.

However, my web app includes some web pages that are public (i.e. not
protected and open to public access) and not covered by the security
constraints.

On the main public page I want to include the usual login related controls
( user ID, password and submit button) to allow for quick login.

But how and what do I call to authenticate from this public area?




davout
  Reply With Quote
Old 03-28-2005, 07:57 PM   #2
Heiko W. Rupp
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

davout wrote:
> But how and what do I call to authenticate from this public area?


You need a form like this:
<form method="POST" action="j_security_check">
Login: <input type="text" name="j_username"><br/>
Passwort: <input type="password" name="j_password"><br/>
<input type="submit" value="Login"/>
</form>

In jboss-web.xml you need to set the security-domain for JAAS as well:

<jboss-web>
<security-domain>java:/jaas/adb</security-domain>
</jboss-web>

In this example "adb" is a domain that has been declared in
$JBServer/conf/login-config.xml

--
Heiko W. Rupp
JBoss Buch: http://www.dpunkt.de/buch/3-89864-318-2.html
  Reply With Quote
Old 03-28-2005, 09:50 PM   #3
davout
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

Thanks...

Where does the 'j_security_check' servlet redirect to after it has finished?


"Heiko W. Rupp" <> wrote in message
news:...
> davout wrote:
>> But how and what do I call to authenticate from this public area?

>
> You need a form like this:
> <form method="POST" action="j_security_check">
> Login: <input type="text" name="j_username"><br/>
> Passwort: <input type="password" name="j_password"><br/>
> <input type="submit" value="Login"/>
> </form>
>
> In jboss-web.xml you need to set the security-domain for JAAS as well:
>
> <jboss-web>
> <security-domain>java:/jaas/adb</security-domain>
> </jboss-web>
>
> In this example "adb" is a domain that has been declared in
> $JBServer/conf/login-config.xml
>
> --
> Heiko W. Rupp
> JBoss Buch: http://www.dpunkt.de/buch/3-89864-318-2.html



  Reply With Quote
Old 03-29-2005, 12:47 AM   #4
kjc
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

davout wrote:
> Thanks...
>
> Where does the 'j_security_check' servlet redirect to after it has finished?
>
>
> "Heiko W. Rupp" <> wrote in message
> news:...
>
>>davout wrote:
>>
>>>But how and what do I call to authenticate from this public area?

>>
>>You need a form like this:
>><form method="POST" action="j_security_check">
>> Login: <input type="text" name="j_username"><br/>
>> Passwort: <input type="password" name="j_password"><br/>
>> <input type="submit" value="Login"/>
>></form>
>>
>>In jboss-web.xml you need to set the security-domain for JAAS as well:
>>
>><jboss-web>
>> <security-domain>java:/jaas/adb</security-domain>
>></jboss-web>
>>
>>In this example "adb" is a domain that has been declared in
>>$JBServer/conf/login-config.xml
>>
>>--
>>Heiko W. Rupp
>> JBoss Buch: http://www.dpunkt.de/buch/3-89864-318-2.html

>
>
>

You need to set which pages are to be secured in your
web.xml file.

When a user hits one of these pages, he/she will be dircted to your
defined login page.
If the login is successful, the user is redirected to the desired page.
  Reply With Quote
Old 03-29-2005, 10:23 AM   #5
davout
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

That doesn't answer my question. Here's the situation...
* The user is on a public (unprotected) page that includes login controls
* According to a previous reponse on this thread the form action on the
login form should point at 'j_security_check'
* Hence, when the user enters their ID and password and clicks 'submit' the
'j_security_check' servlet is called.

So my question is where does the user reqest get re-directed to after
'j_security_check' servlet has finished?


"kjc" <> wrote in message
news:3I02e.21690$...
> davout wrote:
>> Thanks...
>>
>> Where does the 'j_security_check' servlet redirect to after it has
>> finished?
>>
>>
>> "Heiko W. Rupp" <> wrote in message
>> news:...
>>
>>>davout wrote:
>>>
>>>>But how and what do I call to authenticate from this public area?
>>>
>>>You need a form like this:
>>><form method="POST" action="j_security_check">
>>> Login: <input type="text" name="j_username"><br/>
>>> Passwort: <input type="password" name="j_password"><br/>
>>> <input type="submit" value="Login"/>
>>></form>
>>>
>>>In jboss-web.xml you need to set the security-domain for JAAS as well:
>>>
>>><jboss-web>
>>> <security-domain>java:/jaas/adb</security-domain>
>>></jboss-web>
>>>
>>>In this example "adb" is a domain that has been declared in
>>>$JBServer/conf/login-config.xml
>>>
>>>--
>>>Heiko W. Rupp
>>> JBoss Buch: http://www.dpunkt.de/buch/3-89864-318-2.html

>>
>>
>>

> You need to set which pages are to be secured in your
> web.xml file.
>
> When a user hits one of these pages, he/she will be dircted to your
> defined login page.
> If the login is successful, the user is redirected to the desired page.



  Reply With Quote
Old 03-29-2005, 10:39 AM   #6
Manfred Rosenboom
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

davout wrote:
> That doesn't answer my question. Here's the situation...
> * The user is on a public (unprotected) page that includes login controls
> * According to a previous reponse on this thread the form action on the
> login form should point at 'j_security_check'
> * Hence, when the user enters their ID and password and clicks 'submit' the
> 'j_security_check' servlet is called.
>
> So my question is where does the user reqest get re-directed to after
> 'j_security_check' servlet has finished?


You have to lean more about FORM based authentication in a
web container: in the web.xml file you can configure
form based authentication and the page to use, whenever
authentication is needed. How th write such a page was already
answered. Next you have to describe, which pages (URLs) in your
web application are protected. When you access such an URL for
the first time (i.e. no user authentication was done before in
the actual session), the web container will show your login
page and after checking the entered data will forward to the
desired URL.

Best,
Manfred
  Reply With Quote
Old 03-29-2005, 04:40 PM   #7
davout
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

Maybe I'm not being clear....

The question relates to an open unprotected page which does not require
authorized access - like the top level public page of most web sites. On
these front pages you often find a quick login facility, where a user may
enter their user ID and password. Note, this is NOT a separate login page,
the login controls are part of the top level open front page.

Hence, the difference is that I'm not trying to reach a protected page where
the container protection will intercept and force a redirect to a login
page. Instead I'm on a public (unprotected page) which includes a set of
login inputs and a login submit button.

Thus, from the earlier response the login submit from this public page will
call the 'j_security_check' servlet, but what happens after this servlet
completes its authentication check?


"Manfred Rosenboom" <> wrote in message
news:d2b7or$hu8$...
> davout wrote:
>> That doesn't answer my question. Here's the situation...
>> * The user is on a public (unprotected) page that includes login controls
>> * According to a previous reponse on this thread the form action on the
>> login form should point at 'j_security_check'
>> * Hence, when the user enters their ID and password and clicks 'submit'
>> the 'j_security_check' servlet is called.
>>
>> So my question is where does the user reqest get re-directed to after
>> 'j_security_check' servlet has finished?

>
> You have to lean more about FORM based authentication in a
> web container: in the web.xml file you can configure
> form based authentication and the page to use, whenever
> authentication is needed. How th write such a page was already
> answered. Next you have to describe, which pages (URLs) in your
> web application are protected. When you access such an URL for
> the first time (i.e. no user authentication was done before in
> the actual session), the web container will show your login
> page and after checking the entered data will forward to the
> desired URL.
>
> Best,
> Manfred



  Reply With Quote
Old 03-30-2005, 07:29 AM   #8
Manfred Rosenboom
 
Posts: n/a
Default Re: How to authenticate under JBoss/JAAS from a public web app page?

davout wrote:
> Maybe I'm not being clear....
>
> The question relates to an open unprotected page which does not require
> authorized access - like the top level public page of most web sites. On
> these front pages you often find a quick login facility, where a user may
> enter their user ID and password. Note, this is NOT a separate login page,
> the login controls are part of the top level open front page.
>
> Hence, the difference is that I'm not trying to reach a protected page where
> the container protection will intercept and force a redirect to a login
> page. Instead I'm on a public (unprotected page) which includes a set of
> login inputs and a login submit button.
>
> Thus, from the earlier response the login submit from this public page will
> call the 'j_security_check' servlet, but what happens after this servlet
> completes its authentication check?


This is a complete different case (neither BASE nor FORM authorization
but customer specified authorization). The j_security_check related
stuff works only for FORM based authorization. In your case you have to
code your own authorization. You can save the information (anonymous or
authorized user) in the related session.

Best,
Manfred
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump