我目前正在构建一个 Java-servlet 应用程序(具体来说,在 GlassFish 上使用 Jersey)。在应用程序的某些部分,我需要使用基本身份验证对用户进行身份验证,而在其他一些部分,我需要使用客户端证书。使用哪一个将取决于请求的路径。例如 /cert/secretMethod1 或 /basic/secretMethod2 。
我怎么做?下面是我当前的 web.xml,它目前只进行基本的身份验证。我想我需要使用两种不同的,但我更愿意只使用一种身份验证领域。是否有 web.xml 的标签/属性使我能够为应用程序的不同路径指定不同的身份验证方法?
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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">
<display-name>
TestServer
</display-name>
<servlet>
<description>Jersey servlet</description>
<display-name>Jersey servlet</display-name>
<servlet-name>JerseyServlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JerseyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>TestServer</display-name>
<web-resource-collection>
<web-resource-name>TestServer</web-resource-name>
<description></description>
<url-pattern>/</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description>Have to be a USER</description>
<role-name>User</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>jpaCustomRealm</realm-name>
</login-config>
<security-role>
<description/>
<role-name>User</role-name>
</security-role>
</web-app>
Run Code Online (Sandbox Code Playgroud) 我正在我的系统上本地开发一个 Web 应用程序,使用 Tomcat (tomcat-7.0.52) 为其提供服务。在生产中,我想用 Apache httpd (Apache/2.2.15) 在 Tomcat 前面。
这有效,我设法根据需要配置缓存。现在我想配置压缩,但似乎无法让Apache httpd修改它从Tomcat获得的响应。
但正如我在这里读到的,这是首选的方式。mod_jk 压缩仅在 httpd 和 Tomcat 之间进行,如果我想直接在 Tomcat 中配置压缩,我需要一个额外的 servlet。
我的 vhost 文件中有以下行来启用静态和 httpd 服务内容的压缩:
#SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/plain text/html application/json text/xml text/css text/javascript
Run Code Online (Sandbox Code Playgroud)
启用第一行对我没有任何改变。
我使用 mod_jk 将这些请求传递给 Tomcat:
<IfModule mod_jk.c>
JkMount /myapp/j_security_check worker1
JkMount /myapp/*.jsp worker1
JkMount /myapp/DataSourceLoader worker1
JkMount /myapp/ServletLogin worker1
</IfModule>
Run Code Online (Sandbox Code Playgroud)
使用 Firebug 我可以看到 Tomcat 返回的请求的 MIME 类型是
/myapp/j_security_check: "text/plain; charset=UTF-8" (with the space)
/myapp/*.jsp: "text/plain; charset=UTF-8" (with the space)
/myapp/DataSourceLoader: "application/json;charset=UTF-8" (without …
Run Code Online (Sandbox Code Playgroud) 我刚刚完成 JIRA 和 Confluence 的安装并在 Ubuntu Server 上运行 Tomcat,这时我注意到网上有关于 JBoss 上的 JIRA/Confluence 的安装说明。
我不熟悉 JEE 应用程序服务器,大部分时间都花在更简单的 servlet 容器上。
然而,假设 JIRA 不使用 EJB,为什么要将其部署到 JBoss 呢?在这种情况下,JBoss 提供了哪些 Tomcat 没有提供的功能?
servlet ×3
tomcat ×2
apache-2.2 ×1
certificate ×1
compression ×1
glassfish ×1
java ×1
jboss ×1
jira ×1
mod-jk ×1