[原创]实施webservice security[ws-凯发k8网页登录

 
鉴于很多系统需要实施ws-security的标准,我们在springside中提供了xfire wss4j的demo,本文介绍springside中spring xfire wss4j的基本配置

[webservice server端配置]
第一,创建一个基本的bookservice
public interface bookservice {
    
/**
     * 按书名模糊查询图书
     
*/

    list findbooksbyname(string name);

    
/**
     * 查找目录下的所有图书
     *
     * 
@param categoryid 如果category为null或“all”, 列出所有图书。
     
*/

    list findbooksbycategory(string categoryid);

    
/**
     * 列出所有分类.
     *
     * 
@return list,或是null。
     
*/

    list getallcategorys();
}

第二,接口扩展,即extend基本的bookservice,在xfire中,不同的wss4j策略需要针对不同的serviceclass,否则里面的定义会overlap。
public interface bookservicewss4jenc  extends bookservice {

}

public interface bookservicewss4jsign  extends bookservice {

}

第三,配置spring的applicationcontext文件
    
    
<bean id="basewebservice" class="org.codehaus.xfire.spring.remoting.xfireexporter" abstract="true">
        
<property name="servicefactory" ref="xfire.servicefactory"/>
        
<property name="xfire" ref="xfire"/>
    
bean>

    
<bean class="org.springframework.web.servlet.handler.simpleurlhandlermapping">
        
<property name="mappings">
            
<value>
                /bookservice=bookservice
                /bookservicewss4j=bookservicewss4j
                /bookservicewss4jenc=bookservicewss4jenc
                /bookservicewss4jsign=bookservicewss4jsign
            
value>
        
property>
    
bean>

   

    
<bean id="bookservice" class="org.codehaus.xfire.spring.remoting.xfireexporter">
        
<property name="servicefactory" ref="xfire.servicefactory"/>
        
<property name="xfire" ref="xfire"/>
        
<property name="servicebean" ref="bookmanager"/>
        
<property name="serviceclass" value="org.springside.bookstore.plugins.xfire.service.bookservice"/>
    
bean>

    

    
<bean id="bookservicewss4j" class="org.codehaus.xfire.spring.remoting.xfireexporter">
        
<property name="servicebean" ref="bookmanager"/>
        
<property name="serviceclass" value="org.springside.bookstore.plugins.xfire.service.bookservicewss4j"/>
        
<property name="inhandlers">
            
<list>
                
<ref bean="dominhandler"/>
                
<ref bean="wss4jinhandler"/>
                
<ref bean="validateusertokenhandler"/>
            
list>
        
property>
    
bean>

    
<bean id="dominhandler" class="org.codehaus.xfire.util.dom.dominhandler"/>

    
<bean id="wss4jinhandler" class="org.codehaus.xfire.security.wss4j.wss4jinhandler">
        
<property name="properties">
            
<props>
                
<prop key="action">usernametokenprop>
                
<prop key="passwordcallbackclass">org.springside.bookstore.plugins.xfire.wss4j.passwordhandlerprop>
            
props>
        
property>
    
bean>

    
<bean id="validateusertokenhandler" class="org.springside.bookstore.plugins.xfire.wss4j.wss4jtokenhandler"/>
    
    

    
<bean id="bookservicewss4jenc" class="org.codehaus.xfire.spring.remoting.xfireexporter">
        
<property name="servicebean" ref="bookmanager"/>
        
<property name="serviceclass" value="org.springside.bookstore.plugins.xfire.service.bookservicewss4jenc"/>
        
<property name="inhandlers">
            
<list>
                
<ref bean="dominhandler"/>
                
<ref bean="wss4jinhandlerenc"/>
                
<ref bean="validateusertokenhandler"/>
            
list>
        
property>
    
bean>
        
    
<bean id="wss4jinhandlerenc" class="org.codehaus.xfire.security.wss4j.wss4jinhandler">
        
<property name="properties">
          
<props>
            
<prop key="action">encryptprop>
            
<prop key="decryptionpropfile">org/springside/bookstore/plugins/xfire/wss4j/insecurity_enc.propertiesprop>
            
<prop key="passwordcallbackclass">org.springside.bookstore.plugins.xfire.wss4j.passwordhandlerprop>
          
props>
        
property>
    
bean>
    
    

    
<bean id="bookservicewss4jsign" class="org.codehaus.xfire.spring.remoting.xfireexporter">
        
<property name="servicebean" ref="bookmanager"/>
        
<property name="serviceclass" value="org.springside.bookstore.plugins.xfire.service.bookservicewss4jsign"/>
        
<property name="inhandlers">
            
<list>
                
<ref bean="dominhandler"/>
                
<ref bean="wss4jinhandlersign"/>
                
<ref bean="validateusertokenhandler"/>
            
list>
        
property>
    
bean>
    
    
<bean id="wss4jinhandlersign" class="org.codehaus.xfire.security.wss4j.wss4jinhandler">
        
<property name="properties">
          
<props>
            
<prop key="action">signatureprop>
            
<prop key="signaturepropfile">org/springside/bookstore/plugins/xfire/wss4j/insecurity_sign.propertiesprop>
            
<prop key="passwordcallbackclass">org.springside.bookstore.plugins.xfire.wss4j.passwordhandlerprop>
          
props>
        
property>
    
bean>
    
beans>

第四,配置insecurity_enc.properties和insecurity_sign.properties两个密钥库配置文件
insecurity_enc.properties:
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.merlin
org.apache.ws.security.crypto.merlin.keystore.type
=jks
org.apache.ws.security.crypto.merlin.keystore.password
=
org.apache.ws.security.crypto.merlin.alias.password
=
org.apache.ws.security.crypto.merlin.keystore.alias
=david
org.apache.ws.security.crypto.merlin.file
=org/springside/bookstore/plugins/xfire/wss4j/springside_private.jks

outsecurity_sign.properties:
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.merlin
org.apache.ws.security.crypto.merlin.keystore.type
=jks
org.apache.ws.security.crypto.merlin.keystore.password
=
org.apache.ws.security.crypto.merlin.keystore.alias
=david
org.apache.ws.security.crypto.merlin.file
=org/springside/bookstore/plugins/xfire/wss4j/springside_public.jks

第五,使用securex生成了两个keystore文件
springside_private.jks
别名名称: david
创建日期: 
2006-8-6
输入类型:keyentry
认证链长度: 
1
认证 
[1]:
owner: cn
=david, ou=, o=org, l=gz, st=gd, c=cn
发照者: cn
=david, ou=, o=org, l=gz, st=gd, c=cn
序号: 44d4cdcd
有效期间: sun aug 
06 00:56:45 cst 2006 至: mon aug 06 00:56:45 cst 2007
认证指纹:
         md5:  cf:
97:13:0c:70:d0:4d:b6:b4:27:0f:1a:0b:cf:d9:f2
         sha1: 8e:8e:e8:bc:
64:39:c8:43:e4:f7:1b:3b:ce:48:1d:6b:a0:2b:58:b5

springside_public.jks
别名名称: david
创建日期: 
2006-8-6
输入类型: trustedcertentry

owner: cn
=david, ou=, o=org, l=gz, st=gd, c=cn
发照者: cn
=david, ou=, o=org, l=gz, st=gd, c=cn
序号: 44d4cdcd
有效期间: sun aug 
06 00:56:45 cst 2006 至: mon aug 06 00:56:45 cst 2007
认证指纹:
         md5:  cf:
97:13:0c:70:d0:4d:b6:b4:27:0f:1a:0b:cf:d9:f2
         sha1: 8e:8e:e8:bc:
64:39:c8:43:e4:f7:1b:3b:ce:48:1d:6b:a0:2b:58:b5

第五,新版本springside需要

并且要配置java.security
另外,还要使用jdk加密增强策略


用户要使用wss4j,需要配置bouncycastle这个securityprovider,否则
运行enc模式的xfire认证的时候,会抛出异常:
org.apache.ws.security.wssecurityexception: an unsupported signature or encryption algorithm was used unsupported key
配合java.security也是非常简单:
在最后加入bouncycastleprovider。
security.provider.1=sun.security.provider.sun
security.provider.2=com.sun.net.ssl.internal.ssl.provider
security.provider.3=com.sun.rsajca.provider
security.provider.4=com.sun.crypto.provider.sunjce
security.provider.5=sun.security.jgss.sunprovider
security.provider.6=org.bouncycastle.jce.provider.bouncycastleprovider

[webservice client端配置]
1,encrypt模式的client是在客户端用david的公钥加密soap里面的usernametoken,然后发送到web服务,web服务用david的私钥来验证。这种模式需要客户端预先知道服务器端的公钥。

在encrypt模式中,需要这样配置clienthandler:
        service servicemodel = new objectservicefactory().create(bookservicewss4jenc.class);
        xfireproxyfactory factory 
= new xfireproxyfactory(getxfire());

        bookservice service 
= (bookservice) factory.create(servicemodel, "xfire.local://bookservicewss4jenc");

        client client 
= ((xfireproxy) proxy.getinvocationhandler(service)).getclient();
        
//挂上wss4jouthandler,提供认证
        client.addouthandler(new domouthandler());
        properties properties 
= new properties();
        configureoutproperties(properties);
        client.addouthandler(
new wss4jouthandler(properties));

        list list 
= service.getallcategorys();
configureoutproperties函数负责指定client使用何种安全策略,没错,使用outsecurity_enc.properties,这个properties是跟server端的insecurity_enc.properties一起使用的。
    protected void configureoutproperties(properties config) {
        config.setproperty(wshandlerconstants.action, wshandlerconstants.encrypt);
        config.setproperty(wshandlerconstants.user, 
"david");
        
//config.setproperty(wshandlerconstants.pw_callback_class, passwordhandler.class.getname());
        
//configuration of public key used to encrypt message goes to properties file.
        config.setproperty(wshandlerconstants.enc_prop_file,
                               
"org/springside/bookstore/plugins/xfire/outsecurity_enc.properties");
    }

outsecurity_enc.properties:
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.merlin
org.apache.ws.security.crypto.merlin.keystore.type
=jks
org.apache.ws.security.crypto.merlin.keystore.password
=
org.apache.ws.security.crypto.merlin.keystore.alias
=david
org.apache.ws.security.crypto.merlin.file
=org/springside/bookstore/plugins/xfire/wss4j/springside_public.jks


2, sign模式的client同样也是很简单,这种模式是client端用自己的私钥为usernametoken签名,服务器端用client的公钥来验证签名,因此,服务器端需要预先知道客户端的公钥。
对应于encrypt模式,这里的configureoutproperties需要这样来配置:
    protected void configureoutproperties(properties properties) {
        properties.setproperty(wshandlerconstants.action,wshandlerconstants.signature);
        
// user in keystore
        properties.setproperty(wshandlerconstants.user, "david");
        
// this callback is used to specify password for given user for keystore
        properties.setproperty(wshandlerconstants.pw_callback_class, passwordhandler.class.getname());
        
// configuration for accessing private key in keystore
        properties.setproperty(wshandlerconstants.sig_prop_file,"org/springside/bookstore/plugins/xfire/outsecurity_sign.properties");
        properties.setproperty(wshandlerconstants.sig_key_id,
"issuerserial");
    }


outsecurity_sign.properties:
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.merlin
org.apache.ws.security.crypto.merlin.keystore.type
=jks
org.apache.ws.security.crypto.merlin.keystore.password
=
org.apache.ws.security.crypto.merlin.alias.password
=
org.apache.ws.security.crypto.merlin.keystore.alias
=david
org.apache.ws.security.crypto.merlin.file
=org/springside/bookstore/plugins/xfire/wss4j/springside_private.jks

posted on 2006-08-08 09:09 david.turing 阅读(22229) 评论(42)     所属分类: security领域

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-08 09:17 江南白衣

酷,xfire终于足够安全,不用再公司项目那样,靠防火墙过滤ip白名单了:)  回复     

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-08 11:40

理论上,sign模式适合分发型的webservice结构,举一个例子,microsoft公司有一个能够计算股市走势的webservice,他当然不希望授权才能访问,于是,他要求调用方为每个soap请求签名,这样他可以确保购买了服务的人才能享受此服务

encrypt模式适合集中式的webservice结构,举一个例子,中国最高人民检察院提供一个webservice服务,它希望民间团体能够向政府举证揭发贪污腐败的官员,于是,他公布了自己的keystore,其中包含了私钥,于是,民间团体可以通过encrypt模式加密一些比较私隐的信息(username),only检察院才能解密(因为他们有私钥)。  回复     

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-08 16:14

david研究axis2没有?  回复     

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-08 16:28

我和白衣都是从axis2转移到xfire,仅仅因为xfire是build on在spring之上,集成spring更容易。  回复     

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-09 23:07

david写篇wss4j中使用opensaml的文章,网上都找不到相关文章  回复     

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-11 08:40

好建议,我打算做一个weblogic 9.2和xfire saml的sso demo  回复     

# re: 实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-08-11 14:30

代表人民感谢你了,只是我用的是axis2,很期待你的作品。  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-09-06 02:24

hi, i have a question regarding to the exception handling. in my app,
the server encrypt the message before sending to client. but when
exception occurs, the client doesn't seem to be able to read the fault,
here is the stacktrace:

org.codehaus.xfire.fault.xfirefault: wss4jinhandler: request does not contain required security header
at org.codehaus.xfire.security.wss4j.wss4jinhandler.invoke(wss4jinhandler.java:159)
at org.codehaus.xfire.handler.handlerpipeline.invoke(handlerpipeline.java:110)
at org.codehaus.xfire.client.client.onreceive(client.java:382)
....

have you experiencing the same problem?

thanks,  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-09-06 10:21

it seems that you have not correctly config the xfire configuration.
i meant that if you use sign-mode, you should not use the encrypt-mode handler

carefully check the configuration



signature
org/springside/bookstore/plugins/xfire/wss4j/insecurity_sign.properties
org.springside.bookstore.plugins.xfire.wss4j.passwordhandler




check the "signature" and "signaturepropfile". be sure not to confuss by "encrypt" and "decryptionpropfile".  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-10-13 12:59

很高兴国内有这样的作品,不过我做了ws-security测试, signature签名这个例子走不通,遇到异常:
org.codehaus.xfire.fault.xfirefault: wshandler: signature: error during message processing org.apache..ws.security.wssecurityexception:signature creation failed; nested exception is: java.lang.nullpointerexception
我很希望能够得到您的指点在ws-security方面。非常感谢!  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2006-10-27 12:53 david.turing

debug一下,我在springside2提供了一个测试的使用类,去借鉴一下?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-01-12 13:24

两种方式按照例子都调通了,不过现在有个问题,我的客户端是通过wsdl用xfire的wsgen生成的,生成了3个文件:bookserviceclient.java/bookserviceimpl.java/bookserviceporttype.java,仍然用例子中的代码,只是把bookservice改成了bookserviceporttype,其他基本没变.
发布的方法如果返回的是基本类型,能正常访问到.如果返回的是对象,客户端就会报错org.codehaus.xfire.fault.xfirefault: couldn't instantiate class. javax.xml.bind.jaxbelement.如果返回的是list,客户端不报错,但list的size为0
对于复杂对象应该怎么处理?用wsgen生成的客户端如何才能和ws security关联起来?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-03-09 15:21

@x@   回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-05-10 18:26

使用wss4j,配置bouncycastle这个securityprovider时,不用更改jdk中的java.security.直接将包bcprov-jdk16-136.jar导入工程即可.下载地址是

  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-05-10 18:31

最近作网关的安全性功能.david关于ws-security的文章讲得非常好.对我的
帮助很大.谢谢~~~~~  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-05-11 10:21

不错不错,我也附上我的客户端中使用spring的sign模式配置

">http://www.springframework.org/dtd/spring-beans.dtd">

class="org.codehaus.xfire.spring.remoting.xfireclientfactorybean">

org.cmb.webservice.service.transaction











class="org.codehaus.xfire.util.dom.domouthandler" />
class="org.codehaus.xfire.security.wss4j.wss4jouthandler">


signature
ws_security
org.cmb.client.web.util.passwordhandler

org/cmb/client/web/util/insecurity.properties

issuerserial



  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2007-05-24 17:14

有个问题想要问一下:
一个webservices的发布接口,既要签名又要加密该怎么配置?
意思就是客户端的请求需要用自己的私钥签名,用服务端的公钥加密,服务端用客户端的公钥验证签名,用自己的私钥解密  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-05-30 13:39

和只作加密或只作签名时的方法基本一样。
例如:
在服务端配置:
















encrypt signature
org/springside/bookstore/plugins/xfire/wss4j/insecurity_sign.properties
org/springside/bookstore/plugins/xfire/wss4j/insecurity_enc.properties
org.springside.bookstore.plugins.xfire.wss4j.passwordhandler






客户端也作相应的修改即可。
注意:1.客户端在配置wshandlerconstants.action时,encrypt signature的顺序不能写反。
2.用于加密和签名的密钥对最好配置成独立的两对。  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-05-30 16:35

@kevin
在xfire-distribution-1.2.6中的example文件夹中有个ws-security例子。也可以借鉴一下。  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-05-31 08:59

我写client代码调用时为什么抛出异常,说namespaceuri cannot be null.  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-06-01 18:27

可能是你的服务端设置了命名空间而客户端没有设置命名空间。
要把服务端和客户端都的命名空间设置成相同的。或者都用默认的  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-06-03 14:39

能和acegi集成实现安全认证?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-06-04 12:05

我没有指定命名空间,如果返回的对象的所有属性都是基本类型的话没有问题,但是如果属性包含别的对象就会抛出异常
  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-06-11 11:04

为什么我的老是报这个错误呢?我使用的是1.26版的。
2007-06-11 10:59:12,640 error - servlet.service() for servlet jsp threw excepti
on
java.lang.illegalstateexception: getoutputstream() has already been called for t
his response
at org.apache.catalina.connector.response.getwriter(response.java:599)
at org.apache.catalina.connector.responsefacade.getwriter(responsefacade
.java:195)
at org.apache.jasper.runtime.jspwriterimpl.initout(jspwriterimpl.java:12
4)
at org.apache.jasper.runtime.jspwriterimpl.flushbuffer(jspwriterimpl.jav
a:117)
at org.apache.jasper.runtime.pagecontextimpl.release(pagecontextimpl.jav
a:191)
at org.apache.jasper.runtime.jspfactoryimpl.internalreleasepagecontext(j
spfactoryimpl.java:115)
at org.apache.jasper.runtime.jspfactoryimpl.releasepagecontext(jspfactor
yimpl.java:75)
at org.apache.jsp.image_jsp._jspservice(image_jsp.java:129)
at org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:97)
at javax.servlet.http.httpservlet.service(httpservlet.java:802)
at org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper
.java:332)
at org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:3
14)
at org.apache.jasper.servlet.jspservlet.service(jspservlet.java:264)
at javax.servlet.http.httpservlet.service(httpservlet.java:802)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(appl
icationfilterchain.java:252)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationf
ilterchain.java:173)
at com.syscanhc.tjy.util.setcharacterencodingfilter.dofilter(setcharacte
rencodingfilter.java:171)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(appl
icationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationf
ilterchain.java:173)
at org.apache.catalina.core.standardwrappervalve.invoke(standardwrapperv
alve.java:213)
at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextv
alve.java:178)
at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.j
ava:126)
at org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.j
ava:105)
at org.apache.catalina.core.standardenginevalve.invoke(standardengineval
ve.java:107)
at org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.jav
a:148)
at org.apache.coyote.http11.http11processor.process(http11processor.java
:869)
at org.apache.coyote.http11.http11baseprotocol$http11connectionhandler.p
rocessconnection(http11baseprotocol.java:664)
at org.apache.tomcat.util.net.pooltcpendpoint.processsocket(pooltcpendpo
int.java:527)
at org.apache.tomcat.util.net.leaderfollowerworkerthread.runit(leaderfol
lowerworkerthread.java:80)
at org.apache.tomcat.util.threads.threadpool$controlrunnable.run(threadp
ool.java:684)
at java.lang.thread.run(thread.java:595)  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-06-12 20:26

.net有可能调用ws-security啊?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2007-08-29 11:05

insecurity_sign.properties
这个文件没有呀  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-09-27 11:29

好像是xfire带的例子的子集  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-10-11 16:20

" encrypt模式的client是在客户端用david的公钥加密soap里面的usernametoken,然后发送到web服务,web服务用david的私钥来验证。这种模式需要客户端预先知道服务器端的公钥。"
encrypt模式是对usernametoken加密还是对整个soap消息加密?如过是前者,那如何对整个soap消息加密来保证消息的安全性呢?  回复     

# re: [原創]實施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2007-12-23 14:19

我在sign的模式下一直出現
could not invoke service.. nested exception is org.codehaus.xfire.fault.xfirefault: wss4jinhandler: security processing failed
但在enc的模式下卻是正常的,我檢查過所有的配置及寫法都是正確的,請問一下問題可能出在那裡?

另外,我用enc的模式在 tcp/ip monitor裡進行觀查,發現client所發出的訊息是有加密,但server端所回覆的卻是明碼,請問我如何進行加密? thanks~~  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2007-12-29 11:38

楼上的第二个问题应该是没有配置outhandlers












...


  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2008-01-15 13:05

写的不错!  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2008-01-15 16:55

16:47:32,875 debug [org.codehaus.xfire.handler.handlerpipeline] invoking handler org.codehaus.xfire.soap.handler.validateheadershandler in phase pre-invoke
16:47:32,906 info [org.codehaus.xfire.handler.defaultfaulthandler] fault occurred!
org.codehaus.xfire.fault.xfirefault: header {security} was not undertsood by the service.
at org.codehaus.xfire.soap.handler.validateheadershandler.assertunderstandsheader(validateheadershandler.java:76)
at org.codehaus.xfire.soap.handler.validateheadershandler.invoke(validateheadershandler.java:53)
at org.codehaus.xfire.handler.handlerpipeline.invoke(handlerpipeline.java:131)
at org.codehaus.xfire.transport.defaultendpoint.onreceive(defaultendpoint.java:64)
at org.codehaus.xfire.transport.abstractchannel.receive(abstractchannel.java:38)
at org.codehaus.xfire.transport.http.xfireservletcontroller.invoke(xfireservletcontroller.java:304)
at org.codehaus.xfire.transport.http.xfireservletcontroller.doservice(xfireservletcontroller.java:129)
at org.codehaus.xfire.transport.http.xfireservlet.dopost(xfireservlet.java:116)
at javax.servlet.http.httpservlet.service(httpservlet.java:717)
at javax.servlet.http.httpservlet.service(httpservlet.java:810)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:252)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.apache.struts2.dispatcher.filterdispatcher.dofilter(filterdispatcher.java:413)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.apache.struts2.dispatcher.actioncontextcleanup.dofilter(actioncontextcleanup.java:99)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.jboss.web.tomcat.filters.replyheaderfilter.dofilter(replyheaderfilter.java:81)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:213)
at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:178)
at org.jboss.web.tomcat.security.customprincipalvalve.invoke(customprincipalvalve.java:39)
at org.jboss.web.tomcat.security.securityassociationvalve.invoke(securityassociationvalve.java:159)
at org.jboss.web.tomcat.security.jacccontextvalve.invoke(jacccontextvalve.java:59)
at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:126)
at org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:105)
at org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:107)
at org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:148)
at org.apache.coyote.http11.http11processor.process(http11processor.java:856)
at org.apache.coyote.http11.http11protocol$http11connectionhandler.processconnection(http11protocol.java:744)
at org.apache.tomcat.util.net.pooltcpendpoint.processsocket(pooltcpendpoint.java:527)
at org.apache.tomcat.util.net.masterslaveworkerthread.run(masterslaveworkerthread.java:112)
at java.lang.thread.run(thread.java:595)  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2008-01-15 16:56

谁能告诉我这个异常是为什么啊?斑竹在吗?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2008-01-15 16:56

16:47:32,875 debug [org.codehaus.xfire.handler.handlerpipeline] invoking handler org.codehaus.xfire.soap.handler.validateheadershandler in phase pre-invoke
16:47:32,906 info [org.codehaus.xfire.handler.defaultfaulthandler] fault occurred!
org.codehaus.xfire.fault.xfirefault: header {security} was not undertsood by the service.
at org.codehaus.xfire.soap.handler.validateheadershandler.assertunderstandsheader(validateheadershandler.java:76)
at org.codehaus.xfire.soap.handler.validateheadershandler.invoke(validateheadershandler.java:53)
at org.codehaus.xfire.handler.handlerpipeline.invoke(handlerpipeline.java:131)
at org.codehaus.xfire.transport.defaultendpoint.onreceive(defaultendpoint.java:64)
at org.codehaus.xfire.transport.abstractchannel.receive(abstractchannel.java:38)
at org.codehaus.xfire.transport.http.xfireservletcontroller.invoke(xfireservletcontroller.java:304)
at org.codehaus.xfire.transport.http.xfireservletcontroller.doservice(xfireservletcontroller.java:129)
at org.codehaus.xfire.transport.http.xfireservlet.dopost(xfireservlet.java:116)
at javax.servlet.http.httpservlet.service(httpservlet.java:717)
at javax.servlet.http.httpservlet.service(httpservlet.java:810)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:252)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.apache.struts2.dispatcher.filterdispatcher.dofilter(filterdispatcher.java:413)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.apache.struts2.dispatcher.actioncontextcleanup.dofilter(actioncontextcleanup.java:99)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.jboss.web.tomcat.filters.replyheaderfilter.dofilter(replyheaderfilter.java:81)
at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:202)
at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:173)
at org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:213)
at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:178)
at org.jboss.web.tomcat.security.customprincipalvalve.invoke(customprincipalvalve.java:39)
at org.jboss.web.tomcat.security.securityassociationvalve.invoke(securityassociationvalve.java:159)
at org.jboss.web.tomcat.security.jacccontextvalve.invoke(jacccontextvalve.java:59)
at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:126)
at org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:105)
at org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:107)
at org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:148)
at org.apache.coyote.http11.http11processor.process(http11processor.java:856)
at org.apache.coyote.http11.http11protocol$http11connectionhandler.processconnection(http11protocol.java:744)
at org.apache.tomcat.util.net.pooltcpendpoint.processsocket(pooltcpendpoint.java:527)
at org.apache.tomcat.util.net.masterslaveworkerthread.run(masterslaveworkerthread.java:112)
at java.lang.thread.run(thread.java:595)  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2008-01-18 16:31

斑竹能给我一个完整的例子吗?例如怎么配置services.xml文件,怎么和spring 整合,怎么生成私钥和公钥和证书等等,还有怎么通过soap header来认证的,怎么通过session认证,怎么实现和acegi的整合,怎么解决上面的问题,希望斑竹给个凯发天生赢家一触即发官网的联系方式,我们可以交流交流,我的email是:362726130@qq.com,谢谢!  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2008-04-15 22:17

终于找到了,迟来的星星  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j)[未登录] 2008-07-27 01:10

如果客户端的是多个密钥的话,服务端怎么处理,怎么选择客户端的公钥来加密呢?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2008-09-24 15:33

securex 是什么啊,怎么用啊?  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2008-09-24 15:33

生成.jks文件的sourcex是什么?怎么用的?什么原理呀?   回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2008-11-26 13:14

真是好文章 在这篇文章的基础上我实现了用户验证 报文加密的ws-security,在结合中出现org.apache.ws.security.components.crypto.merlin cannot create instance这个异常 花费了我一天的时间才解决这问题 最后我是重新配置了一遍密钥库文件,把私钥和密钥对的别名的访问密码重新设定。

但现在我这边还有个问题,因为我这边是c#与java两点交互的系统 不知在c#端能不能怎么加密报文
大家多多指教 email: liubinan@yahoo.com.cn
  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2009-01-15 09:26

@三石
service servicemodel = new objectservicefactory(
new aegisbindingprovider(new jaxbtyperegistry()))
.create(userservicecomporttype.class);

myeclipse自动生成的web service与xfire默认的绑定方式不一样造成的。
xfire默认的绑定方式是:aegis。而生成的客户端是用的jaxb@三石
  回复     

# re: [原创]实施webservice security[ws-security1.0]的encrypt和sign模式(xfire wss4j) 2011-06-02 21:10

不知楼主现在是否还能回答下问题!本人遇到了和srvrv12的第一个问题一样的问题,即在sign的模式下一直出現 could not invoke service.. nested exception is org.codehaus.xfire.fault.xfirefault: wss4jinhandler: security processing failed ,不知是否已经有人解决了,可否赐教下
  回复     

导航

统计

常用链接

留言簿(109)

我参与的团队

随笔分类(126)

随笔档案(155)

文章分类(9)

文章档案(19)

相册

搜索

积分与排名

最新随笔

最新评论

阅读排行榜

评论排行榜

网站地图