解答例 - 実習課題1 - 11.認証方式
(実習課題1)
前章の実習課題4を、DIGEST認証を使用するように改良しなさい。
解答例
<?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>Clock</servlet-name> <jsp-file>/jsp/clock.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>Clock</servlet-name> <url-pattern>/servlet10-1</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Clock</servlet-name> <url-pattern>/admin/servlet10-1</url-pattern> </servlet-mapping> <security-constraint> <web-resource-collection> <web-resource-name>all jsp-file</web-resource-name> <url-pattern>*.jsp</url-pattern> </web-resource-collection> <auth-constraint> </auth-constraint> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>admin page</web-resource-name> <url-pattern>/admin/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>admin</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>DIGEST</auth-method> <realm-name>admin page</realm-name> </login-config> <security-role> <role-name>admin</role-name> </security-role> <security-role> <role-name>user</role-name> </security-role> </web-app>