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
- UriTemplateDispatchFormatter.cs
- webbrowsersite.cs
- OdbcUtils.cs
- RelationshipEndCollection.cs
- FileDialog_Vista.cs
- ConsoleCancelEventArgs.cs
- FreezableDefaultValueFactory.cs
- BrowsableAttribute.cs
- SqlMethodAttribute.cs
- AppDomainResourcePerfCounters.cs
- ContextStaticAttribute.cs
- NodeLabelEditEvent.cs
- MissingManifestResourceException.cs
- TypeSystem.cs
- ShowExpandedMultiValueConverter.cs
- StyleSheetDesigner.cs
- SerializationSectionGroup.cs
- ViewManagerAttribute.cs
- ElementHostPropertyMap.cs
- Int32Storage.cs
- ToolStripSystemRenderer.cs
- ReliableRequestSessionChannel.cs
- DLinqColumnProvider.cs
- TableLayoutSettings.cs
- CapabilitiesRule.cs
- TopClause.cs
- DataSourceGeneratorException.cs
- RelationshipConverter.cs
- Tracer.cs
- EditorZone.cs
- MsmqIntegrationProcessProtocolHandler.cs
- ObjectListField.cs
- BitStack.cs
- FixUpCollection.cs
- TypePresenter.xaml.cs
- SEHException.cs
- AssociationTypeEmitter.cs
- InfiniteTimeSpanConverter.cs
- InteropAutomationProvider.cs
- StrokeNodeEnumerator.cs
- BitmapEffectInput.cs
- XmlCharacterData.cs
- EntityCommandCompilationException.cs
- DetectRunnableInstancesTask.cs
- DesignTableCollection.cs
- ICollection.cs
- Int32Converter.cs
- CoTaskMemSafeHandle.cs
- FreezableCollection.cs
- TransactionManager.cs
- parserscommon.cs
- DesignerAdRotatorAdapter.cs
- InstanceKeyCompleteException.cs
- MulticastIPAddressInformationCollection.cs
- ConfigurationElementProperty.cs
- HealthMonitoringSection.cs
- JsonCollectionDataContract.cs
- QuotedStringWriteStateInfo.cs
- TextRunCache.cs
- oledbconnectionstring.cs
- SimplePropertyEntry.cs
- FileSystemEventArgs.cs
- ConfigurationManagerInternalFactory.cs
- EventData.cs
- EntityDataSourceValidationException.cs
- SID.cs
- ReadOnlyDataSourceView.cs
- OdbcException.cs
- Variant.cs
- XmlSubtreeReader.cs
- DockPanel.cs
- ClockController.cs
- WebPartTransformerAttribute.cs
- DataGridViewTextBoxCell.cs
- TextEndOfSegment.cs
- Point3DCollectionValueSerializer.cs
- TextEditorLists.cs
- ServicePointManagerElement.cs
- RtfFormatStack.cs
- TextEndOfSegment.cs
- SystemDiagnosticsSection.cs
- basenumberconverter.cs
- DataGridViewElement.cs
- XamlPathDataSerializer.cs
- DataGridViewImageCell.cs
- LeaseManager.cs
- CodeRemoveEventStatement.cs
- Label.cs
- TypeDescriptor.cs
- XomlDesignerLoader.cs
- ComPlusServiceLoader.cs
- SchemaImporterExtensionsSection.cs
- SocketException.cs
- TemplateBindingExpressionConverter.cs
- AdornerLayer.cs
- BypassElement.cs
- DesignerHost.cs
- MeshGeometry3D.cs
- Constants.cs
- ResourceDefaultValueAttribute.cs