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
- OletxResourceManager.cs
- Message.cs
- ScrollableControlDesigner.cs
- safex509handles.cs
- EntityDataSourceMemberPath.cs
- OLEDB_Enum.cs
- CommunicationObjectManager.cs
- HtmlInputCheckBox.cs
- GifBitmapEncoder.cs
- BooleanConverter.cs
- ButtonField.cs
- SqlDataSourceCommandParser.cs
- MediaCommands.cs
- DataGridViewTopRowAccessibleObject.cs
- StateFinalizationActivity.cs
- ElementNotEnabledException.cs
- ConnectionManagementElementCollection.cs
- InkCanvas.cs
- URLMembershipCondition.cs
- ApplicationManager.cs
- EntityDataSourceChangedEventArgs.cs
- ListViewGroupConverter.cs
- SymLanguageVendor.cs
- RequestDescription.cs
- PropertyEmitterBase.cs
- DataControlImageButton.cs
- XPathBuilder.cs
- ImageFormatConverter.cs
- _BufferOffsetSize.cs
- StylusCaptureWithinProperty.cs
- TypeEnumerableViewSchema.cs
- ProfileElement.cs
- ISAPIWorkerRequest.cs
- DataGridViewColumnConverter.cs
- PackageRelationshipCollection.cs
- ConfigurationException.cs
- ProgressChangedEventArgs.cs
- SafeArrayRankMismatchException.cs
- CodeDelegateCreateExpression.cs
- DataGridViewCellStyleBuilderDialog.cs
- MorphHelper.cs
- FlowLayout.cs
- MouseOverProperty.cs
- HtmlInputCheckBox.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- UnlockCardRequest.cs
- SourceItem.cs
- TextElementEnumerator.cs
- ToolboxItemWrapper.cs
- SerializationTrace.cs
- TreeView.cs
- GridItemCollection.cs
- SizeChangedInfo.cs
- EntityAdapter.cs
- QuinticEase.cs
- InputScopeManager.cs
- listitem.cs
- EntityContainer.cs
- CheckBoxBaseAdapter.cs
- QuaternionValueSerializer.cs
- TrustManagerPromptUI.cs
- XmlSchemaNotation.cs
- UrlAuthorizationModule.cs
- _UncName.cs
- GeneralTransform.cs
- ReflectionTypeLoadException.cs
- PropertyRecord.cs
- ProxyFragment.cs
- CodeTypeParameterCollection.cs
- CodeObjectCreateExpression.cs
- Matrix3D.cs
- StyleXamlParser.cs
- AppModelKnownContentFactory.cs
- sitestring.cs
- NetworkAddressChange.cs
- DocumentApplicationJournalEntry.cs
- ProfilePropertyMetadata.cs
- TemplateBindingExtensionConverter.cs
- PolicyUtility.cs
- FunctionImportElement.cs
- NameTable.cs
- InstancePersistenceException.cs
- Vector3D.cs
- DbProviderConfigurationHandler.cs
- Matrix.cs
- TableFieldsEditor.cs
- XmlSchemaValidationException.cs
- RolePrincipal.cs
- Attributes.cs
- FaultContractAttribute.cs
- AutomationEvent.cs
- OdbcReferenceCollection.cs
- ColumnReorderedEventArgs.cs
- SafeLibraryHandle.cs
- CapabilitiesPattern.cs
- DoubleAnimationClockResource.cs
- FamilyMap.cs
- ControlPaint.cs
- HttpGetServerProtocol.cs
- BackoffTimeoutHelper.cs