Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / SignatureResourcePool.cs / 1305376 / SignatureResourcePool.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel { using System.IO; using System.Security.Cryptography; using System.IdentityModel.Tokens; using System.Xml; using System.Text; // for sequential use by one thread sealed class SignatureResourcePool { const int BufferSize = 64; CanonicalizationDriver canonicalizationDriver; HashStream hashStream; HashAlgorithm hashAlgorithm; #if NO XmlC14NWriter integratedWriter; #endif XmlDictionaryWriter utf8Writer; byte[] encodingBuffer; char[] base64Buffer; public char[] TakeBase64Buffer() { if (this.base64Buffer == null) { this.base64Buffer = new char[BufferSize]; } return this.base64Buffer; } public CanonicalizationDriver TakeCanonicalizationDriver() { if (this.canonicalizationDriver == null) { this.canonicalizationDriver = new CanonicalizationDriver(); } else { this.canonicalizationDriver.Reset(); } return this.canonicalizationDriver; } public byte[] TakeEncodingBuffer() { if (this.encodingBuffer == null) { this.encodingBuffer = new byte[BufferSize]; } return this.encodingBuffer; } public HashAlgorithm TakeHashAlgorithm(string algorithm) { if ( this.hashAlgorithm == null ) { if ( String.IsNullOrEmpty( algorithm ) ) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument( algorithm, SR.GetString( SR.EmptyOrNullArgumentString, "algorithm" ) ); } this.hashAlgorithm = CryptoHelper.CreateHashAlgorithm( algorithm ); } else { this.hashAlgorithm.Initialize(); } return this.hashAlgorithm; } public HashStream TakeHashStream(HashAlgorithm hash) { if (this.hashStream == null) { this.hashStream = new HashStream(hash); } else { this.hashStream.Reset(hash); } return this.hashStream; } public HashStream TakeHashStream(string algorithm) { return TakeHashStream(TakeHashAlgorithm(algorithm)); } #if NO public XmlC14NWriter TakeIntegratedWriter(Stream stream) { return TakeIntegratedWriter(stream, false, null); } public XmlC14NWriter TakeIntegratedWriter(Stream stream, bool includeComments, string[] inclusivePrefixes) { if (this.integratedWriter == null) { this.integratedWriter = new XmlC14NWriter(stream, includeComments, inclusivePrefixes); } else { this.integratedWriter.SetOutput(stream, includeComments, inclusivePrefixes); } return this.integratedWriter; } #endif public XmlDictionaryWriter TakeUtf8Writer() { if (this.utf8Writer == null) { this.utf8Writer = XmlDictionaryWriter.CreateTextWriter(Stream.Null, Encoding.UTF8, false); } else { ((IXmlTextWriterInitializer) this.utf8Writer).SetOutput(Stream.Null, Encoding.UTF8, false); } return this.utf8Writer; } } } // 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
- SqlDataAdapter.cs
- DisplayInformation.cs
- VerticalAlignConverter.cs
- HtmlTernaryTree.cs
- PublishLicense.cs
- HttpRuntime.cs
- MimeFormReflector.cs
- PointF.cs
- UnlockInstanceCommand.cs
- sqlstateclientmanager.cs
- ServiceInstanceProvider.cs
- TextDecorationUnitValidation.cs
- FilePrompt.cs
- EventSourceCreationData.cs
- ControlPropertyNameConverter.cs
- RoleGroup.cs
- SharedStatics.cs
- ResourceDescriptionAttribute.cs
- Label.cs
- FunctionNode.cs
- FixedPosition.cs
- AnonymousIdentificationSection.cs
- HelpInfo.cs
- indexingfiltermarshaler.cs
- InstanceNotFoundException.cs
- TableCell.cs
- AutoGeneratedFieldProperties.cs
- Imaging.cs
- HTMLTextWriter.cs
- x509store.cs
- HitTestParameters.cs
- ToolStripRenderEventArgs.cs
- CmsUtils.cs
- recordstatescratchpad.cs
- Shared.cs
- ApplicationHost.cs
- ClientTarget.cs
- BorderSidesEditor.cs
- RenderOptions.cs
- CodeIdentifiers.cs
- SingleAnimationUsingKeyFrames.cs
- RewritingSimplifier.cs
- BamlResourceContent.cs
- ConsumerConnectionPoint.cs
- ClusterRegistryConfigurationProvider.cs
- SoapCodeExporter.cs
- XamlWriter.cs
- TextDecorationCollection.cs
- _DomainName.cs
- QilStrConcatenator.cs
- MethodRental.cs
- LayoutManager.cs
- Point3DCollection.cs
- TempFiles.cs
- AmbientValueAttribute.cs
- ProgressBar.cs
- FileUtil.cs
- RootProfilePropertySettingsCollection.cs
- DispatcherSynchronizationContext.cs
- DataGridCaption.cs
- ObjectDataSourceSelectingEventArgs.cs
- OracleConnectionStringBuilder.cs
- QueryableDataSourceHelper.cs
- TextServicesProperty.cs
- EllipseGeometry.cs
- RulePatternOps.cs
- RoleManagerEventArgs.cs
- ScrollData.cs
- ExpressionWriter.cs
- Trace.cs
- DateTimeConstantAttribute.cs
- CopyAction.cs
- _Events.cs
- StateFinalizationActivity.cs
- EventQueueState.cs
- DocumentViewerBaseAutomationPeer.cs
- DocumentSequenceHighlightLayer.cs
- thaishape.cs
- EDesignUtil.cs
- XmlObjectSerializerWriteContext.cs
- ThreadInterruptedException.cs
- HostingEnvironmentSection.cs
- Activator.cs
- _ListenerAsyncResult.cs
- NullRuntimeConfig.cs
- XmlDataSourceNodeDescriptor.cs
- ServiceProviders.cs
- RelationalExpressions.cs
- ReplacementText.cs
- GradientBrush.cs
- HttpPostedFile.cs
- ByteStream.cs
- XPathPatternParser.cs
- safex509handles.cs
- Compiler.cs
- CodeArrayIndexerExpression.cs
- ListViewItem.cs
- Transform.cs
- ScrollData.cs
- PerfCounters.cs