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
- WebServiceData.cs
- Int64.cs
- ResourcePool.cs
- SimpleBitVector32.cs
- SqlGatherConsumedAliases.cs
- StaticTextPointer.cs
- Filter.cs
- CompiledQuery.cs
- AbstractSvcMapFileLoader.cs
- UnknownBitmapEncoder.cs
- MemberProjectedSlot.cs
- BasicSecurityProfileVersion.cs
- SqlDataSourceView.cs
- WebRequestModuleElement.cs
- UIElement3D.cs
- AttributeXamlType.cs
- EventData.cs
- BasePattern.cs
- DynamicRendererThreadManager.cs
- SafeNativeMethods.cs
- XamlTemplateSerializer.cs
- MenuBase.cs
- ObjectToIdCache.cs
- SerialReceived.cs
- PropertyReferenceSerializer.cs
- _OverlappedAsyncResult.cs
- TransformPatternIdentifiers.cs
- AsynchronousChannelMergeEnumerator.cs
- StringToken.cs
- PropVariant.cs
- CodeLinePragma.cs
- SrgsDocumentParser.cs
- SplineKeyFrames.cs
- FlowLayoutPanelDesigner.cs
- CodeTypeParameter.cs
- _SingleItemRequestCache.cs
- DataFormat.cs
- UndoUnit.cs
- Timer.cs
- PrePostDescendentsWalker.cs
- RegexGroupCollection.cs
- IgnoreDataMemberAttribute.cs
- XmlMapping.cs
- ColorConvertedBitmap.cs
- EventListener.cs
- ComplexType.cs
- Vector3DIndependentAnimationStorage.cs
- ErrorFormatter.cs
- FontEmbeddingManager.cs
- SessionIDManager.cs
- ErrorTolerantObjectWriter.cs
- ModuleBuilder.cs
- PrtTicket_Editor.cs
- ReachObjectContext.cs
- WebPartCatalogCloseVerb.cs
- DesignerTransactionCloseEvent.cs
- WhileDesigner.cs
- IntSecurity.cs
- SmtpLoginAuthenticationModule.cs
- EntityCommandDefinition.cs
- ConfigurationLoaderException.cs
- RowsCopiedEventArgs.cs
- SQLBytesStorage.cs
- WinOEToolBoxItem.cs
- GridViewActionList.cs
- StrokeNodeOperations.cs
- AtomEntry.cs
- Calendar.cs
- _CommandStream.cs
- Empty.cs
- MessageSmuggler.cs
- EventProperty.cs
- IndexExpression.cs
- MobileResource.cs
- EventLogWatcher.cs
- TextLineResult.cs
- DomainLiteralReader.cs
- AttributeEmitter.cs
- StaticDataManager.cs
- ObjectSelectorEditor.cs
- CodeLabeledStatement.cs
- ComponentEditorForm.cs
- BitmapEffectrendercontext.cs
- BitmapMetadata.cs
- TreeNodeBinding.cs
- CookieParameter.cs
- MetaDataInfo.cs
- BindingNavigator.cs
- PerformanceCounterManager.cs
- QuaternionAnimationUsingKeyFrames.cs
- DocumentGrid.cs
- ToolStripDropDownItemDesigner.cs
- XpsS0ValidatingLoader.cs
- NewArray.cs
- ListSourceHelper.cs
- Canvas.cs
- XmlEntity.cs
- IntSecurity.cs
- DataGridViewRowsRemovedEventArgs.cs
- HtmlTableRowCollection.cs