Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / DataProtectionSecurityStateEncoder.cs / 1 / DataProtectionSecurityStateEncoder.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Security { using System.Text; using System.Security.Cryptography; public class DataProtectionSecurityStateEncoder : SecurityStateEncoder { byte[] entropy; bool useCurrentUserProtectionScope; public DataProtectionSecurityStateEncoder() : this(true) { // empty } public DataProtectionSecurityStateEncoder(bool useCurrentUserProtectionScope) : this(useCurrentUserProtectionScope, null) { } public DataProtectionSecurityStateEncoder(bool useCurrentUserProtectionScope, byte[] entropy) { this.useCurrentUserProtectionScope = useCurrentUserProtectionScope; if (entropy == null) { this.entropy = null; } else { this.entropy = DiagnosticUtility.Utility.AllocateByteArray(entropy.Length); Buffer.BlockCopy(entropy, 0, this.entropy, 0, entropy.Length); } } public bool UseCurrentUserProtectionScope { get { return this.useCurrentUserProtectionScope; } } public byte[] GetEntropy() { byte[] result = null; if (this.entropy != null) { result = DiagnosticUtility.Utility.AllocateByteArray(this.entropy.Length); Buffer.BlockCopy(this.entropy, 0, result, 0, this.entropy.Length); } return result; } public override string ToString() { StringBuilder result = new StringBuilder(); result.Append(this.GetType().ToString()); result.AppendFormat("{0} UseCurrentUserProtectionScope={1}", Environment.NewLine, this.useCurrentUserProtectionScope); result.AppendFormat("{0} Entropy Length={1}", Environment.NewLine, (this.entropy == null) ? 0 : this.entropy.Length); return result.ToString(); } protected internal override byte[] DecodeSecurityState(byte[] data) { return ProtectedData.Unprotect(data, this.entropy, (this.useCurrentUserProtectionScope) ? DataProtectionScope.CurrentUser : DataProtectionScope.LocalMachine); } protected internal override byte[] EncodeSecurityState(byte[] data) { return ProtectedData.Protect(data, this.entropy, (this.useCurrentUserProtectionScope) ? DataProtectionScope.CurrentUser : DataProtectionScope.LocalMachine); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PageContentAsyncResult.cs
- TextServicesCompartmentContext.cs
- AppDomainManager.cs
- XamlSerializerUtil.cs
- FileLoadException.cs
- HelpEvent.cs
- GCHandleCookieTable.cs
- SelectorItemAutomationPeer.cs
- ConditionalAttribute.cs
- Int32RectConverter.cs
- ProcessManager.cs
- MsmqHostedTransportConfiguration.cs
- XmlAutoDetectWriter.cs
- Propagator.cs
- StylusPointCollection.cs
- CompilerWrapper.cs
- ValidatorCollection.cs
- RealizationDrawingContextWalker.cs
- ListView.cs
- Accessors.cs
- DoubleCollectionValueSerializer.cs
- IntegerFacetDescriptionElement.cs
- ObjectStateManager.cs
- CommandEventArgs.cs
- RenderingEventArgs.cs
- SqlDataReader.cs
- SQLMoney.cs
- NGCSerializerAsync.cs
- LexicalChunk.cs
- EntityCommandCompilationException.cs
- InstanceBehavior.cs
- CommandBindingCollection.cs
- CollectionChangeEventArgs.cs
- TextTreeObjectNode.cs
- ObjectQuery.cs
- XamlWriter.cs
- ValidationErrorCollection.cs
- LoginName.cs
- ComboBoxRenderer.cs
- XmlDesignerDataSourceView.cs
- TextEditorLists.cs
- WebPartZoneBase.cs
- ValidatingReaderNodeData.cs
- SiteMapDataSource.cs
- _ContextAwareResult.cs
- DataKeyCollection.cs
- WSSecurityJan2004.cs
- PathNode.cs
- addressfiltermode.cs
- EncryptedPackage.cs
- X500Name.cs
- SchemaSetCompiler.cs
- NetPeerTcpBindingElement.cs
- BulletChrome.cs
- ColorKeyFrameCollection.cs
- Logging.cs
- MergeFailedEvent.cs
- BinaryParser.cs
- ReadOnlyMetadataCollection.cs
- BrowserCapabilitiesFactoryBase.cs
- MatrixCamera.cs
- SortQueryOperator.cs
- ThreadAttributes.cs
- CheckBox.cs
- ExternalFile.cs
- DecimalKeyFrameCollection.cs
- NegatedConstant.cs
- WebPermission.cs
- FlowDocumentPageViewerAutomationPeer.cs
- cookiecontainer.cs
- COMException.cs
- DataColumnMapping.cs
- BlurBitmapEffect.cs
- HttpCapabilitiesEvaluator.cs
- WebEventTraceProvider.cs
- PackWebRequestFactory.cs
- XmlQueryTypeFactory.cs
- SubtreeProcessor.cs
- PermissionSetTriple.cs
- CommonXSendMessage.cs
- SiteMapDataSource.cs
- SequenceFullException.cs
- ScrollViewerAutomationPeer.cs
- KeyInstance.cs
- AnalyzedTree.cs
- DbConnectionPoolCounters.cs
- RelatedEnd.cs
- FileInfo.cs
- KeyConverter.cs
- ToolboxControl.cs
- DataSourceXmlSubItemAttribute.cs
- AuthenticationModulesSection.cs
- _NativeSSPI.cs
- CTreeGenerator.cs
- ThreadStartException.cs
- AutomationTextAttribute.cs
- ListBindableAttribute.cs
- SqlSelectStatement.cs
- XmlSchemaChoice.cs
- ComplexBindingPropertiesAttribute.cs