You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Guido Schoepp <gu...@guxx.net> on 2006/05/31 09:19:24 UTC

Why no GenericPrincipal?

Hi,

I set up a JSP to get the user principal. But when trying to access the 
principal by
   request.getUserPrincipal(),
I'll always get a plain Principal class. I expected to get a 
GenericPrincipal class by the container's UserDatabaseRealm.

I'm using the Tomcat default configuration with the UserDatabaseRealm. I 
tried this with TC 5.0.27 on Windows 2000 and TC 5.0.28 on Debian Linux.

Any thoughts?

   Guido

--- authtest.jsp --------------
<html>
<body>
<h1>AuthTest</h1>
Name: <%=request.getRemoteUser()%><br/>
<%
   java.security.Principal principal = request.getUserPrincipal();
   out.println("Principal Name: "+principal.getName()+"<br/>");
   if (principal instanceof org.apache.catalina.realm.GenericPrincipal) {
     org.apache.catalina.realm.GenericPrincipal gp =
        (org.apache.catalina.realm.GenericPrincipal)principal;
     out.println("Principal PW: "+gp.getPassword()+" <br/>");
   } else {
     out.println("no GenericPrincipal <br/>");
   }
%>
</body>
</html>
--- authtest.jsp --------------

--- web.xml -------------------
   ...
   <security-constraint>
     <display-name>Example Security Constraint</display-name>
     <web-resource-collection>
       <web-resource-name>Protected Area</web-resource-name>
       <url-pattern>/*</url-pattern>
     </web-resource-collection>
     <auth-constraint>
       <role-name>tomcat</role-name>
     </auth-constraint>
   </security-constraint>

   <security-role>
     <role-name>tomcat</role-name>
   </security-role>

   <login-config>
     <auth-method>BASIC</auth-method>
   </login-config>
   ...
--- web.xml -------------------


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


Re: Why no GenericPrincipal?

Posted by Guido Schoepp <gu...@guxx.net>.
Mark Thomas schrieb:
>> Mh, is this not the right list for these kind of questions?
> http://tomcat.apache.org/faq/tomcatuser.html#why

So I hope it's "No one knows the answer".

   Guido


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


Re: Why no GenericPrincipal?

Posted by Mark Thomas <ma...@apache.org>.
Guido Schoepp wrote:
> Mh, is this not the right list for these kind of questions?

http://tomcat.apache.org/faq/tomcatuser.html#why


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


Re: Why no GenericPrincipal?

Posted by Guido Schoepp <gu...@guxx.net>.
Mh, is this not the right list for these kind of questions?

   Guido

Guido Schoepp schrieb:
> I set up a JSP to get the user principal. But when trying to access the 
> principal by
>   request.getUserPrincipal(),
> I'll always get a plain Principal class. I expected to get a 
> GenericPrincipal class by the container's UserDatabaseRealm.
> 
> I'm using the Tomcat default configuration with the UserDatabaseRealm. I 
> tried this with TC 5.0.27 on Windows 2000 and TC 5.0.28 on Debian Linux.
> 
> Any thoughts?
> 
>   Guido
> 
> --- authtest.jsp --------------
> <html>
> <body>
> <h1>AuthTest</h1>
> Name: <%=request.getRemoteUser()%><br/>
> <%
>   java.security.Principal principal = request.getUserPrincipal();
>   out.println("Principal Name: "+principal.getName()+"<br/>");
>   if (principal instanceof org.apache.catalina.realm.GenericPrincipal) {
>     org.apache.catalina.realm.GenericPrincipal gp =
>        (org.apache.catalina.realm.GenericPrincipal)principal;
>     out.println("Principal PW: "+gp.getPassword()+" <br/>");
>   } else {
>     out.println("no GenericPrincipal <br/>");
>   }
> %>
> </body>
> </html>
> --- authtest.jsp --------------
> 
> --- web.xml -------------------
>   ...
>   <security-constraint>
>     <display-name>Example Security Constraint</display-name>
>     <web-resource-collection>
>       <web-resource-name>Protected Area</web-resource-name>
>       <url-pattern>/*</url-pattern>
>     </web-resource-collection>
>     <auth-constraint>
>       <role-name>tomcat</role-name>
>     </auth-constraint>
>   </security-constraint>
> 
>   <security-role>
>     <role-name>tomcat</role-name>
>   </security-role>
> 
>   <login-config>
>     <auth-method>BASIC</auth-method>
>   </login-config>
>   ...
> --- web.xml -------------------


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