解答例 - 実習課題4 - 10.アクセス制限
(実習課題4)
実習課題3のWebアプリケーションにMemoryRealmを設定し、web.xmlに設定したアクセス制限が正しく動作していることを確認しなさい。
解答例
<Server port="8005" shutdown="SHUTDOWN" debug="0"> <Service name="Tomcat-Standalone"> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080" minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443" acceptCount="10" debug="0" connectionTimeout="20000" useURIValidationHack="false"/> <Engine name="Standalone" defaultHost="localhost" debug="0"> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/> <Realm className="org.apache.catalina.realm.MemoryRealm" /> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true"> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" /> <Context path="/mitoma" docBase="mitoma/webapp" debug="0" reloadable="true" crossContext="false"> <Realm className="org.apache.catalina.realm.MemoryRealm" debug="1" pathname="mitoma/webapp/WEB-INF/users.xml"/> </Context> </Host> </Engine> </Service> </Server>
<?xml version="1.0" ?> <tomcat-users> <role rolename="admin"/> <role rolename="user"/> <user username="admin" password="admin" roles="admin"/> <user username="user" password="user" roles="user"/> </tomcat-users>