我正在使用WIF (System.IdentityModel)类在.NET 4.5中创建一个STS。这个STS需要处理一个ActAs令牌。我已经成功地将客户端原型化为发送ActAs令牌,这将在服务器端产生以下错误消息:
ID3265:找到了ActAs元素,但没有注册令牌处理程序来读取ActAs元素。考虑将一个有效的SecurityTokenHandlerCollection添加到SecurityTokenHanderCollectionManager中以供ActAs使用。
但是,我看不出向SecurityTokenHandlerCollection添加SecurityTokenHanderCollectionManager的任何方法。这是怎么做的?
我尝试了这文档中的建议:
<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令牌?
发布于 2013-01-30 20:22:32
SecurityTokenHandlerCollectionManager上的索引器不是只读的:
// 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设置为所需的集合:
SecurityTokenHandlerCollectionManager["ActAs"] = new SecurityTokenHandlerCollection();
// or:
SecurityTokenHandlerCollectionManager[SecurityTokenHandlerCollectionManager.Usage.ActAs] = new SecurityTokenHandlerCollection();https://stackoverflow.com/questions/14611773
复制相似问题