【问题标题】:WS-Security: @EndpointConfig not workingWS-Security:@EndpointConfig 不起作用
【发布时间】:2012-09-07 13:29:00
【问题描述】:

我想构建一个受用户名和密码保护的简单示例 web 服务。

作为我使用的起点:https://docs.jboss.org/author/display/JBWS/WS-Security

问题:每个客户端即使有错误或丢失的凭据也可以调用 Web 服务方法。所以@EndpointConfig 似乎没有效果。 但是我不知道如何深入挖掘,因为我无法通过调试和 jboss 管理控制台获得有关 Web 服务配置的更详细信息。

网络服务类:

@WebService(serviceName="MyWebService", portName="MyWebServicePort")
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "myconfig")
public class MyWebService{...}

jaxws-endpoint-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:javaee="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
  <endpoint-config>
    <config-name>myconfig</config-name>
    <property>
      <property-name>ws-security.username</property-name>
      <property-value>myusername</property-value>
    </property>
    <property>
      <property-name>ws-security.password</property-name>
      <property-value>mypassword</property-value>
    </property>
  </endpoint-config>
</jaxws-config>

有什么建议可以拒绝未经授权的客户吗?

【问题讨论】:

    标签: web-services jboss cxf ws-security jbossws


    【解决方案1】:

    您基本上需要在您的 WSDL 中发布您的策略。

    您必须在 WSDL 的绑定部分下添加。

    <binding name="SecurityServicePortBinding" type="tns:ServiceIface">
    <wsp:PolicyReference URI="#SecurityServiceSignThenEncryptPolicy"/>
    ...
    </binding>
    

    并将策略定义本身添加到您的 WSDL 中。

    <wsp:Policy wsu:Id="SecurityServiceSignThenEncryptPolicy" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
     <wsp:ExactlyOne>
       <wsp:All>
        <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
       ....
     </wsp:ExactlyOne>
    </wsp:Policy>
    

    当您点击您的服务 URL(例如 http://localhost:8080/yourservice?wsdl)时,您应该能够在返回的 WSDL 中看到策略引用。否则,不会发生身份验证/加密。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      • 2018-06-26
      • 2015-08-27
      • 2013-04-28
      • 2016-02-16
      • 2018-02-03
      • 1970-01-01
      相关资源
      最近更新 更多