谁能指点我对WS-Security的一些不错的介绍?
我正在寻找能够提供相当温和的主题介绍的教程或内容,但我不介意它是否承担了Web服务和SOAP的基本知识.到目前为止,我见过的大部分内容都非常技术性,您需要大量复杂,详细的背景知识才能正确理解它.
我们必须在PHP中实现Web服务以及在.NET中实现一个或多个客户端,因此非常感谢涵盖这两者的资源.
是否可以使用JAX-WS创建WebService,然后使用这样的绑定由WCF客户端使用?
<bindings>
<basicHttpBinding>
<binding name="CaseObjectServicePortBinding" >
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate"/>
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
我现在创建了这样一个没有WSIT的服务,只是一个简单的服务,并且想要忽略传入SOAP消息中的"Security"头.但它失败了:
"无法为权限为'xxxxxxxxxx'的SSL/TLS建立安全通道."
如果我改变:
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate"/>
<message clientCredentialType="Certificate" />
</security>
Run Code Online (Sandbox Code Playgroud)
至:
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
<message clientCredentialType="Certificate" />
</security>
Run Code Online (Sandbox Code Playgroud)
一切都完美无瑕.有什么想法我做错了什么?
让我们假装我拥有的只是emacs.我想实现一个使用WS-Security和JAX-WS的Web服务.有没有人知道实现不依赖Netbeans等工具的客户端的好例子?
谢谢
我在我的项目中使用axis2实现了webservice(服务器端).我们希望在现有Web服务中启用WS-security.我们正在评估apache ramapart模块是否符合我们的需求.这是我们的要求:基本上我们有内部安全框架,提供加密,签名和令牌生成功能.我们的内部安全框架基本上需要以XML形式的一组配置,并且它公开各种API以执行各种安全操作.
现在有了上述环境,我可以想到三种可能的解决方案: -
我可以围绕内部安全框架开发一个axis2模块,并在安全阶段将其安装为.mar文件.所以我不会使用apache rampart.但是这种方法的问题是我不能使用ws-security策略来指定安全断言并确保传入的安全性令牌符合有效的策略.这就像重新发明轮子已经做的那样.
我相信apache rampart强调要求apache wss4j模块进行安全操作.我相信apache wss4j模块提供了一种注册第三方安全提供程序的方法(通过实现CryptoProvider接口).我不确定这是否是可行和可行的解决方案.请建议.
Ws-security策略允许使用自定义令牌.可以使用我们的内部安全框架构建此自定义令牌.所以基本上它使我们能够使用apache rampart模块创建ws-security策略,并使用我们的安全框架开发自定义令牌.但我在互联网上找不到这方面的帮助.有谁可以帮助举例.
任何其他建议也是最受欢迎的.
我已经完成了几个教程的混搭,也没有太成功!
我试图让Apache CXF和WS-Security回调我的Spring Security身份验证器.一切都接近工作但是在某个时刻,我在获取密码以使Spring安全性退出WS-call时遇到问题.
下面的处理程序变得很难,但pc.getPassword()为空.我希望这是在Soap中发送的密码,所以我可以把它传递给spring
public class ServerPasswordCallback implements CallbackHandler {
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
pc.setPassword( pc.getPassword() );
}
Run Code Online (Sandbox Code Playgroud)
我的拦截器设置如此
<bean id="wsAuthenticationInterceptor" class="com.olympus.viewtheworld.server.security.auth.WSAuthenticationInInterceptor">
<constructor-arg index="0">
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackClass" value="com.olympus.viewtheworld.server.security.auth.ServerPasswordCallback" />
</map>
</constructor-arg>
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
<jaxws:endpoint id="secureHelloService"
implementor="#secureHelloServiceImpl"
implementorClass="com.olympus.viewtheworld.server.service.Impl.SecureHelloServiceImpl"
address="/SoapService/secure/hello">
<jaxws:serviceFactory>
<ref bean="jaxws-and-aegis-service-factory" />
</jaxws:serviceFactory>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
<ref bean="wsAuthenticationInterceptor" />
</jaxws:inInterceptors>
</jaxws:endpoint>
Run Code Online (Sandbox Code Playgroud)
我从SoapUI发出的soap请求是
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个"java first"webservice,它将使用简单的UsernameToken WS-Security.我试图遵循CXF的例子.当我查询我的wsdl时,我看不到任何与ws-security相关的内容.我正在使用CXF 2.7.5,我正在尝试用注释做所有事情.
以下是我失败的尝试:
SampleService.java:
import java.util.ArrayList;
import java.util.Date;
import javax.jws.WebParam;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.apache.cxf.annotations.EndpointProperties;
import org.apache.cxf.annotations.EndpointProperty;
@WebService(targetNamespace="https://test.company.com/ws/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@EndpointProperties({
@EndpointProperty(key = "action", value="UsernameToken"),
@EndpointProperty(key = "passwordType", value="PasswordText"),
@EndpointProperty(key = "ws-security.callback-handler", value="PasswordHandler"),
//@EndpointProperty(key = "ws-security.validate.token", value="false"),
})
public interface SampleService {
@WebMethod
public String getSample(
@WebParam(name="startDate") Date startDate,
@WebParam(name="endDate") Date endDate);
}
Run Code Online (Sandbox Code Playgroud)
SampleServiceImpl.java:
import java.util.Date;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(endpointInterface = "SampleService", targetNamespace="https://test.company.com/ws/")
public class SampleServiceImpl implements SampleService {
@Override
@WebMethod
public String …Run Code Online (Sandbox Code Playgroud) 是否有任何开源的jax-ws处理程序实现了不依赖于cxf或axis2的基于策略的WS-Security?
我的主要用例是实现webservice客户端,但是使用cxf或axis2意味着我必须使用大量的库才能使用wss4j.
理想情况下,我想仅依赖于wss4j + neethi和加密包.
我正在尝试从Java调用Web服务。除了Web服务期望以用户名和密码以及随机数的形式提供某种安全性外,这基本上没有那么困难。当我尝试从SoapUi调用Web服务时,我看到原始消息看起来像这样:
<soapenv:Envelope xmlns:sch="http://somedomain.com/pe/ws/schema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-E70691ACBDEFEC750814238295617871">
<wsse:Username>usr</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"
>pw</wsse:Password>
<wsse:Nonce
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
>4smQZF5KMSktEXrQc0v5yw==</wsse:Nonce>
<wsu:Created>2015-02-13T12:12:41.784Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<sch:EventSubmitRequest>
<sch:Event>
<sch:EventId>392</sch:EventId>
<sch:Recoverable>false</sch:Recoverable>
</sch:Event>
</sch:EventSubmitRequest>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
消息中显而易见的元素是用户名,密码和已创建,但让我感到困惑的是随机数。在示例中,该字段的值为4smQZF5KMSktEXrQc0v5yw ==,但是每个请求的值都不同(这很有意义,因为根据Wikipedia,随机数是仅使用一次的任意数字)。在四处搜索时,我找不到如何在Java中生成随机数的可用示例(尽管我确实在堆栈溢出时找到了一些php示例,但我无法轻松地验证它们是否起作用)。虽然我不介意自己构造该随机数,但我想知道这是否真的必要,但我有点希望这是Java中的标准功能。
以下是我正在使用的代码:
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class soaptest {
public static void main(String args[]) {
try {
// Create SOAP Connection
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
// Send SOAP Message to SOAP Server
String url = …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置将使用WSHttpBinding进行通信的客户端(Web应用程序)和服务(WCF服务).看来为了使用这种绑定,客户端发送初步消息来设置频道.
在客户端和服务之间存在一个服务总线,它在自定义头上进行路由.使用BasicHttpBinding安全性时,该消息没有问题.
我的问题是:有没有办法在初步的RequestSecurityToken消息中添加相同的自定义标头?
先感谢您.
我已经为我的WS-Client启用了调试日志
Client client = ClientProxy.getClient(port);
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
client.getOutInterceptors().add(loggingOutInterceptor);
client.getInInterceptors().add(loggingInInterceptor);
Run Code Online (Sandbox Code Playgroud)
不幸的是,这会产生如下输出:
[...]
<soap:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="_fac28258-8b72-4e26-8936-f8ec39d36941">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="ED-c2e3310c-c15c-44f9-b458-d2f84bbad79f" Type="http://www.w3.org/2001/04/xmlenc#Content">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
[...]
<xenc:CipherData>
<xenc:CipherValue>YSeTqiVf7/yDrgG8Vp/eUp5lbl4pJpFvkyv4spNKRmoD+0j1XmI4YIWhiFldlBwRqsaAhSDHR0p9nj6Hq37elnXWj2PAFvAqBprh2sxN9q06cWEmIOo8yvC/te41GyVTWGwe0qnS7Q3J79p5LbnUBFZl3pHzAVJDAYG4NMeJE6iAw1gwVIYEraS495d09oYBEV29C9Q1RsHO0xIeg2pzuZv0epm8X5zTCJidGe7sEn0Ko9u+3uLonAqMYgFUeKX+CwTq8ZDCe1LJcrp41S/n7HEj2HdrnVrQ0U+ZqamBUF3J9w+buH26YFuIF61UAv+xedual+RpgxMj+kKqMeIbhcZfxoaVv7PjsIbyDNNwUk/TVfxycF9KosQzWllImmAV514roVo3WzaFHUzcqX+bKpcfYbQaH4E0at+NV4mBUymY6sQar9QskSH5yYUgocDwR5/K45xtxiVDldWKtAOjERhIiWmIMvVLsDY6s43XLH5rtHuRpSOPLKuugtFLvBc/zo1cLkMvzcpCzwzMK/yTTA+/S5Sm5aVMnrASegFd/hsvfwjNgHVnAPTjVAcRe8FlxaT51XyUBWS/LGQGLH5ZhKBLJqQ4TOD+Gj6VfvREDVBIDmmnoWL/Sa5NdcVQ03WrUbq9x71C179p0Kas8u950iWO0lq/bFqVlcZKegSW0/wQ0OLR7C4tBk06XoM4UhT2MJa/4aFUhFuo4PZhK4GbdSLwrO0ECuNPfLF0Fae4xLNglSCGFhfBZ4FlfqqPvnJOB4S24r7sTXamjPyS49m70yIn/mk/vFgc5fzcrMwMwMweQm/tjKYT4eJIkNqpW6M3QcACNkJUyrOjl2mf0lDyrkEcZPFr6v+Fae/5B70H48kUgRDFp6ozsZiP+XiooVfKisskBNrKZNcS34101VUCOC9opZnNO5Tr9XvLYKN9lQQ=</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</soap:Body>
Run Code Online (Sandbox Code Playgroud)
如果我需要澄清传输的业务数据,这对我们来说真的没有用.
有没有办法在加密之前获取传出的SOAP信封以及解密后传入的SOAP信封各自?