Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/08/2011, 20:48
Cehdhe
 
Fecha de Ingreso: julio-2011
Mensajes: 11
Antigüedad: 12 años, 9 meses
Puntos: 4
Respuesta: Archivo .htpasswd en Tomcat

Les comento como le hice para proteger mi carpeta.
El archivo web.xml lo encontré en la carpeta WEB-INF, en ese archivo coloque el siguiente código:

Código XML:
Ver original
  1. <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  2.   <description>Servlet and JSP Examples.</description>
  3.   <display-name>Servlet and JSP Examples</display-name>
  4. <security-constraint>
  5.   <display-name>Security Constraint para Validar</display-name>
  6.  <web-resource-collection>
  7.   <web-resource-name>Protected Area</web-resource-name>
  8.  <!--  Define the context-relative URL(s) to be protected -->
  9.   <url-pattern>/jsp/validar/*</url-pattern>
  10.  <!--  If you list http methods, only those methods are protected -->
  11.   <http-method>DELETE</http-method>
  12.   <http-method>GET</http-method>
  13.   <http-method>POST</http-method>
  14.   <http-method>PUT</http-method>
  15.   </web-resource-collection>
  16.  <auth-constraint>
  17.  <!--  Anyone with one of the listed roles may access this area -->
  18.   <role-name>tomcat</role-name>
  19.   <role-name>EsteRoleNombre</role-name>
  20.   </auth-constraint>
  21. </security-constraint>
  22. <!--  Default login configuration uses form-based authentication -->
  23.  <login-config>
  24.   <auth-method>FORM</auth-method>
  25.   <realm-name>Example Form-Based Authentication Area</realm-name>
  26.  <form-login-config>
  27.  <form-login-page>/jsp/validar/login.jsp</form-login-page>
  28.   <form-error-page>/jsp/validar/error.jsp</form-error-page>
  29.   </form-login-config>
  30. </login-config>
  31. </web-app>

Utilice como plantilla el ejemplo que esta en: examples\jsp\security\protected

Última edición por Cehdhe; 11/08/2011 a las 20:53 Razón: Corrección de ortografía