You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Rafferty <ch...@sidonis.com> on 2010/06/30 12:22:46 UTC

FormAuthenticator exception with non-latin (UTF8) user name

Hi,

 

I'm getting the following exception when I try to access the list of
deployed webservices (http://localhost:8080/manager/list) with a user who
has non-Latin characters in their user name:

 

java.lang.NullPointerException

org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormA
uthenticator.java:321)

 
org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthent
icator.java:245)

 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:523)

 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)

 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:588)

 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

        java.lang.Thread.run(Thread.java:619)

 

I'm running Tomcat and the browser (Firefox) all on my development PC with
Windows XP,  I've tried the same scenario, with the same results, on the
following Tomcat versions 5.5.23, 5.5.29 and 6.0.26 all on Java 1.6.0_12.  

 

My username and passwords are stored in a Postgres database and I have the
realm configured to access my database and tables in my server.xml, thus:

 

      <Realm  className="org.apache.catalina.realm.JDBCRealm"

             driverName="org.postgresql.Driver"

          connectionURL="jdbc:postgresql://localhost/uca"

         connectionName="blah" connectionPassword="blah"

              userTable="mg_users" userNameCol="username"
userCredCol="password"

          userRoleTable="mg_roles" roleNameCol="role" />

 

This only occurs when I add the following valve to /conf/context.xml

 

    <Valve className="org.apache.catalina.authenticator.FormAuthenticator"
characterEncoding="UTF-8" />

 

If I do not add the valve then Tomcat will not authenticate any attempt to
access the list page with a user name containing non-Latin characters, it
works perfectly if the user name contains only Latin characters.   Rationale
behind this approach:  my application consisting of a number of war files,
an html page and some jsp pages.   A user logs in via a html page which is
submitted as a form.  Now this works correctly for non-Latin characters when
I configure the context.xml in the application's META-INF directory with the
same valve, hence why I was trying to set it for all applications in the
hope that this would allow the manager list to be retrieved.   If I
explicitly set the valve just for the manager application I get the same
exception.     

 

Any pointers to what I'm doing wrong would be greatly appreciated. 

 

Chris Rafferty

Team Leader, Sidonis

 

e:  <ma...@sidonis.com> chris.rafferty@sidonis.com

w:  <http://www.sidonis.com/> www.sidonis.com

 


Re: FormAuthenticator exception with non-latin (UTF8) user name

Posted by Mark Thomas <ma...@apache.org>.
On 30/06/2010 16:20, Caldarale, Charles R wrote:
>> From: Chris Rafferty [mailto:chris.rafferty@sidonis.com]
>> Subject: RE: FormAuthenticator exception with non-latin (UTF8) user
>> name
>>
>> I changed the manager application's web.xml to use FORM
>> based authentication, added the valve to its context.xml
>
> You really should not be explicitly adding the<Valve>; Tomcat will include the proper valve as required by the security specifications in the webapp's WEB-INF/web.xml file.

You do need to add the valve if you want to change any of the default 
settings. Whilst the request body *should* be in UTF-8 if the login form 
is written correctly, I believe there are issues with some browsers not 
following the spec and failing to declare the character encoding being used.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: FormAuthenticator exception with non-latin (UTF8) user name

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Chris Rafferty [mailto:chris.rafferty@sidonis.com]
> Subject: RE: FormAuthenticator exception with non-latin (UTF8) user
> name
> 
> I changed the manager application's web.xml to use FORM 
> based authentication, added the valve to its context.xml

You really should not be explicitly adding the <Valve>; Tomcat will include the proper valve as required by the security specifications in the webapp's WEB-INF/web.xml file.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: FormAuthenticator exception with non-latin (UTF8) user name

Posted by Chris Rafferty <ch...@sidonis.com>.
Thanks Mark,

That has worked a treat.   I changed the manager application's web.xml to
use FORM based authentication, added the valve to its context.xml rather
than specifying it globally and provided the login form. 

Cheers
Chris


-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: 30 June 2010 12:28
To: Tomcat Users List
Subject: Re: FormAuthenticator exception with non-latin (UTF8) user name

On 30/06/2010 12:22, Chris Rafferty wrote:

> This only occurs when I add the following valve to /conf/context.xml
>
>      <Valve
className="org.apache.catalina.authenticator.FormAuthenticator"
> characterEncoding="UTF-8" />

Bad idea on a number of levels.

1. That change then applies to *every* context, and will break any that 
don't use FORM authentication.

2. The Manager app uses BASIC authentication...

> If I do not add the valve then Tomcat will not authenticate any attempt to
> access the list page with a user name containing non-Latin characters, it
> works perfectly if the user name contains only Latin characters.

BASIC auth, browsers and UTF-8 is a combination that I suspect behaves 
differently from browser to browser.

Your best bet would be to modify the manager app to use FORM auth, 
making sure your login form correctly supports UTF-8.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: FormAuthenticator exception with non-latin (UTF8) user name

Posted by Mark Thomas <ma...@apache.org>.
On 30/06/2010 12:22, Chris Rafferty wrote:

> This only occurs when I add the following valve to /conf/context.xml
>
>      <Valve className="org.apache.catalina.authenticator.FormAuthenticator"
> characterEncoding="UTF-8" />

Bad idea on a number of levels.

1. That change then applies to *every* context, and will break any that 
don't use FORM authentication.

2. The Manager app uses BASIC authentication...

> If I do not add the valve then Tomcat will not authenticate any attempt to
> access the list page with a user name containing non-Latin characters, it
> works perfectly if the user name contains only Latin characters.

BASIC auth, browsers and UTF-8 is a combination that I suspect behaves 
differently from browser to browser.

Your best bet would be to modify the manager app to use FORM auth, 
making sure your login form correctly supports UTF-8.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org