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
- Char.cs
- BinHexEncoder.cs
- ObjectSelectorEditor.cs
- GridViewColumn.cs
- ObjectSecurity.cs
- HttpConfigurationContext.cs
- BindingObserver.cs
- GatewayDefinition.cs
- FlowLayoutPanel.cs
- ReturnValue.cs
- InstalledFontCollection.cs
- SchemaNamespaceManager.cs
- TextReader.cs
- GlobalEventManager.cs
- WebServicesDescriptionAttribute.cs
- DataGridRelationshipRow.cs
- WebServiceHandlerFactory.cs
- SaveCardRequest.cs
- AvTraceFormat.cs
- ScrollEvent.cs
- ELinqQueryState.cs
- DrawingCollection.cs
- RawStylusSystemGestureInputReport.cs
- FixedFlowMap.cs
- peernodestatemanager.cs
- SchemaLookupTable.cs
- Helper.cs
- UiaCoreApi.cs
- TemplateControl.cs
- EventHandlerList.cs
- XDRSchema.cs
- WmfPlaceableFileHeader.cs
- XmlWriterTraceListener.cs
- MetadataHelper.cs
- ServiceReference.cs
- IgnoreFileBuildProvider.cs
- SiteMapHierarchicalDataSourceView.cs
- XPathParser.cs
- DefaultValidator.cs
- ResolvePPIDRequest.cs
- EntityDataSourceStatementEditorForm.cs
- Style.cs
- ResourceProviderFactory.cs
- WebPartTransformer.cs
- WebControlAdapter.cs
- TypedTableBase.cs
- DataGridPageChangedEventArgs.cs
- GlyphsSerializer.cs
- WorkflowEventArgs.cs
- GridEntryCollection.cs
- KernelTypeValidation.cs
- ServiceRoute.cs
- TextChange.cs
- COMException.cs
- SafeThemeHandle.cs
- OdbcConnectionHandle.cs
- XmlDocumentType.cs
- PropertyInfo.cs
- WeakRefEnumerator.cs
- BufferModeSettings.cs
- _CacheStreams.cs
- Unit.cs
- _ConnectStream.cs
- TiffBitmapDecoder.cs
- LocalizableResourceBuilder.cs
- FileUtil.cs
- TransactionContextManager.cs
- Stack.cs
- RowToFieldTransformer.cs
- GeometryValueSerializer.cs
- ExpressionBuilderCollection.cs
- CompositionAdorner.cs
- EditorPartChrome.cs
- Button.cs
- RbTree.cs
- WebUtil.cs
- HttpCacheVary.cs
- CircleEase.cs
- SID.cs
- Trace.cs
- Rect3DValueSerializer.cs
- LinkArea.cs
- EnumMemberAttribute.cs
- RemotingSurrogateSelector.cs
- BinaryReader.cs
- TransformerInfoCollection.cs
- EndpointNotFoundException.cs
- RuntimeArgument.cs
- QilSortKey.cs
- WindowsToolbar.cs
- ClientClassGenerator.cs
- KeyFrames.cs
- LightweightEntityWrapper.cs
- InheritanceContextHelper.cs
- MsmqAppDomainProtocolHandler.cs
- SecurityState.cs
- WebHttpDispatchOperationSelector.cs
- HttpWriter.cs
- WebPartEditVerb.cs
- Sql8ConformanceChecker.cs