You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Oki DZ <ok...@bdg.pindad.com> on 2001/05/14 11:10:11 UTC

Digest authentication

Hi,

I'd like to use the Digest authentication on Tomcat. I set my app's
web.xml as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>
  <servlet>
      <servlet-name>sample</servlet-name>
      <servlet-class>SampleServlet</servlet-class>
      <init-param>
        <param-name>properties</param-name>
	<param-value>WEB-INF/sample.properties</param-value>
      </init-param>
  </servlet>
   <servlet-mapping>
       <servlet-name>sample</servlet-name>
       <url-pattern>/sample</url-pattern>
   </servlet-mapping>

  <!-- Define a Security Constraint on this Application -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Entire Application</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
       <role-name>tomcat</role-name>
    </auth-constraint>
  </security-constraint>

  <!-- Define the Login Configuration for this Application -->

  <login-config>
    <auth-method>DIGEST</auth-method>
    <realm-name>Test Application</realm-name>
  </login-config>

</web-app>

If I changed the "DIGEST" above into "BASIC" (and have the passwords
stored in plain-text in the db), everything would be fine. But the above
settings seem not to be working; I get "HTTP Status 401 - Unauthorized."
There's no login panel displayed or anything.

BTW, if I used the Digest auth., then the passwords in the database
should be stored in MD5 format, right? 

Another thing... I changed one of the attributes of Valve element in
server.xml; the org.apache.catalina.authenticator.SingleSignOn to
org.apache.catalina.authenticator.DigestAuthenticator. Unfortunately,
Tomcat couldn't be started. The error message said that a context should
be attached. How can I attach a context to a valve?

TIA,
Oki