Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------ // 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
- ExecutorLocksHeldException.cs
- ProtocolsConfigurationHandler.cs
- StructuralCache.cs
- NextPreviousPagerField.cs
- ConnectionConsumerAttribute.cs
- LinqDataSourceSelectEventArgs.cs
- MatrixAnimationBase.cs
- SerializationStore.cs
- SystemGatewayIPAddressInformation.cs
- WinFormsUtils.cs
- DifferencingCollection.cs
- UriExt.cs
- SelectionListDesigner.cs
- CultureNotFoundException.cs
- GlobalizationAssembly.cs
- EqualityArray.cs
- BasicExpandProvider.cs
- BatchStream.cs
- RelationshipDetailsRow.cs
- FormattedText.cs
- InternalConfigEventArgs.cs
- BrowserTree.cs
- PaperSource.cs
- CapabilitiesSection.cs
- TimeSpanConverter.cs
- LinkConverter.cs
- ViewBox.cs
- StreamAsIStream.cs
- Int16AnimationUsingKeyFrames.cs
- SqlErrorCollection.cs
- DataServiceResponse.cs
- GatewayDefinition.cs
- ConfigsHelper.cs
- PagesSection.cs
- TreeNode.cs
- TextViewSelectionProcessor.cs
- Point3DCollectionConverter.cs
- UnknownWrapper.cs
- DefaultValueAttribute.cs
- Line.cs
- Tokenizer.cs
- UserControlDesigner.cs
- StatusBarItem.cs
- ReadOnlyCollection.cs
- EditorAttributeInfo.cs
- HMACSHA384.cs
- FileFormatException.cs
- ElementProxy.cs
- BaseProcessor.cs
- Decoder.cs
- CollectionsUtil.cs
- GroupByExpressionRewriter.cs
- TemplateKey.cs
- PerformanceCounterPermissionAttribute.cs
- WpfPayload.cs
- PictureBox.cs
- WebPartEventArgs.cs
- Inline.cs
- FixedSOMTableCell.cs
- DescendantBaseQuery.cs
- NonSerializedAttribute.cs
- TableParaClient.cs
- ResourcePermissionBase.cs
- FormClosedEvent.cs
- ActivityDesignerHelper.cs
- XmlTextWriter.cs
- QilScopedVisitor.cs
- RtfControls.cs
- ContentFileHelper.cs
- ImageAttributes.cs
- XpsFixedPageReaderWriter.cs
- MimeMultiPart.cs
- ViewCellSlot.cs
- RegexEditorDialog.cs
- _FtpDataStream.cs
- GifBitmapEncoder.cs
- SiteMapNodeItem.cs
- ClientProxyGenerator.cs
- XmlObjectSerializerWriteContext.cs
- CreatingCookieEventArgs.cs
- TableCellsCollectionEditor.cs
- TimerTable.cs
- XmlSchemaAttributeGroup.cs
- StringOutput.cs
- FileLogRecordEnumerator.cs
- Propagator.Evaluator.cs
- InternalConfigHost.cs
- Size.cs
- ThrowHelper.cs
- ProvidersHelper.cs
- ServicePerformanceCounters.cs
- FormsAuthenticationEventArgs.cs
- StylusPointProperty.cs
- OleDbReferenceCollection.cs
- InvokeProviderWrapper.cs
- ContainerFilterService.cs
- XmlConverter.cs
- ActiveXContainer.cs
- DataIdProcessor.cs
- Adorner.cs