本文整理汇总了C#中System.ServiceModel.Security.Tokens.SecurityTokenParameters.CreateKeyIdentifierClause方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityTokenParameters.CreateKeyIdentifierClause方法的具体用法?C# SecurityTokenParameters.CreateKeyIdentifierClause怎么用?C# SecurityTokenParameters.CreateKeyIdentifierClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Security.Tokens.SecurityTokenParameters
的用法示例。
在下文中一共展示了SecurityTokenParameters.CreateKeyIdentifierClause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWrappedKeyToken
private WrappedKeySecurityToken CreateWrappedKeyToken(SecurityToken wrappingToken, SecurityTokenParameters wrappingTokenParameters, SecurityTokenReferenceStyle wrappingTokenReferenceStyle)
{
int keyLength = Math.Max(0x80, this.Factory.OutgoingAlgorithmSuite.DefaultSymmetricKeyLength);
CryptoHelper.ValidateSymmetricKeyLength(keyLength, this.Factory.OutgoingAlgorithmSuite);
byte[] buffer = new byte[keyLength / 8];
CryptoHelper.FillRandomBytes(buffer);
string id = System.ServiceModel.Security.SecurityUtils.GenerateId();
string defaultAsymmetricKeyWrapAlgorithm = this.Factory.OutgoingAlgorithmSuite.DefaultAsymmetricKeyWrapAlgorithm;
SecurityKeyIdentifierClause clause = wrappingTokenParameters.CreateKeyIdentifierClause(wrappingToken, wrappingTokenReferenceStyle);
SecurityKeyIdentifier wrappingTokenReference = new SecurityKeyIdentifier();
wrappingTokenReference.Add(clause);
return new WrappedKeySecurityToken(id, buffer, defaultAsymmetricKeyWrapAlgorithm, wrappingToken, wrappingTokenReference);
}
示例2: AddPrimaryTokenSignatureReference
void AddPrimaryTokenSignatureReference(SecurityToken token, SecurityTokenParameters securityTokenParameters)
{
// Currently we only support signing the primary token if the primary token is an issued token and protectTokens knob is set to true.
// We will get rid of the below check when we support all token types.
IssuedSecurityTokenParameters istp = securityTokenParameters as IssuedSecurityTokenParameters;
if (istp == null)
{
return;
}
bool strTransformEnabled = istp != null && istp.UseStrTransform;
SecurityKeyIdentifierClause keyIdentifierClause = null;
// Only if the primary token is included in the message that we sign it because WCF at present does not resolve externally referenced tokens.
// This means in the server's response
if (ShouldSerializeToken(securityTokenParameters, this.MessageDirection))
{
if (strTransformEnabled)
{
keyIdentifierClause = securityTokenParameters.CreateKeyIdentifierClause(token, GetTokenReferenceStyle(securityTokenParameters));
}
AddTokenSignatureReference(token, keyIdentifierClause, strTransformEnabled);
}
}
示例3: CreateWrappedKeyToken
WrappedKeySecurityToken CreateWrappedKeyToken(SecurityToken wrappingToken, SecurityTokenParameters wrappingTokenParameters, SecurityTokenReferenceStyle wrappingTokenReferenceStyle)
{
int keyLength = Math.Max(128, this.Factory.OutgoingAlgorithmSuite.DefaultSymmetricKeyLength);
CryptoHelper.ValidateSymmetricKeyLength(keyLength, this.Factory.OutgoingAlgorithmSuite);
byte[] key = new byte[keyLength / 8];
CryptoHelper.FillRandomBytes(key);
string tokenId = SecurityUtils.GenerateId();
string wrappingAlgorithm = this.Factory.OutgoingAlgorithmSuite.DefaultAsymmetricKeyWrapAlgorithm;
SecurityKeyIdentifierClause clause = wrappingTokenParameters.CreateKeyIdentifierClause(wrappingToken, wrappingTokenReferenceStyle);
SecurityKeyIdentifier identifier = new SecurityKeyIdentifier();
identifier.Add(clause);
return new WrappedKeySecurityToken(tokenId, key, wrappingAlgorithm, wrappingToken, identifier);
}