通过IP限制对Servlet的访问

时间:2015-03-25 22:42:53

标签: weblogic

是否可以将对Servlet的访问限制为已定义的IP地址列表?

这与在Weblogic 12.1.1.0上运行的可配置的现成系统有关。我无法访问Java源代码,但我可以在Weblogic控制台中直接修改ear / war文件中的设置。

以下是相关的web.xml文件,它描述了我试图保护的Web服务应用程序。

<!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="XyzWSWebApp">
    <display-name>Xyz Web Services</display-name>
    <description>Xyz Web Service Web-App</description>


  <servlet>
    <servlet-name>AxisServlet</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
    <init-param>
       <param-name>axis.attachments.Directory</param-name>
       <param-value>${java.io.tmpdir}/axis/attachments</param-value>
    </init-param>   
  </servlet>

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

  <session-config>
    <session-timeout>25</session-timeout>
  </session-config>

  <mime-mapping>
    <extension>wsdl</extension>
     <mime-type>text/xml</mime-type>
  </mime-mapping>

  <mime-mapping>
    <extension>xsd</extension>
    <mime-type>text/xml</mime-type>
  </mime-mapping>



  <security-constraint>
     <web-resource-collection>
        <web-resource-name>Xyz Web Services</web-resource-name>
        <url-pattern>/*</url-pattern>
     </web-resource-collection>
     <auth-constraint>
        <description>Users access Xyz Web Services</description>
        <role-name>AgileUser</role-name>
     </auth-constraint>
     <user-data-constraint>
        <description>Define whether to use SSL to transport data</description>
        <transport-guarantee>NONE</transport-guarantee>
     </user-data-constraint>
  </security-constraint>

  <security-constraint>
     <web-resource-collection>
        <web-resource-name>Unprotect web service URL</web-resource-name>
        <url-pattern>/*</url-pattern>   
        <http-method>GET</http-method>     
    </web-resource-collection>
     <user-data-constraint>
        <description>Define whether to use SSL to transport data</description>
        <transport-guarantee>NONE</transport-guarantee>
     </user-data-constraint>  
  </security-constraint>


    <login-config>
     <auth-method>BASIC</auth-method>
     <realm-name>XyzRealm</realm-name>
  </login-config>

  <security-role>
     <description>Users access Xyz</description>
     <role-name>XyzUser</role-name>
  </security-role>

</web-app>

提前致谢。

1 个答案:

答案 0 :(得分:0)

我不知道只使用WebLogic的方法。但是,您可以使用Apache来引导WebLogic并使用mod_authz_core模块来限制IP地址的访问。