Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / X509SubjectKeyIdentifierClause.cs / 1 / X509SubjectKeyIdentifierClause.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel.Tokens
{
using System.Globalization;
using System.Security.Cryptography.X509Certificates;
public class X509SubjectKeyIdentifierClause : BinaryKeyIdentifierClause
{
const string SubjectKeyIdentifierOid = "2.5.29.14";
const int SkiDataOffset = 2;
public X509SubjectKeyIdentifierClause(byte[] ski)
: this(ski, true)
{
}
internal X509SubjectKeyIdentifierClause(byte[] ski, bool cloneBuffer)
: base(null, ski, cloneBuffer)
{
}
static byte[] GetSkiRawData(X509Certificate2 certificate)
{
if (certificate == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("certificate");
X509SubjectKeyIdentifierExtension skiExtension =
certificate.Extensions[SubjectKeyIdentifierOid] as X509SubjectKeyIdentifierExtension;
if (skiExtension != null)
{
return skiExtension.RawData;
}
else
{
return null;
}
}
public byte[] GetX509SubjectKeyIdentifier()
{
return GetBuffer();
}
public bool Matches(X509Certificate2 certificate)
{
if (certificate == null)
return false;
byte[] data = GetSkiRawData(certificate);
return data != null && Matches(data, SkiDataOffset);
}
public static bool TryCreateFrom(X509Certificate2 certificate, out X509SubjectKeyIdentifierClause keyIdentifierClause)
{
byte[] data = GetSkiRawData(certificate);
keyIdentifierClause = null;
if (data != null)
{
byte[] ski = SecurityUtils.CloneBuffer(data, SkiDataOffset, data.Length - SkiDataOffset);
keyIdentifierClause = new X509SubjectKeyIdentifierClause(ski, false);
}
return keyIdentifierClause != null;
}
public static bool CanCreateFrom(X509Certificate2 certificate)
{
return null != GetSkiRawData(certificate);
}
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "X509SubjectKeyIdentifierClause(SKI = 0x{0})", ToHexString());
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DebugInfoGenerator.cs
- datacache.cs
- CodeObject.cs
- FrugalMap.cs
- TextTreeRootTextBlock.cs
- XmlSchemaSequence.cs
- DescendantOverDescendantQuery.cs
- safex509handles.cs
- WebDescriptionAttribute.cs
- SoapFault.cs
- ControlUtil.cs
- x509store.cs
- Vector3DAnimationUsingKeyFrames.cs
- SoapHttpTransportImporter.cs
- MatrixAnimationUsingPath.cs
- SiteMapNode.cs
- InternalDuplexChannelListener.cs
- ExternalFile.cs
- AdvancedBindingEditor.cs
- ThousandthOfEmRealPoints.cs
- ListQueryResults.cs
- ObjectDataSourceDisposingEventArgs.cs
- TypeUnloadedException.cs
- coordinator.cs
- AnnotationStore.cs
- ScrollBarRenderer.cs
- InternalSafeNativeMethods.cs
- PasswordBox.cs
- BitHelper.cs
- CookieProtection.cs
- OdbcEnvironment.cs
- RowBinding.cs
- SolidColorBrush.cs
- PolyLineSegment.cs
- RsaSecurityKey.cs
- MemberHolder.cs
- PropertyItemInternal.cs
- LongValidator.cs
- SchemaTypeEmitter.cs
- FormatterServices.cs
- HttpContext.cs
- Clock.cs
- SqlCommandSet.cs
- Exceptions.cs
- MailMessageEventArgs.cs
- MarkedHighlightComponent.cs
- ISO2022Encoding.cs
- WorkerRequest.cs
- MarginCollapsingState.cs
- CustomErrorCollection.cs
- PolicyLevel.cs
- LogicalTreeHelper.cs
- FormsAuthenticationConfiguration.cs
- DataGridViewCellMouseEventArgs.cs
- CngUIPolicy.cs
- ZoneButton.cs
- IisTraceListener.cs
- querybuilder.cs
- DataListItemCollection.cs
- TypeDescriptor.cs
- UnionCodeGroup.cs
- AnnotationService.cs
- HttpCacheVaryByContentEncodings.cs
- ObjectViewFactory.cs
- Int16Storage.cs
- SelectionPattern.cs
- PnrpPermission.cs
- DataTemplateSelector.cs
- SubclassTypeValidatorAttribute.cs
- RegexCode.cs
- StaticResourceExtension.cs
- ApplicationException.cs
- XD.cs
- SafeEventLogWriteHandle.cs
- SqlFileStream.cs
- TextSimpleMarkerProperties.cs
- DateTimeFormatInfoScanner.cs
- XmlChildNodes.cs
- IndexedString.cs
- BasicViewGenerator.cs
- EntityWithKeyStrategy.cs
- EditCommandColumn.cs
- NamedPermissionSet.cs
- AppSettings.cs
- ScriptResourceInfo.cs
- DateTimeStorage.cs
- MethodBody.cs
- DynamicActivity.cs
- DayRenderEvent.cs
- VerificationException.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- ToolboxSnapDragDropEventArgs.cs
- WeakHashtable.cs
- CommonObjectSecurity.cs
- EditorPart.cs
- CreateRefExpr.cs
- AuthenticationConfig.cs
- Matrix.cs
- DataStorage.cs
- Dispatcher.cs