Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / EncryptedKey.cs / 1 / EncryptedKey.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Security { using System.IO; using System.Security.Cryptography; using System.Text; using System.Xml; sealed class EncryptedKey : EncryptedType { internal static readonly XmlDictionaryString CarriedKeyElementName = XD.XmlEncryptionDictionary.CarriedKeyName; internal static readonly XmlDictionaryString ElementName = XD.XmlEncryptionDictionary.EncryptedKey; internal static readonly XmlDictionaryString RecipientAttribute = XD.XmlEncryptionDictionary.Recipient; string carriedKeyName; string recipient; ReferenceList referenceList; byte[] wrappedKey; public string CarriedKeyName { get { return this.carriedKeyName; } set { this.carriedKeyName = value; } } public string Recipient { get { return this.recipient; } set { this.recipient = value; } } public ReferenceList ReferenceList { get { return this.referenceList; } set { this.referenceList = value; } } protected override XmlDictionaryString OpeningElementName { get { return ElementName; } } protected override void ForceEncryption() { // no work to be done here since, unlike bulk encryption, key wrapping is done eagerly } public byte[] GetWrappedKey() { if (this.State == EncryptionState.New) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.BadEncryptionState))); } return this.wrappedKey; } public void SetUpKeyWrap(byte[] wrappedKey) { if (this.State != EncryptionState.New) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.BadEncryptionState))); } if (wrappedKey == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("wrappedKey"); } this.wrappedKey = wrappedKey; this.State = EncryptionState.Encrypted; } protected override void ReadAdditionalAttributes(XmlDictionaryReader reader) { this.recipient = reader.GetAttribute(RecipientAttribute, null); } protected override void ReadAdditionalElements(XmlDictionaryReader reader) { if (reader.IsStartElement(ReferenceList.ElementName, EncryptedType.NamespaceUri)) { this.referenceList = new ReferenceList(); this.referenceList.ReadFrom(reader); } if (reader.IsStartElement(CarriedKeyElementName, EncryptedType.NamespaceUri)) { reader.ReadStartElement(CarriedKeyElementName, EncryptedType.NamespaceUri); this.carriedKeyName = reader.ReadString(); reader.ReadEndElement(); } } protected override void ReadCipherData(XmlDictionaryReader reader) { this.wrappedKey = reader.ReadContentAsBase64(); } protected override void ReadCipherData(XmlDictionaryReader reader, long maxBufferSize) { this.wrappedKey = SecurityUtils.ReadContentAsBase64(reader, maxBufferSize); } protected override void WriteAdditionalAttributes(XmlDictionaryWriter writer) { if (this.recipient != null) { writer.WriteAttributeString(RecipientAttribute, null, this.recipient); } } protected override void WriteAdditionalElements(XmlDictionaryWriter writer) { if (this.carriedKeyName != null) { writer.WriteStartElement(CarriedKeyElementName, EncryptedType.NamespaceUri); writer.WriteString(this.carriedKeyName); writer.WriteEndElement(); // CarriedKeyName } if (this.referenceList != null) { this.referenceList.WriteTo(writer, ServiceModelDictionaryManager.Instance); } } protected override void WriteCipherData(XmlDictionaryWriter writer) { writer.WriteBase64(this.wrappedKey, 0, this.wrappedKey.Length); } } } // 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
- LineGeometry.cs
- EastAsianLunisolarCalendar.cs
- LayoutManager.cs
- SelfIssuedAuthRSACryptoProvider.cs
- SinglePhaseEnlistment.cs
- configsystem.cs
- MenuCommandService.cs
- EntityDataSourceDataSelection.cs
- Domain.cs
- SortDescriptionCollection.cs
- ToolStripContainer.cs
- ClientBuildManagerCallback.cs
- ItemMap.cs
- LogicalExpr.cs
- TreeViewEvent.cs
- DBCommandBuilder.cs
- SchemaElementDecl.cs
- DataServiceResponse.cs
- ApplicationException.cs
- OdbcConnection.cs
- ObjectStorage.cs
- ZipPackagePart.cs
- ZipIOBlockManager.cs
- XmlNamespaceManager.cs
- HttpResponseInternalBase.cs
- ProfileGroupSettings.cs
- SortQuery.cs
- ModuleElement.cs
- HttpClientCertificate.cs
- WindowPatternIdentifiers.cs
- CmsUtils.cs
- DataGridViewHitTestInfo.cs
- RootAction.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- DataSetFieldSchema.cs
- EarlyBoundInfo.cs
- ChildTable.cs
- ViewManager.cs
- DbConnectionInternal.cs
- HttpHandlersSection.cs
- DataGridViewHitTestInfo.cs
- PeerEndPoint.cs
- SelectedDatesCollection.cs
- BufferedReadStream.cs
- LineProperties.cs
- HttpCacheVaryByContentEncodings.cs
- HtmlButton.cs
- UTF7Encoding.cs
- ApplicationManager.cs
- ToolStripKeyboardHandlingService.cs
- ListDictionary.cs
- ComponentResourceKeyConverter.cs
- StrokeIntersection.cs
- ListControl.cs
- BindingContext.cs
- ToolboxDataAttribute.cs
- AutoFocusStyle.xaml.cs
- Attributes.cs
- ObjectTag.cs
- ValidationErrorEventArgs.cs
- TakeOrSkipWhileQueryOperator.cs
- MasterPageParser.cs
- ArrayWithOffset.cs
- GlyphTypeface.cs
- DeclarativeExpressionConditionDeclaration.cs
- MarginCollapsingState.cs
- WebHttpElement.cs
- BuildProviderUtils.cs
- DoubleAnimationBase.cs
- AutoGeneratedField.cs
- SBCSCodePageEncoding.cs
- UInt64Converter.cs
- ListViewCancelEventArgs.cs
- RoleGroup.cs
- TextSimpleMarkerProperties.cs
- TextDecorationCollection.cs
- UnsafeNativeMethods.cs
- MediaScriptCommandRoutedEventArgs.cs
- SubordinateTransaction.cs
- SafeThreadHandle.cs
- Transform3D.cs
- FixedSOMTableRow.cs
- HotCommands.cs
- XPathDescendantIterator.cs
- Repeater.cs
- log.cs
- DynamicEntity.cs
- BufferedOutputStream.cs
- LoopExpression.cs
- CodeStatementCollection.cs
- SiteIdentityPermission.cs
- CheckBoxPopupAdapter.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- GiveFeedbackEventArgs.cs
- AccessKeyManager.cs
- XPathArrayIterator.cs
- Privilege.cs
- HtmlPanelAdapter.cs
- EventSetter.cs
- HttpProfileBase.cs