我致力于使用 CXF 2.5.2 实现的 JAVA 中 Web 服务的开发。我使用apache Tomcat作为Web服务器。
我需要在某些网络服务方法中添加HTTPS安全性,我想知道实现HTTPS安全性的最佳方法。我听说我可以通过指定安全约束来在网络中配置 HTTPS.xml...或者我可以在Apache tomcat中为任何方法配置HTTPS。
我对每个解决方案的优点和缺点的看法,我认为在 web.xml 中配置 https 的优势是在 webservice 的同一 web 应用程序中进行本地化。apache tomcat 配置的优势允许不耦合到任何 webapp。
我相信有更多的方法可以实现HTTPS。
谢谢!
在 web 中配置安全性.xml
(例如)<security-constraint>
<web-resource-collection>
<web-resource-name>REST Service </web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>User</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test</realm-name>
</login-config>
<security-role>
<role-name>User</role-name>
</security-role>