Аутентификация JAAS не работает в Tomcat - PullRequest
1 голос
/ 24 октября 2019

Я пытаюсь настроить пример конфигурации на сервере Tomcat. Это мои настройки:

файл web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1"
  metadata-complete="true">

    <description>
    ID webapp
    </description>
    <display-name>ID webapp</display-name>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <security-constraint>
    <web-resource-collection>
        <web-resource-name>Admin</web-resource-name>
        <url-pattern>/secure/menu.jsp</url-pattern>
    </web-resource-collection>
    <auth-constraint>
         <role-name>tomcat</role-name>
         <role-name>role1</role-name>
    </auth-constraint>
    </security-constraint>

    <security-role>
         <role-name>tomcat</role-name>
    </security-role>
    <security-role>
         <role-name>role1</role-name>
    </security-role>

    <login-config>
      <auth-method>FORM</auth-method>
      <realm-name>Example Form-Based Authentication Area</realm-name>
      <form-login-config>
        <form-login-page>/secure/login.jsp</form-login-page>
        <form-error-page>/secure/error.jsp</form-error-page>
      </form-login-config>
    </login-config>
</web-app>

файл login.jsp

<html>
<head>
<title>Login Page for Examples</title>
<body bgcolor="white">
<form method="POST" action='<%= response.encodeURL("j_security_check") %>' >
  <table border="0" cellspacing="5">
    <tr>
      <th align="right">Username:</th>
      <td align="left"><input type="text" name="j_username"></td>
    </tr>
    <tr>
      <th align="right">Password:</th>
      <td align="left"><input type="password" name="j_password"></td>
    </tr>
    <tr>
      <td align="right"><input type="submit" value="Log In"></td>
      <td align="left"><input type="reset"></td>
    </tr>
  </table>
</form>
</body>
</html>

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<html>
  <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title>Home Page</title>
  </head>
<body>
<div id="content">
<h1>Sistema de Gestión</h1>

<p>
<a href="secure/menu.jsp">Acceso al Sistema</a></p>
</div>
</body>
</html>

Основная проблема заключается в том, что даже форма не отображается . Только 403-Запрещенная ошибка в веб-браузере, когда я нажимаю ссылку href в index.jsp. Это мое дерево каталогов.

enter image description here

Я не знаю, как приступить к получению формы учетных данных в веб-браузере. Чего мне не хватает?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...