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
- WebReferenceCollection.cs
- DataGridViewCellStyleConverter.cs
- DecoderReplacementFallback.cs
- LostFocusEventManager.cs
- LineBreak.cs
- Transform3DCollection.cs
- WorkflowIdleElement.cs
- DragEventArgs.cs
- ItemPager.cs
- WmlValidatorAdapter.cs
- UnknownBitmapEncoder.cs
- RadialGradientBrush.cs
- FixedSOMTable.cs
- ObjectViewListener.cs
- ToolStripHighContrastRenderer.cs
- UInt64.cs
- GridViewItemAutomationPeer.cs
- DoubleAnimationBase.cs
- InstanceView.cs
- manifestimages.cs
- EnumValidator.cs
- IsolatedStorageFilePermission.cs
- EntityDataSourceValidationException.cs
- SessionSymmetricTransportSecurityProtocolFactory.cs
- ButtonFieldBase.cs
- DynamicControlParameter.cs
- X509SubjectKeyIdentifierClause.cs
- ZoneButton.cs
- BooleanConverter.cs
- Encoding.cs
- xmlNames.cs
- DataTemplate.cs
- UIElement.cs
- AmbientLight.cs
- MenuCommand.cs
- OleDbTransaction.cs
- ErrorTolerantObjectWriter.cs
- ProtectedUri.cs
- TextDecoration.cs
- DbMetaDataCollectionNames.cs
- sqlpipe.cs
- HtmlForm.cs
- TextParentUndoUnit.cs
- QualifiedCellIdBoolean.cs
- XmlAnyAttributeAttribute.cs
- ChannelSinkStacks.cs
- SoapSchemaImporter.cs
- PauseStoryboard.cs
- XamlStream.cs
- storepermissionattribute.cs
- XmlSerializationWriter.cs
- XamlReader.cs
- TiffBitmapDecoder.cs
- IisTraceListener.cs
- backend.cs
- BitmapCodecInfo.cs
- OdbcInfoMessageEvent.cs
- ComponentResourceKeyConverter.cs
- WindowsStartMenu.cs
- CaseInsensitiveHashCodeProvider.cs
- VisualBrush.cs
- RecognizeCompletedEventArgs.cs
- ListViewTableRow.cs
- EllipticalNodeOperations.cs
- MetadataItemSerializer.cs
- EffectiveValueEntry.cs
- ElementNotEnabledException.cs
- BindingElement.cs
- safex509handles.cs
- TextModifierScope.cs
- DerivedKeySecurityToken.cs
- CallContext.cs
- Thumb.cs
- DomainConstraint.cs
- UnionQueryOperator.cs
- BackgroundWorker.cs
- HierarchicalDataSourceControl.cs
- CodeSubDirectory.cs
- InstanceKeyNotReadyException.cs
- DtcInterfaces.cs
- Operators.cs
- RelationshipManager.cs
- SqlCommand.cs
- LineServicesCallbacks.cs
- ReferenceSchema.cs
- TrustSection.cs
- PeerOutputChannel.cs
- PeerTransportListenAddressValidator.cs
- QueryAccessibilityHelpEvent.cs
- DesignerSerializationOptionsAttribute.cs
- SudsParser.cs
- RSAPKCS1KeyExchangeFormatter.cs
- XamlWriter.cs
- BCLDebug.cs
- Utility.cs
- EventListenerClientSide.cs
- TagPrefixCollection.cs
- NameValueSectionHandler.cs
- FormViewPagerRow.cs
- DateTimeValueSerializerContext.cs