首页 新闻 会员 周边 捐助

跪求园子里面懂Java的高手,.NET如何调用基于Axis2开发的加密服务

0
悬赏园豆:5 [已关闭问题] 关闭于 2012-10-10 14:56

情况是这样的,.net系统去调用Axis2开发的加密服务。因为加密所有我是通过拼报文的形式,再通过.net的HttpWebRequest去请求服务器。

AXIS2计算密码的算法是:Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) )。

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
      <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-28760888">
        <wsu:Created>2012-10-08T11:21:49</wsu:Created>
        <wsu:Expires>2012-10-08T11:31:49</wsu:Expires>
      </wsu:Timestamp>
      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-24814400">
        <wsse:Username>***</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">          MTY2NDJmMmI1NTUzNTY5YjY0MDM4NTBkZWZlMTg5MDUwYTcxMDgyNg==         </wsse:Password>
        <wsse:Nonce>2+UZAwD7+BjzRUVJKFq3xQ==</wsse:Nonce>
        <wsu:Created>2012-10-08T11:21:06</wsu:Created>
      </wsse:UsernameToken>
    </wsse:Security>

这个是计算公式:Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) )

标红的nonce节点的值+标红create 节点的值+实际password的值,再通过SHA-1,BASE64加密得到。

我的加密方式:             string pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(content, "SHA1");

和 public static string EncryptString(string sInputString)
        {
            byte[] bInput = Encoding.Default.GetBytes(sInputString);
            try
            {
                return System.Convert.ToBase64String(bInput, 0, bInput.Length);
            }
            catch (System.ArgumentNullException)
            {
                //二进制数组为NULL.
                return "";
            }
            catch (System.ArgumentOutOfRangeException)
            {
                //长度不够
                return "";
            }
        }

而实际正确的是:<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
      <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-28760888">
        <wsu:Created>2012-09-28T09:15:50.114Z</wsu:Created>
        <wsu:Expires>2012-09-28T09:20:50.114Z</wsu:Expires>
      </wsu:Timestamp>
      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-24814400">
        <wsse:Username>***</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">
          Pzf66eK5vDe1//WU++YW4udd+IE=
        </wsse:Password>
        <wsse:Nonce>2+UZAwD7+BjzRUVJKFq3xQ==</wsse:Nonce>
        <wsu:Created>2012-09-28T09:15:50.099Z</wsu:Created>
      </wsse:UsernameToken>
    </wsse:Security>

正确的报文都是Noce24位,Password28位。请教高手AXIS2是怎么生成的啊????

面包快跑的主页 面包快跑 | 初学一级 | 园豆:189
提问于:2012-10-09 18:11
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册