首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >已忽略自定义X509SecurityTokenManager

已忽略自定义X509SecurityTokenManager
EN

Stack Overflow用户
提问于 2008-09-17 09:00:46
回答 2查看 675关注 0票数 1

我有一个WSE服务,它在WSE 3.0中使用带有X.509证书的消息层安全性。该服务使用X509v3策略对soapheader中的各种元素进行签名。

我需要对证书进行一些自定义检查,因此我尝试实现了一个自定义X509SecurityTokenManager,并在web.config中添加了一个部分。

当我使用我的Wseproxy调用服务时,我期望得到一个错误(NotImplementedException),但是调用失败了,在下面的例子中,控制台输出了"foo“。

问题是:错过了什么?web.config中的binarySecurityTokenManager类型与RDI.Server.X509TokenManager的完整类名匹配。X509TokenManager继承自X509SecurityTokenManager (尽管方法只是存根)。

代码语言:javascript
复制
using System;
using System.Xml;
using System.Security.Permissions;
using System.Security.Cryptography;
using Microsoft.Web.Services3;
using Microsoft.Web.Services3.Security.Tokens;

namespace RDI.Server
{

[SecurityPermissionAttribute(SecurityAction.Demand,Flags = SecurityPermissionFlag.UnmanagedCode)]
public class X509TokenManager : Microsoft.Web.Services3.Security.Tokens.X509SecurityTokenManager
{
    public X509TokenManager() : base()
    {
        throw new NotImplementedException("Stub");
    }

    public X509TokenManager(XmlNodeList configData) : base(configData)
    {
        throw new NotImplementedException("Stub");
    }

    protected override void AuthenticateToken(X509SecurityToken token)
    {
        base.AuthenticateToken(token);
        throw new NotImplementedException("Stub");
    }
}
}

我的web.config的前几行,为简洁起见进行了编辑

代码语言:javascript
复制
<?xml version="1.0"?>
  <configuration><configSections><section name="microsoft.web.services3" type="..." />
  </configSections>
  <microsoft.web.services3>
    <policy fileName="wse3policyCache.config" />
    <security>
      <binarySecurityTokenManager>
        <add type="RDI.Server.X509TokenManager" valueType="http://docs.oasis-open.org/..." />
      </binarySecurityTokenManager>
    </security>
  </microsoft.web.services3>`

(顺便说一句,如何在stackoverflow上很好地格式化xml?)

代码语言:javascript
复制
Administration.AdministrationWse test = new TestConnector.Administration.AdministrationWse();

X509Certificate2 cert = GetCert("RDIDemoUser2");
X509SecurityToken x509Token = new X509SecurityToken(cert);
test.SetPolicy("X509");
test.SetClientCredential(x509Token);

string message = test.Ping("foo");

Console.WriteLine(message);

我暂时被困在WCF2.0 (VS2005)中,所以我认为WCF2.0是不可能的,否则互操作性不是问题,因为我可以控制系统中的客户端和服务。

EN

回答 2

Stack Overflow用户

发布于 2008-09-18 12:31:59

问题出在别处。我的服务器项目是一个web应用程序,一些选项不适用于web应用程序,只适用于web站点。所以我做了一个小网站项目,对web.configs进行了比较,并注意到一些代码行不同。

这些代码行在网站web.config中,但不在我的另一个项目中

代码语言:javascript
复制
  <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  <soapExtensionImporterTypes>
    <add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </soapExtensionImporterTypes>

在我添加这些行之后,我得到了预期的错误。

票数 1
EN

Stack Overflow用户

发布于 2008-09-17 09:59:33

我知道这不是特别有建设性的建议,但如果我是你,我会尽快离开WSE3.0。今年早些时候,我们做了一些工作,试图让它与WCF和一个Java客户端进行互操作,这是一个显而易见的噩梦。

另一方面,WCF实际上是合理的,关于这类领域的文档也相当不错。这对你来说是一个选择吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/81295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档