禁止用户访问某个目录,比如一些资源文件等等!

在 red5 的oflaDemo实例中web.xml配置文件如下

使得用户禁止访问streams目录下的资源

<security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/streams/*</url-pattern>
        </web-resource-collection>
        <auth-constraint/>
    </security-constraint>
如果浏览器访问则报403 forbidden错误

禁止用户访问某个目录,比如一些资源文件等等!_第1张图片


<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 
   xmlns="http://java.sun.com/xml/ns/j2ee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
   version="2.4"> 
 
    <display-name>oflaDemo</display-name>
	
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>/oflaDemo</param-value>
	</context-param>
 
    <listener>
        <listener-class>org.red5.logging.ContextLoggingListener</listener-class>
    </listener>
    
    <filter>
        <filter-name>LoggerContextFilter</filter-name>
        <filter-class>org.red5.logging.LoggerContextFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>LoggerContextFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
   	<servlet>
		<servlet-name>rtmpt</servlet-name>
		<servlet-class>org.red5.server.net.rtmpt.RTMPTServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	
   	<servlet>
   		<display-name>SecurityTest</display-name>
   		<servlet-name>SecurityTest</servlet-name>
   		<servlet-class>org.red5.demos.oflaDemo.SecurityTest</servlet-class>
   	</servlet>
    
	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/fcs/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/open/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/close/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/send/*</url-pattern>
	</servlet-mapping>

	<servlet-mapping>
		<servlet-name>rtmpt</servlet-name>
		<url-pattern>/idle/*</url-pattern>
	</servlet-mapping>
	
	<servlet-mapping>
		<servlet-name>SecurityTest</servlet-name>
		<url-pattern>/securitytest</url-pattern>
	</servlet-mapping>
    
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/streams/*</url-pattern>
        </web-resource-collection>
        <auth-constraint/>
    </security-constraint>

</web-app>




你可能感兴趣的:(禁止用户访问某个目录,比如一些资源文件等等!)