Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / OptionalRstParameters.cs / 1 / OptionalRstParameters.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; using System.Runtime.Serialization; using System.ServiceModel.Security; using System.Xml; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary: // This class clumps together optional properties from the recipient policy's // requestsecuritytokentemplate and puts them into the RST to the IP/STS // // wst:TokenType // wst:SignatureAlgorithm // wst:EncryptionAlgorithm // wst:CanonicalizationAlgorithm // wst:SignWith // wst:EncryptWith // wst:KeyWrapAlgorithm // class OptionalRstParameters { string m_tokenType = String.Empty; // // We could set the default value of the signature, but does not seem necessary // SecurityAlgorithmSuite.Default.DefaultSymmetricSignatureAlgorithm; hmac sha1 // SecurityAlgorithmSuite.Default.DefaultEncryptionAlgorithm; aes256 cbc // SecurityAlgorithmSuite.Default.DefaultCanonicalizationAlgorithm; xml-exc-c14n // SecurityAlgorithmSuite.Default.DefaultAsymmetricSignatureAlgorithm; rsa sha1 // string m_signatureAlgorithm; string m_encryptionAlgorithm; string m_canonicalizationAlgorithm; string m_signWith; // // SecurityAlgorithmSuite.Default.DefaultEncryptionAlgorithm // Current default is Basic256 --> Aes256Encryption CBC // string m_encryptWith; // // This optional URI element indicates the desired algorithm to use for // key wrapping when STS encrypts the issued token for the relying party using an asymmetric key. // string m_keyWrapAlgorithm; // // Creates a merged instace of OptionalRstParameters that populates its members from primary whenever possible and // secondary when the values are absent from primary. // public static OptionalRstParameters CreateMergedParameters( OptionalRstParameters primary, OptionalRstParameters secondary ) { OptionalRstParameters mergedParams = new OptionalRstParameters(); mergedParams.m_canonicalizationAlgorithm = ( !String.IsNullOrEmpty( primary.m_canonicalizationAlgorithm ) ) ? primary.m_canonicalizationAlgorithm : secondary.m_canonicalizationAlgorithm; mergedParams.m_encryptionAlgorithm = ( !String.IsNullOrEmpty( primary.m_encryptionAlgorithm ) ) ? primary.m_encryptionAlgorithm : secondary.m_encryptionAlgorithm; mergedParams.m_encryptWith = ( !String.IsNullOrEmpty( primary.m_encryptWith ) ) ? primary.m_encryptWith : secondary.m_encryptWith; if( String.IsNullOrEmpty( primary.m_keyWrapAlgorithm ) && String.IsNullOrEmpty( secondary.m_keyWrapAlgorithm ) ) { mergedParams.m_keyWrapAlgorithm = SecurityAlgorithmSuite.Default.DefaultAsymmetricKeyWrapAlgorithm; } else { mergedParams.m_keyWrapAlgorithm = ( !String.IsNullOrEmpty( primary.m_keyWrapAlgorithm ) ) ? primary.m_keyWrapAlgorithm : secondary.m_keyWrapAlgorithm; } mergedParams.m_signatureAlgorithm = ( !String.IsNullOrEmpty( primary.m_signatureAlgorithm ) ) ? primary.m_signatureAlgorithm : secondary.m_signatureAlgorithm; mergedParams.m_signWith = ( !String.IsNullOrEmpty( primary.m_signWith ) ) ? primary.m_signWith : secondary.m_signWith; mergedParams.m_tokenType = ( !String.IsNullOrEmpty( primary.m_tokenType ) ) ? primary.m_tokenType : secondary.m_tokenType; return mergedParams; } public string SignatureAlgorithm { get { return m_signatureAlgorithm; } set { m_signatureAlgorithm = value; } } public string EncryptionAlgorithm { get { return m_encryptionAlgorithm; } set { m_encryptionAlgorithm = value; } } public string SignWith { get { return m_signWith; } set { m_signWith = value; } } public string EncryptWith { get { return m_encryptWith; } set { m_encryptWith = value; } } public string CanonicalizationAlgorithm { get { return m_canonicalizationAlgorithm; } set { m_canonicalizationAlgorithm = value; } } public string KeyWrapAlgorithm { get { return m_keyWrapAlgorithm; } set { m_keyWrapAlgorithm = value; } } public string TokenType { get { return m_tokenType; } set { m_tokenType = value; } } // // Summary: // Only to be used by CustomTokenRequest to write out the // optional pass on elements into the RST with the IP/STS // public void WritePassOnElements( XmlDictionaryWriter writer, ProtocolProfile profile ) { string wstprefix = profile.WSTrust.DefaultPrefix; if( !String.IsNullOrEmpty( TokenType ) ) { IDT.TraceDebug( "IPSTSCLIENT: Writing token type {0} to RST", TokenType ); writer.WriteStartElement( wstprefix, profile.WSTrust.TokenType, profile.WSTrust.Namespace ); writer.WriteString( TokenType ); writer.WriteEndElement(); } if( !String.IsNullOrEmpty( SignatureAlgorithm ) ) { writer.WriteStartElement( wstprefix, profile.WSTrust.SignatureAlgorithm, profile.WSTrust.Namespace ); writer.WriteString( SignatureAlgorithm ); writer.WriteEndElement(); } if( !String.IsNullOrEmpty( CanonicalizationAlgorithm ) ) { writer.WriteStartElement( wstprefix, profile.WSTrust.CanonicalizationAlgorithm, profile.WSTrust.Namespace ); writer.WriteString( CanonicalizationAlgorithm ); writer.WriteEndElement(); } // // Already handled in CustomRequestToken, don't write again: // EncryptionAlgorithm // SignWith // EncryptWith // KeyWrapAlgorithm // } } } // 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
- CompressEmulationStream.cs
- NativeRightsManagementAPIsStructures.cs
- PersonalizationStateInfoCollection.cs
- Image.cs
- ClientRolePrincipal.cs
- CompositeDataBoundControl.cs
- LineVisual.cs
- MemoryPressure.cs
- PathParser.cs
- loginstatus.cs
- ManagementOperationWatcher.cs
- ExpressionBindingsDialog.cs
- WebPartAddingEventArgs.cs
- CacheVirtualItemsEvent.cs
- CodeMethodReturnStatement.cs
- MessageSecurityOverTcp.cs
- CheckBoxPopupAdapter.cs
- LinqDataSource.cs
- BitmapEffectDrawing.cs
- OutputWindow.cs
- CodeGenerator.cs
- BinarySerializer.cs
- SendActivityDesignerTheme.cs
- ScriptReferenceBase.cs
- BufferAllocator.cs
- XPathDocumentBuilder.cs
- TabItemAutomationPeer.cs
- UnaryExpressionHelper.cs
- wgx_sdk_version.cs
- SQLInt16.cs
- Base64Encoding.cs
- ProgressBarRenderer.cs
- Msec.cs
- XmlObjectSerializer.cs
- Label.cs
- DataMemberFieldConverter.cs
- InitializingNewItemEventArgs.cs
- FixedSOMTableCell.cs
- AppDomainProtocolHandler.cs
- Figure.cs
- GcHandle.cs
- ExtensionsSection.cs
- WorkflowServiceBuildProvider.cs
- QilParameter.cs
- RadioButtonFlatAdapter.cs
- MessageLogTraceRecord.cs
- StorageFunctionMapping.cs
- ManagementException.cs
- SiteMapNodeCollection.cs
- JulianCalendar.cs
- TimeSpan.cs
- odbcmetadatacolumnnames.cs
- HttpCookie.cs
- LocatorBase.cs
- ListBoxItemWrapperAutomationPeer.cs
- ReadOnlyObservableCollection.cs
- MemberAccessException.cs
- XmlSchemaAnnotated.cs
- ListBoxAutomationPeer.cs
- NameValuePermission.cs
- ScriptMethodAttribute.cs
- GridViewPageEventArgs.cs
- Application.cs
- SqlDependencyUtils.cs
- InvokeMethodActivity.cs
- SspiSafeHandles.cs
- MarkedHighlightComponent.cs
- DbDataReader.cs
- CookielessHelper.cs
- RegexWorker.cs
- DataListItemEventArgs.cs
- HandlerFactoryCache.cs
- ServiceModelConfigurationSection.cs
- CopyCodeAction.cs
- WSSecurityXXX2005.cs
- UnsafeNativeMethods.cs
- TreeView.cs
- FlatButtonAppearance.cs
- PackageDigitalSignatureManager.cs
- ConnectionManagementElement.cs
- SqlBulkCopyColumnMapping.cs
- CreateUserWizardDesigner.cs
- _BufferOffsetSize.cs
- GridViewRowEventArgs.cs
- OracleParameter.cs
- sqlser.cs
- TextUtf8RawTextWriter.cs
- CharUnicodeInfo.cs
- KernelTypeValidation.cs
- SimplePropertyEntry.cs
- FunctionDetailsReader.cs
- MemoryStream.cs
- Brushes.cs
- LocalizabilityAttribute.cs
- ByteKeyFrameCollection.cs
- TrustManagerPromptUI.cs
- BrushValueSerializer.cs
- PageParserFilter.cs
- CommandLibraryHelper.cs
- UriScheme.cs