java - 是否可以从 SOAP Web 服务保存客户端证书?

标签 java web-services ssl soap glassfish

我一直在尝试使用 GlassFish 作为 Web 服务器和 SOAP UI 来实现基于数字证书的身份验证和授权,以测试我的应用程序的功能,但作为身份验证过程的一部分,我需要保存所有消息信息的日志,包括在来自使用 Web 服务的客户端的 glassfish 的 cacerts 文件中找到的别名和消息的内容。

是否真的可以从应用层做到这一点?我尝试在服务器端使用消息和逻辑处理程序,但我看不到与数字证书相关的任何内容,我唯一的线索是 SOAP UI 从客户端获取服务器证书。

最佳答案

经过一些研究和一些失败后,我最终将证书详细信息添加到 Web 描述符上的项目并从中捕获用户名,然后找到该用户名的别名,最后在 TrustStore 中搜索别名以获取公钥。

首先我们需要在 web.xml 文件中添加身份验证的详细信息:

<!-- Security constraint for resource only accessible to role -->
<security-constraint>
  <display-name>WebServiceSecurity</display-name>

  <web-resource-collection>
    <web-resource-name>Authorized users only</web-resource-name>
    <url-pattern>/ExampleWSService</url-pattern>
    <http-method>POST</http-method>
  </web-resource-collection>

  <auth-constraint>
    <role-name>user</role-name>
  </auth-constraint>

</security-constraint>  

<!-- BASIC authorization -->
<login-config>
  <auth-method>CLIENT-CERT</auth-method>
</login-config>

<!-- Definition of role -->
<security-role>
  <role-name>user</role-name>
</security-role>

在 sun-web.xml 中,我们添加了角色映射和来自客户端的详细信息,这可以使用公钥检索。

<sun-web-app>
  <security-role-mapping>
    <role-name>user</role-name>
      <!-- <group-name>wsusers</group-name> -->
     <principal-name>CN=Name, OU=Department, O=Organization, L=City, ST=State, C=nl</principal-name>
  </security-role-mapping>
  <security-role-mapping>
    <role-name>user</role-name>
    <group-name>wsusers</group-name>
  </security-role-mapping>
</sun-web-app>

基于本教程:http://javaeenotes.blogspot.com/2010/10/securing-jax-ws-web-services.html

关于java - 是否可以从 SOAP Web 服务保存客户端证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31863633/

相关文章:

java - ZXing QR 代码扫描仪嵌入在扫描过程中按下后退按钮

asp.net - 设置 POST Web API 方法?

ruby - 将 https 用于 ruby​​gems 时出现 SSL 连接问题

java - Jax-ws 2.2 或 Metro 作为 Tomcat 运行时环境

wcf - (网站) 上的网页可能暂时关闭,或者可能已永久移至新网址

ruby-on-rails - SSL 证书 WPEngine 到 Heroku Rails

python - 使用 Python 请求访问 Shibboleth 身份验证服务器时出现 SSL 错误

java - 尝试在 android 中构建一个简单的通知

java - 如何从 Firebase 存储获取 URL getDownloadURL

java - 使用 displaytag JSP 选项卡库对 HTML 表格进行排序