首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在WIF 4.5中处理ActAs令牌?

如何在WIF 4.5中处理ActAs令牌?
EN

Stack Overflow用户
提问于 2013-01-30 19:06:55
回答 1查看 1.1K关注 0票数 2

我正在使用WIF (System.IdentityModel)类在.NET 4.5中创建一个STS。这个STS需要处理一个ActAs令牌。我已经成功地将客户端原型化为发送ActAs令牌,这将在服务器端产生以下错误消息:

ID3265:找到了ActAs元素,但没有注册令牌处理程序来读取ActAs元素。考虑将一个有效的SecurityTokenHandlerCollection添加到SecurityTokenHanderCollectionManager中以供ActAs使用。

但是,我看不出向SecurityTokenHandlerCollection添加SecurityTokenHanderCollectionManager的任何方法。这是怎么做的?

我尝试了文档中的建议:

代码语言:javascript
复制
<securityTokenHandlers name="ActAs">
    ...
</securityTokenHandlers>

但这导致了这个错误:

ID0005:输入'configElement.ElementInformation.Properties‘集合不包含名为'ActAs’的属性。

“等效”(根据该文档)咒语,ServiceConfiguration.SecurityTokenHandlerCollectionManager["ActAs"]同样没有帮助:

未处理的异常:字典中不存在给定密钥的System.Collections.Generic.KeyNotFoundException:。(在System.Collections.Generic.Dictionary`2.get_Item(TKey键)在使用System.IdentityModel.Tokens.SecurityTokenHandlerCollectionManager.get_Item(String时)

请注意,文档提供的信息基本上与1相同,但专门用于.NET 4.5。

如何处理ActAs令牌?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-30 20:22:32

SecurityTokenHandlerCollectionManager上的索引器不是只读的:

代码语言:javascript
复制
// Summary:
//     Returns the security token handler collection for the specified usage.
//
// Parameters:
//   usage:
//     The usage name for the token handler collection.
//
// Returns:
//     The token handler collection associated with the specified usage.
public SecurityTokenHandlerCollection this[string usage] { get; set; }

只需将给定密钥的SecurityTokenHandlerCollection设置为所需的集合:

代码语言:javascript
复制
SecurityTokenHandlerCollectionManager["ActAs"] = new SecurityTokenHandlerCollection();
// or:
SecurityTokenHandlerCollectionManager[SecurityTokenHandlerCollectionManager.Usage.ActAs] = new SecurityTokenHandlerCollection();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14611773

复制
相关文章

相似问题

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