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
- ConfigPathUtility.cs
- ThreadStartException.cs
- StatusBarPanel.cs
- Trace.cs
- DbTransaction.cs
- ObjectContextServiceProvider.cs
- BasePattern.cs
- Baml2006SchemaContext.cs
- Pair.cs
- StateMachine.cs
- Socket.cs
- WorkflowItemsPresenter.cs
- Viewport3DAutomationPeer.cs
- AspNetRouteServiceHttpHandler.cs
- ControlBuilder.cs
- InfiniteIntConverter.cs
- MSAANativeProvider.cs
- TextTreeUndoUnit.cs
- TransformPattern.cs
- GradientSpreadMethodValidation.cs
- DocumentCollection.cs
- Permission.cs
- XmlFormatReaderGenerator.cs
- HeaderFilter.cs
- SqlCacheDependencyDatabaseCollection.cs
- VisualBasicHelper.cs
- SqlDataSource.cs
- XmlNamespaceDeclarationsAttribute.cs
- infer.cs
- X509CertificateCollection.cs
- ProcessModuleCollection.cs
- StackSpiller.Temps.cs
- QilGeneratorEnv.cs
- VScrollBar.cs
- RestHandler.cs
- VisualStyleTypesAndProperties.cs
- DataColumnCollection.cs
- TransactionWaitAsyncResult.cs
- ExtensibleClassFactory.cs
- DefaultHttpHandler.cs
- ComplusEndpointConfigContainer.cs
- WmlLinkAdapter.cs
- DataBindingExpressionBuilder.cs
- DmlSqlGenerator.cs
- HostedTransportConfigurationBase.cs
- ItemList.cs
- UtilityExtension.cs
- StringUtil.cs
- WebScriptServiceHostFactory.cs
- XmlSchemaAttribute.cs
- BitVector32.cs
- ToolstripProfessionalRenderer.cs
- PointCollectionValueSerializer.cs
- ImageEditor.cs
- RegexMatchCollection.cs
- DataSourceComponent.cs
- OleCmdHelper.cs
- DesignerToolboxInfo.cs
- SqlCommandBuilder.cs
- LogicalTreeHelper.cs
- IntellisenseTextBox.cs
- XmlSiteMapProvider.cs
- RegistrationServices.cs
- ToRequest.cs
- WebFaultException.cs
- IisTraceListener.cs
- SystemNetHelpers.cs
- _NTAuthentication.cs
- Constraint.cs
- DrawListViewColumnHeaderEventArgs.cs
- AutomationElementIdentifiers.cs
- RepeatBehavior.cs
- DispatcherExceptionEventArgs.cs
- AssemblyBuilderData.cs
- TextStore.cs
- Stack.cs
- EarlyBoundInfo.cs
- RequestCacheValidator.cs
- BaseCollection.cs
- ToolBarPanel.cs
- ListBoxItem.cs
- _AutoWebProxyScriptHelper.cs
- SoapIncludeAttribute.cs
- StateBag.cs
- TimeoutStream.cs
- XmlWellformedWriterHelpers.cs
- CultureSpecificStringDictionary.cs
- SQLInt16Storage.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- DesignerWidgets.cs
- ArrayConverter.cs
- RequestStatusBarUpdateEventArgs.cs
- DataGridViewLayoutData.cs
- ExtensionFile.cs
- SizeF.cs
- VisualBasicExpressionConverter.cs
- CanExecuteRoutedEventArgs.cs
- StrokeNodeData.cs
- MenuItem.cs
- DisableDpiAwarenessAttribute.cs