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
- Axis.cs
- HtmlTextArea.cs
- Command.cs
- SecurityException.cs
- Deserializer.cs
- WinEventQueueItem.cs
- NameTable.cs
- TerminatorSinks.cs
- ResXFileRef.cs
- HGlobalSafeHandle.cs
- OptimalBreakSession.cs
- OdbcTransaction.cs
- ConsoleTraceListener.cs
- DataGridViewColumnTypePicker.cs
- Rule.cs
- CodeTypeParameter.cs
- AutoGeneratedFieldProperties.cs
- GroupBoxAutomationPeer.cs
- _ConnectStream.cs
- EventSource.cs
- Normalizer.cs
- AtlasWeb.Designer.cs
- ThreadAbortException.cs
- UpDownEvent.cs
- ConnectionPointGlyph.cs
- MatrixCamera.cs
- QueryOptionExpression.cs
- CatalogPartChrome.cs
- Item.cs
- HandlerWithFactory.cs
- SystemBrushes.cs
- DBCSCodePageEncoding.cs
- SmtpReplyReader.cs
- CustomExpressionEventArgs.cs
- InputElement.cs
- ImmutableCollection.cs
- LiteralControl.cs
- TcpSocketManager.cs
- MetadataArtifactLoader.cs
- NullableFloatSumAggregationOperator.cs
- ObjectToModelValueConverter.cs
- Triplet.cs
- DiagnosticsConfiguration.cs
- SyndicationLink.cs
- SkinBuilder.cs
- StrokeNodeOperations.cs
- Cast.cs
- ClientConfigurationHost.cs
- UIElementPropertyUndoUnit.cs
- NameNode.cs
- DataSourceSelectArguments.cs
- SqlDataSource.cs
- SqlTypeSystemProvider.cs
- BaseUriHelper.cs
- MembershipValidatePasswordEventArgs.cs
- DrawingContextWalker.cs
- InternalCompensate.cs
- TextStore.cs
- ErrorStyle.cs
- ProjectionPath.cs
- FacetValues.cs
- ToolStripPanelCell.cs
- DoWorkEventArgs.cs
- XPathNodeIterator.cs
- SSmlParser.cs
- ListBoxDesigner.cs
- HttpEncoderUtility.cs
- WindowsFormsHostAutomationPeer.cs
- XmlValueConverter.cs
- NameValuePermission.cs
- HttpDictionary.cs
- BamlLocalizer.cs
- RoleGroupCollection.cs
- BaseTreeIterator.cs
- ItemCollection.cs
- HttpModulesSection.cs
- TextOutput.cs
- SiteMembershipCondition.cs
- templategroup.cs
- BaseCodePageEncoding.cs
- DataKeyPropertyAttribute.cs
- ResolveNameEventArgs.cs
- PassportAuthenticationEventArgs.cs
- ProfileSettingsCollection.cs
- ListControl.cs
- MimeTypeMapper.cs
- HttpWebRequestElement.cs
- OverflowException.cs
- WindowClosedEventArgs.cs
- OrthographicCamera.cs
- CloseSequence.cs
- SHA1Managed.cs
- AppDomainFactory.cs
- FormViewModeEventArgs.cs
- SqlUtils.cs
- Menu.cs
- Choices.cs
- SerialStream.cs
- RemotingClientProxy.cs
- WSDualHttpSecurity.cs