<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<tomcat-users version="1.0" xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd">
<!-- NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary. -->
<!-- NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove <!..
..> that surrounds them. -->
<role rolename="tomcat" />
<role rolename="role1" />
<user username="tomcat" password="tomcat1234" roles="tomcat" />
<user username="both" password="both1234" roles="tomcat,role1" />
<user username="role1" password="role1234" roles="role1" />
</tomcat-users>
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<security-role>
<role-name>role1</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>JSPBook</web-resource-name>
<url-pattern>/ch10/security01.jsp</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description></description>
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<p>인증 성공 했습니다
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<security-role>
<role-name>role1</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>JSPBook</web-resource-name>
<url-pattern>/ch10/security01.jsp</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description></description>
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/ch10/login.jsp</form-login-page>
<form-error-page>/ch10/login_failed.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form name="loginForm" action="j_security_check" method="post">
<p> 사용자명 : <input type="text" name="j_username"> </p>
<p> 비밀번호 : <input type="password" name="j_password"> </p>
<p> <input type="submit" value="전송"> </p>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<p>인증 실패했습니다</p>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<security-role>
<role-name>role1</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>JSPBook</web-resource-name>
<url-pattern>/ch10/security02.jsp</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description></description>
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/ch10/login.jsp</form-login-page>
<form-error-page>/ch10/login_failed.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<p> 사용자명 : <%=request.getRemoteUser() %></p>
<p> 인증밥법 : <%=request.getAuthType() %></p>
<p> 인증한 사용자명이 역할명 "tomecat"에 속하는 사용자인가요? : <%=request.isUserInRole("tomcat") %></p>
<p> 인증한 사용자명이 역할명 "role1"에 속하는 사람인가요? : <%=request.isUserInRole("role1") %></p>
</body>
</html>
좋은 정리 감사합니다 잘보고 갑니다! 혹시 자료를 사용하게된다면 출처를 남기겠습니다