Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / X509SubjectKeyIdentifierClause.cs / 1305376 / 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. //----------------------------------------------------------- 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FontNameConverter.cs
- SafeHandles.cs
- TagPrefixAttribute.cs
- DataServiceExpressionVisitor.cs
- Rule.cs
- WebBrowserSiteBase.cs
- RouteParametersHelper.cs
- WebEventTraceProvider.cs
- MsdtcClusterUtils.cs
- ViewStateException.cs
- Config.cs
- ContractNamespaceAttribute.cs
- CursorInteropHelper.cs
- GroupDescription.cs
- ViewStateModeByIdAttribute.cs
- SortedList.cs
- DataBoundControl.cs
- FixUp.cs
- NavigationService.cs
- Listen.cs
- SafeCryptoHandles.cs
- DbCommandDefinition.cs
- DesignerHelpers.cs
- XmlSchemaAppInfo.cs
- SrgsElementList.cs
- Pair.cs
- XmlSignatureProperties.cs
- TreeView.cs
- ControlParameter.cs
- BindingMemberInfo.cs
- XamlReaderHelper.cs
- HotSpotCollectionEditor.cs
- UrlAuthFailedErrorFormatter.cs
- XmlSchemaDatatype.cs
- WizardStepBase.cs
- EmptyStringExpandableObjectConverter.cs
- StretchValidation.cs
- QilNode.cs
- FunctionDefinition.cs
- SqlNodeAnnotation.cs
- ObjectCacheSettings.cs
- SBCSCodePageEncoding.cs
- Style.cs
- DataGridBeginningEditEventArgs.cs
- SmiEventStream.cs
- SmiGettersStream.cs
- PanelStyle.cs
- KeyValueSerializer.cs
- WindowsSolidBrush.cs
- TreeNodeEventArgs.cs
- Completion.cs
- RenderingBiasValidation.cs
- SelectionPatternIdentifiers.cs
- RequestResponse.cs
- MessageSecurityProtocol.cs
- PathGeometry.cs
- BaseTemplateParser.cs
- NetCodeGroup.cs
- DataServiceClientException.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- XsdSchemaFileEditor.cs
- MergeLocalizationDirectives.cs
- Choices.cs
- UpdateDelegates.Generated.cs
- Int32Converter.cs
- CriticalExceptions.cs
- MetadataExporter.cs
- PriorityBinding.cs
- InterleavedZipPartStream.cs
- WinFormsSecurity.cs
- ObjectNavigationPropertyMapping.cs
- ChannelManagerBase.cs
- XmlFormatWriterGenerator.cs
- XmlReflectionMember.cs
- SpellCheck.cs
- __Filters.cs
- SchemaImporterExtensionElement.cs
- SharedDp.cs
- Transaction.cs
- CustomCategoryAttribute.cs
- SoapClientProtocol.cs
- ValidationError.cs
- LoginCancelEventArgs.cs
- CodeDelegateInvokeExpression.cs
- KoreanCalendar.cs
- OleServicesContext.cs
- DataServiceResponse.cs
- DriveNotFoundException.cs
- LowerCaseStringConverter.cs
- RectValueSerializer.cs
- SiteMapSection.cs
- QueryConverter.cs
- EnumValAlphaComparer.cs
- NameValueCache.cs
- SqlFunctions.cs
- SoapFault.cs
- CompilerError.cs
- EditorPartDesigner.cs
- HtmlElementEventArgs.cs
- EncryptedType.cs