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
- Size3D.cs
- BackgroundWorker.cs
- TemplatedMailWebEventProvider.cs
- InputLangChangeEvent.cs
- WebPartVerbCollection.cs
- DocumentViewerBase.cs
- TemplateAction.cs
- QueryExpr.cs
- ConfigurationManagerInternal.cs
- Roles.cs
- HandleCollector.cs
- TranslateTransform3D.cs
- CodeTypeReferenceExpression.cs
- ManagementNamedValueCollection.cs
- PaintValueEventArgs.cs
- DbDataReader.cs
- Binding.cs
- ApplicationFileParser.cs
- FileInfo.cs
- HTTP_SERVICE_CONFIG_URLACL_KEY.cs
- GridEntry.cs
- Stylesheet.cs
- FrameworkReadOnlyPropertyMetadata.cs
- NoneExcludedImageIndexConverter.cs
- FacetValueContainer.cs
- MouseGestureConverter.cs
- ColorAnimationUsingKeyFrames.cs
- ApplySecurityAndSendAsyncResult.cs
- WebPartDesigner.cs
- GroupDescription.cs
- EventItfInfo.cs
- SQLDateTime.cs
- ToolBar.cs
- CustomValidator.cs
- DBCommand.cs
- InputMethodStateTypeInfo.cs
- NameObjectCollectionBase.cs
- TouchEventArgs.cs
- PositiveTimeSpanValidator.cs
- WinFormsComponentEditor.cs
- XdrBuilder.cs
- ApplicationInfo.cs
- ConnectionConsumerAttribute.cs
- Model3DGroup.cs
- PasswordRecoveryAutoFormat.cs
- NewExpression.cs
- handlecollector.cs
- RsaSecurityTokenAuthenticator.cs
- SelectionItemPatternIdentifiers.cs
- InitiatorSessionSymmetricTransportSecurityProtocol.cs
- ImageKeyConverter.cs
- SQLMoney.cs
- SourceCollection.cs
- TaskScheduler.cs
- QueryPageSettingsEventArgs.cs
- SapiInterop.cs
- StrokeDescriptor.cs
- TimestampInformation.cs
- DataGridViewCellParsingEventArgs.cs
- QueuePropertyVariants.cs
- ConfigXmlCDataSection.cs
- DbParameterCollectionHelper.cs
- COM2PictureConverter.cs
- RadioButtonBaseAdapter.cs
- DeclaredTypeValidatorAttribute.cs
- EntityObject.cs
- CaseStatement.cs
- RouteParser.cs
- Drawing.cs
- PasswordRecoveryAutoFormat.cs
- DescriptionAttribute.cs
- UInt32Converter.cs
- BigInt.cs
- AnnotationHighlightLayer.cs
- ContextStaticAttribute.cs
- HMACRIPEMD160.cs
- CapabilitiesPattern.cs
- ReachDocumentSequenceSerializerAsync.cs
- PropertyManager.cs
- StretchValidation.cs
- ListItemConverter.cs
- ToolboxComponentsCreatedEventArgs.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- ObfuscationAttribute.cs
- glyphs.cs
- ContainerControl.cs
- AlternationConverter.cs
- CloudCollection.cs
- Decoder.cs
- SystemWebSectionGroup.cs
- FormViewModeEventArgs.cs
- XmlEventCache.cs
- ToolBarTray.cs
- ExpandSegment.cs
- DataSpaceManager.cs
- WS2007HttpBindingElement.cs
- XPathNode.cs
- PermissionSetTriple.cs
- OdbcConnectionFactory.cs
- TypedTableHandler.cs