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
- DataGridViewCellConverter.cs
- FilterElement.cs
- DeploymentExceptionMapper.cs
- AssemblyAssociatedContentFileAttribute.cs
- Application.cs
- BoundingRectTracker.cs
- BrowserCapabilitiesFactory35.cs
- SafeBuffer.cs
- SetterBaseCollection.cs
- DataErrorValidationRule.cs
- SafeRegistryKey.cs
- DataGridTablesFactory.cs
- BmpBitmapDecoder.cs
- ListItemConverter.cs
- XmlNavigatorStack.cs
- SortedSet.cs
- SafeSystemMetrics.cs
- HttpFileCollection.cs
- XmlILConstructAnalyzer.cs
- SoapSchemaMember.cs
- XmlSchemas.cs
- TreeViewItem.cs
- FixedTextView.cs
- ItemChangedEventArgs.cs
- StringFormat.cs
- ApplicationActivator.cs
- RoleService.cs
- EventLogPermissionEntry.cs
- MenuItemStyleCollection.cs
- mediaeventargs.cs
- ControlEvent.cs
- TypeConverterMarkupExtension.cs
- CommandID.cs
- Permission.cs
- Focus.cs
- TextElementCollectionHelper.cs
- MatrixTransform.cs
- SettingsProviderCollection.cs
- HttpCookieCollection.cs
- FixedDocument.cs
- WebPartRestoreVerb.cs
- SqlPersonalizationProvider.cs
- ColorConvertedBitmap.cs
- AppDomainGrammarProxy.cs
- CaseExpr.cs
- GacUtil.cs
- ListMarkerSourceInfo.cs
- PageThemeBuildProvider.cs
- HtmlTableRowCollection.cs
- ExpandCollapsePatternIdentifiers.cs
- ChunkedMemoryStream.cs
- PersonalizableAttribute.cs
- BoundColumn.cs
- WmpBitmapEncoder.cs
- PerformanceCounter.cs
- ToolStripDropDown.cs
- DiagnosticStrings.cs
- Function.cs
- BitmapDownload.cs
- DirectoryNotFoundException.cs
- HasCopySemanticsAttribute.cs
- RegexTree.cs
- CalendarItem.cs
- QilXmlReader.cs
- AssemblyBuilderData.cs
- ConsoleEntryPoint.cs
- WebBrowserNavigatedEventHandler.cs
- CompiledELinqQueryState.cs
- GPRECT.cs
- WindowsMenu.cs
- SqlErrorCollection.cs
- Function.cs
- AutomationPropertyInfo.cs
- ReflectionPermission.cs
- Filter.cs
- BuildProvider.cs
- XmlUtil.cs
- GridView.cs
- ToolboxCategoryItems.cs
- ObjectTag.cs
- EventProviderWriter.cs
- XmlSchemaSubstitutionGroup.cs
- TdsParser.cs
- MemberHolder.cs
- LinkedResourceCollection.cs
- WindowsGraphicsWrapper.cs
- IDReferencePropertyAttribute.cs
- DEREncoding.cs
- NativeMethods.cs
- _SecureChannel.cs
- ZipIOBlockManager.cs
- DetailsViewCommandEventArgs.cs
- OLEDB_Enum.cs
- X509ChainPolicy.cs
- handlecollector.cs
- ToolboxItemCollection.cs
- ExpressionParser.cs
- ListChangedEventArgs.cs
- SecurityDocument.cs
- PropertyBuilder.cs