… <Service name="Catalina"> <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine defaultHost="localhost" name="Catalina"> <Realm className="org.apache.catalina.realm.JDBCRealm" connectionName="postgres" connectionPassword="postgres" connectionURL="jdbc:postgresql://127.0.0.1:5432/testdb" driverName="org.postgresql.Driver" roleNameCol="enabled" userCredCol="password" userNameCol="name" userRoleTable="users" userTable="users" /> <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." resolveHosts="false" suffix=".txt" /> <Context docBase="testFormAuth" path="/testFormAuth" reloadable="true" source="org.eclipse.jst.j2ee.server:testFormAuth" /> </Host> </Engine> </Service> …
web.xml
<?xml version="1.0" encoding="UTF-8"?> <!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 id="WebApp_ID"> <display-name>testFormAuth</display-name> <security-constraint> <web-resource-collection> <web-resource-name>my first form authentication</web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint> <role-name>1</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/error.html</form-error-page> </form-login-config> </login-config> </web-app>
users.sql
CREATE TABLE USERS ( ID INT4, NAME VARCHAR2 (20), PASSWORD VARCHAR2 (20), ENABLED BIT, PRIMARY KEY (ID) )
usersデータ:
id | name | password | enabled |
1 | user1 | passw | 1 |
0 件のコメント:
コメントを投稿