我想建立一个简单的示例and服务,这是由用户名和密码保护。
作为起点,我使用了:https://docs.jboss.org/author/display/JBWS/WS-Security
问题是:每个客户端,即使凭据错误或丢失,也可以调用web服务方法。所以@EndpointConfig似乎没有效果。但我不知道如何更深入地挖掘,因为我无法通过调试和jboss管理控制台获得有关web服务配置的更详细信息。
Webservice类:
@WebService(serviceName="MyWebService", portName="MyWebServicePort")
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "myconfig")
public class MyWebService{...}jaxws-端点-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>有什么建议可以拒绝未经授权的客户端吗?
发布于 2013-03-22 17:16:37
基本上,您需要在WSDL中发布策略。
您必须在WSDL的binding部分下添加。
<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中看到策略引用。否则,不会进行身份验证/加密。
https://stackoverflow.com/questions/12319087
复制相似问题