2011-06-13 72 views
2

我有两个Web服务(为MyService和MyProtectedService)。我希望两者都在相同的端口HTTPS下,但只有受保护的端口具有客户端身份验证(clientAuth = true)。Tomcat的安全访问

所有的安全工作正常,但问题是,客户端验证为ON两种服务,不仅为保护一个。我想要的是为其中一个移除客户端身份验证,或者仅将客户端身份验证应用于另一个身份验证。

没有人有什么暗示?由于

在web.xml:

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>protected element</web-resource-name> 
     <description/> 
     <url-pattern>/MyProtectedService</url-pattern> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 

更新: 我试过两个约束来划分服务:

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>OpenService</web-resource-name> 
     <description/> 
     <url-pattern>/OpenService</url-pattern> 
    </web-resource-collection> 
</security-constraint> 

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>protected</web-resource-name> 
     <description/> 
     <url-pattern>/MyProtectedService</url-pattern> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
    <login-config> 
     <auth-metod>CLIENT-CERT</auth-metod> 
    </login-config> 
</security-constraint> 

而且具有ClientAuth = server.xml中假。

但后来我可以访问此无需任何客户端身份验证: https://MACHINE/MyProtectedService/MyProtectedService?wsdl

回答

2

的办法是有两个独立的安全约束即使一个为大众服务具有完全没有约束(既没有auth-constraint也不一个user-data-constraint)。它假定两个服务具有不同的网址,这是最有可能的情况:

<security-role> 
    <role-name>ProtectedServiceRole</role-name> 
</security-role> 

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>Public Service</web-resource-name> 
     <url-pattern>/PublicService/*</url-pattern> 
    </web-resource-collection> 
</security-constraint> 

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>Protected Service</web-resource-name> 
     <url-pattern>/ProtectedService/*</url-pattern> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
    <auth-constraint> 
     <role-name>ProtectedServiceRole</role-name> 
    </auth-constraint> 
</security-constraint> 

auth-constraint指定将触发验证的角色名称。

更新:

恐怕我还没有正确读取你的问题,忽略了证书认证的一部分。尽管我已经使用过它,但我从来没有进行过混合设置,所以我只能给出一些选项,您可以尝试下一步:

当前,您需要传输级别的身份验证。这是低级和太早。您是否尝试设置clientAuth,取而代之的是以下行添加到你的web.xml:

<login-config> 
    <auth-method>CLIENT-CERT</auth-method> 
</login-config> 

另一种方法是使用两个不同的充端口的两个服务。对于这一点,你在server.xml定义两个不同的连接器

+0

谢谢您的回答。我尝试过这一点,我认为还有其他事情涉及到,因为我仍然被要求提供证书。如果不是https,我使用http:443,那么我会得到奇怪的字符。有任何想法吗? – 2011-06-15 09:32:01

+0

@Codo,它似乎像Tomcat总是要求客户端身份验证(在web.xml之前检查server.xml,这是有道理的),所以我不认为你提到的可以工作...: - ? – 2011-06-15 12:29:38

+0

任何有用的解决方案? – 2011-06-20 14:48:26