目次へ

解答例 - 実習課題3 - 11.認証方式

(実習課題3)

HTTPS通信の設定を行い、実習課題2のWebアプリケーションが実行されることを確認しなさい。

またHTTPS通信においても、BASIC認証やDIGEST認証、FORM認証が実行できることを確認しなさい。

解答例

<Server port="8005" shutdown="SHUTDOWN" debug="0">

  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
    debug="0"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
    debug="0"/>

  <GlobalNamingResources>

    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <Resource name="UserDatabase" auth="Container"
      type="org.apache.catalina.UserDatabase"
      description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>

  </GlobalNamingResources>

  <Service name="Tomcat-Standalone">

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
      port="8080" minProcessors="5" maxProcessors="75"
      enableLookups="true" redirectPort="8443"
      acceptCount="100" debug="0" connectionTimeout="20000"
      useURIValidationHack="false" disableUploadTimeout="true" />

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
      port="8009" minProcessors="5" maxProcessors="75"
      enableLookups="true" redirectPort="8443"
      acceptCount="10" debug="0" connectionTimeout="20000"
      useURIValidationHack="false"
      protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

    <!-- Servlet11章 exercise3 HTTPS通信 -->
    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
      port="8443" minProcessors="5" maxProcessors="75"
      enableLookups="true"
      acceptCount="100" debug="0" scheme="https" secure="true"
      useURIValidationHack="false" disableUploadTimeout="true">
      <Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory"
        clientAuth="true" protocol="TLS"
        keystoreFile=".keystore" keystorePass="tomcat" />
    </Connector>

    <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.UserDatabaseRealm"
        debug="0" resourceName="UserDatabase"/>

      <Host name="localhost" debug="0" appBase="webapps"
        unpackWARs="true" autoDeploy="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="true">
          <Realm className="org.apache.catalina.realm.MemoryRealm"
            debug="1"
            pathname="webapps/mitoma/webapp/WEB-INF/users.xml"/>
          <Logger className="org.apache.catalina.logger.FileLogger"
            prefix="mitoma_" suffix=".log" timestamp="true"/>
        </Context>

      </Host>

    </Engine>

  </Service>

</Server>

↑このページの先頭へ

こちらもチェック!

PR
  • XMLDB.jp