Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / BinaryKeyIdentifierClause.cs / 1305376 / BinaryKeyIdentifierClause.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel.Tokens { using System.Globalization; using HexBinary = System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary; public abstract class BinaryKeyIdentifierClause : SecurityKeyIdentifierClause { readonly byte[] identificationData; protected BinaryKeyIdentifierClause(string clauseType, byte[] identificationData, bool cloneBuffer) : this(clauseType, identificationData, cloneBuffer, null, 0) { } protected BinaryKeyIdentifierClause(string clauseType, byte[] identificationData, bool cloneBuffer, byte[] derivationNonce, int derivationLength) : base(clauseType, derivationNonce, derivationLength) { if (identificationData == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("identificationData")); } if (identificationData.Length == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("identificationData", SR.GetString(SR.LengthMustBeGreaterThanZero))); } if (cloneBuffer) { this.identificationData = SecurityUtils.CloneBuffer(identificationData); } else { this.identificationData = identificationData; } } public byte[] GetBuffer() { return SecurityUtils.CloneBuffer(this.identificationData); } protected byte[] GetRawBuffer() { return this.identificationData; } public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause) { BinaryKeyIdentifierClause that = keyIdentifierClause as BinaryKeyIdentifierClause; // PreSharp Bug: Parameter 'that' to this public method must be validated: A null-dereference can occur here. #pragma warning suppress 56506 return ReferenceEquals(this, that) || (that != null && that.Matches(this.identificationData)); } public bool Matches(byte[] data) { return Matches(data, 0); } public bool Matches(byte[] data, int offset) { if (offset < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", SR.GetString(SR.ValueMustBeNonNegative))); } return SecurityUtils.MatchesBuffer(this.identificationData, 0, data, offset); } internal string ToBase64String() { return Convert.ToBase64String(this.identificationData); } internal string ToHexString() { return new HexBinary(this.identificationData).ToString(); } } } // 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
- WebPartCollection.cs
- ApplicationFileParser.cs
- RegexNode.cs
- UpdateExpressionVisitor.cs
- DbExpressionBuilder.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- _emptywebproxy.cs
- tooltip.cs
- DeviceFilterDictionary.cs
- EmptyElement.cs
- ViewBase.cs
- NamedPipeTransportBindingElement.cs
- LiteralControl.cs
- SQLConvert.cs
- DocumentViewerHelper.cs
- WindowsContainer.cs
- XpsImageSerializationService.cs
- ProfileSettingsCollection.cs
- XmlSchemaChoice.cs
- UrlMappingCollection.cs
- RectangleConverter.cs
- UrlPath.cs
- LabelDesigner.cs
- DefaultAssemblyResolver.cs
- AllMembershipCondition.cs
- ListView.cs
- ContextQuery.cs
- EmptyEnumerable.cs
- SeekStoryboard.cs
- cookie.cs
- MemoryRecordBuffer.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- TimeEnumHelper.cs
- TypedRowGenerator.cs
- Base64Decoder.cs
- NativeMethods.cs
- InvalidOleVariantTypeException.cs
- BrowsableAttribute.cs
- ActivityWithResultConverter.cs
- LinearKeyFrames.cs
- hresults.cs
- SaveFileDialog.cs
- XmlReflectionImporter.cs
- SQLString.cs
- ReaderWriterLock.cs
- Trace.cs
- base64Transforms.cs
- ErrorTableItemStyle.cs
- sqlmetadatafactory.cs
- Matrix.cs
- RequestCache.cs
- StopStoryboard.cs
- OrderedParallelQuery.cs
- BaseConfigurationRecord.cs
- ControlEvent.cs
- WebPartDisplayModeCollection.cs
- Schema.cs
- HeaderedContentControl.cs
- DataAccessor.cs
- ToolbarAUtomationPeer.cs
- EntityDataSource.cs
- DataBindingsDialog.cs
- HtmlWindow.cs
- Color.cs
- NumericUpDown.cs
- ToolboxItem.cs
- WebPartRestoreVerb.cs
- HandlerFactoryCache.cs
- XmlReflectionMember.cs
- DataTableMapping.cs
- DataGridPageChangedEventArgs.cs
- UriExt.cs
- StylusButtonEventArgs.cs
- ModelPerspective.cs
- IIS7WorkerRequest.cs
- HttpBrowserCapabilitiesBase.cs
- LowerCaseStringConverter.cs
- WebPartMinimizeVerb.cs
- _WinHttpWebProxyDataBuilder.cs
- EntityContainerAssociationSet.cs
- MenuItemStyleCollectionEditor.cs
- HttpException.cs
- TextServicesCompartment.cs
- TransactionBridgeSection.cs
- SpeechDetectedEventArgs.cs
- WebHttpElement.cs
- DataPagerField.cs
- TextParagraph.cs
- Style.cs
- LineInfo.cs
- MarshalDirectiveException.cs
- CompilerGlobalScopeAttribute.cs
- ModuleElement.cs
- ProjectionCamera.cs
- CompModSwitches.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- LambdaCompiler.Lambda.cs
- SkewTransform.cs
- XmlDataSourceNodeDescriptor.cs
- Reference.cs