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
- BoundPropertyEntry.cs
- PageContent.cs
- InputProcessorProfilesLoader.cs
- StringOutput.cs
- WindowsStreamSecurityBindingElement.cs
- SoapAttributes.cs
- FunctionUpdateCommand.cs
- LocalFileSettingsProvider.cs
- DataSetUtil.cs
- SeekStoryboard.cs
- ActivationArguments.cs
- SqlBuilder.cs
- ToolStripItemImageRenderEventArgs.cs
- RowCache.cs
- WindowsServiceCredential.cs
- UnmanagedMemoryStream.cs
- HttpPostProtocolReflector.cs
- JsonUriDataContract.cs
- DataGridCommandEventArgs.cs
- TableLayoutSettings.cs
- OleDbStruct.cs
- IntSecurity.cs
- HostingEnvironment.cs
- ModelTypeConverter.cs
- BitmapCodecInfoInternal.cs
- MultiSelectRootGridEntry.cs
- ImageAnimator.cs
- DataGridViewRowConverter.cs
- WindowsIPAddress.cs
- ProfilePropertySettings.cs
- XmlSchemaSimpleContentRestriction.cs
- WindowsListViewScroll.cs
- ReflectionUtil.cs
- CompilerParameters.cs
- RegexTree.cs
- ClusterRegistryConfigurationProvider.cs
- SortedList.cs
- EntityModelBuildProvider.cs
- DBDataPermission.cs
- HasCopySemanticsAttribute.cs
- AutoSizeToolBoxItem.cs
- DBConnection.cs
- HtmlTitle.cs
- TrackingExtract.cs
- safePerfProviderHandle.cs
- BaseTemplateCodeDomTreeGenerator.cs
- DataControlLinkButton.cs
- TileBrush.cs
- wgx_commands.cs
- WebPartDisplayModeCancelEventArgs.cs
- CellTreeNodeVisitors.cs
- TypefaceMetricsCache.cs
- DateTime.cs
- MdiWindowListStrip.cs
- EventToken.cs
- HotSpot.cs
- DetailsViewRowCollection.cs
- TextPatternIdentifiers.cs
- CodeParameterDeclarationExpressionCollection.cs
- ByeOperation11AsyncResult.cs
- SecUtil.cs
- QueueProcessor.cs
- SafeHGlobalHandleCritical.cs
- DataGridViewColumnTypePicker.cs
- ApplicationTrust.cs
- ProjectedWrapper.cs
- RowBinding.cs
- QueryCacheManager.cs
- ValidationPropertyAttribute.cs
- GridErrorDlg.cs
- DataRecordObjectView.cs
- BorderSidesEditor.cs
- QilStrConcatenator.cs
- HandlerFactoryWrapper.cs
- ConversionValidationRule.cs
- RsaSecurityTokenAuthenticator.cs
- FactoryMaker.cs
- MemberPath.cs
- OdbcParameterCollection.cs
- GridViewDeletedEventArgs.cs
- ManipulationDelta.cs
- ProfileGroupSettings.cs
- PageHandlerFactory.cs
- ListChangedEventArgs.cs
- CodeAttributeDeclaration.cs
- ObjectStorage.cs
- SharedPersonalizationStateInfo.cs
- MinMaxParagraphWidth.cs
- DataViewManager.cs
- MultiBinding.cs
- SQLBytesStorage.cs
- MediaElement.cs
- GetMemberBinder.cs
- PropertySegmentSerializationProvider.cs
- SymLanguageType.cs
- TraceSection.cs
- DashStyles.cs
- HttpSessionStateBase.cs
- Stylus.cs
- XmlProcessingInstruction.cs