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
- RawTextInputReport.cs
- RevocationPoint.cs
- WebPartExportVerb.cs
- OdbcConnectionHandle.cs
- Util.cs
- DateTimeOffsetConverter.cs
- ObjectHandle.cs
- SqlCommandBuilder.cs
- DependencyStoreSurrogate.cs
- NumberFormatter.cs
- MulticastNotSupportedException.cs
- recordstatescratchpad.cs
- UrlPath.cs
- PrinterSettings.cs
- UrlAuthFailedErrorFormatter.cs
- streamingZipPartStream.cs
- Pair.cs
- DtdParser.cs
- TextFormatter.cs
- StrokeNodeOperations.cs
- AmbiguousMatchException.cs
- HuffmanTree.cs
- List.cs
- CompoundFileStreamReference.cs
- BitmapEffectState.cs
- PageCatalogPart.cs
- PeerNodeAddress.cs
- ReferenceList.cs
- SByte.cs
- XXXInfos.cs
- QuaternionKeyFrameCollection.cs
- ColorAnimationUsingKeyFrames.cs
- GuidConverter.cs
- ToolStripLabel.cs
- TextSelectionProcessor.cs
- VScrollBar.cs
- DataGridItemCollection.cs
- ArgumentNullException.cs
- WebPartConnectionsConfigureVerb.cs
- ColorConvertedBitmap.cs
- XPathItem.cs
- SortKey.cs
- TcpConnectionPoolSettings.cs
- OleDbDataReader.cs
- OracleRowUpdatingEventArgs.cs
- SchemaMerger.cs
- Slider.cs
- WindowsAuthenticationModule.cs
- arclist.cs
- WebPartTransformerAttribute.cs
- JsonDeserializer.cs
- ReadWriteObjectLock.cs
- UnitySerializationHolder.cs
- ExpressionNode.cs
- DocumentGridPage.cs
- ObjectReaderCompiler.cs
- DocumentApplicationJournalEntry.cs
- SQLInt64.cs
- Rect3D.cs
- GPStream.cs
- InboundActivityHelper.cs
- Rotation3D.cs
- SvcMapFileSerializer.cs
- Geometry.cs
- GroupLabel.cs
- EmbeddedMailObjectsCollection.cs
- ResourceReferenceKeyNotFoundException.cs
- DefaultPrintController.cs
- Activation.cs
- EpmAttributeNameBuilder.cs
- SafeJobHandle.cs
- DoubleKeyFrameCollection.cs
- Mutex.cs
- EncodingNLS.cs
- TextDpi.cs
- WebPartMinimizeVerb.cs
- DataSourceXmlAttributeAttribute.cs
- DataReaderContainer.cs
- CodeArrayIndexerExpression.cs
- Configuration.cs
- securitycriticaldataformultiplegetandset.cs
- SemanticResolver.cs
- RewritingProcessor.cs
- TypeToken.cs
- WebResourceAttribute.cs
- Vector3DAnimationUsingKeyFrames.cs
- ControlDesignerState.cs
- RawAppCommandInputReport.cs
- PropertyGrid.cs
- CodeExporter.cs
- BinaryObjectReader.cs
- XsltContext.cs
- SelectionItemPatternIdentifiers.cs
- AsyncResult.cs
- ProfilePropertyNameValidator.cs
- XPathAxisIterator.cs
- AccessibilityApplicationManager.cs
- ShaderEffect.cs
- EmbeddedObject.cs
- PowerModeChangedEventArgs.cs