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
- SplitterPanel.cs
- XPathNodeList.cs
- Internal.cs
- GenericTypeParameterConverter.cs
- CodeArgumentReferenceExpression.cs
- SourceFileBuildProvider.cs
- XmlSerializationGeneratedCode.cs
- PathSegmentCollection.cs
- WpfKnownTypeInvoker.cs
- EmitterCache.cs
- SpecialNameAttribute.cs
- SqlStatistics.cs
- RestHandler.cs
- AssemblyName.cs
- _UriSyntax.cs
- TreeIterator.cs
- DNS.cs
- AtomicFile.cs
- SettingsPropertyValueCollection.cs
- peernodestatemanager.cs
- XmlQueryTypeFactory.cs
- XsdSchemaFileEditor.cs
- PrintController.cs
- XmlTypeAttribute.cs
- HashJoinQueryOperatorEnumerator.cs
- Serializer.cs
- ImageBrush.cs
- DeviceContexts.cs
- SafeProcessHandle.cs
- SqlProcedureAttribute.cs
- XmlCountingReader.cs
- InputScopeNameConverter.cs
- PolicyValidationException.cs
- XmlSignatureManifest.cs
- PackagePartCollection.cs
- SecurityTokenRequirement.cs
- SymbolMethod.cs
- Header.cs
- TreeViewItemAutomationPeer.cs
- TreeNodeStyle.cs
- OrthographicCamera.cs
- TemplateNameScope.cs
- PackUriHelper.cs
- OutKeywords.cs
- TargetConverter.cs
- HttpChannelHelpers.cs
- QuadraticBezierSegment.cs
- WinEventWrap.cs
- SiteMap.cs
- ServiceContractListItem.cs
- SafeHGlobalHandleCritical.cs
- DataConnectionHelper.cs
- Constraint.cs
- SqlClientPermission.cs
- Int64KeyFrameCollection.cs
- WorkItem.cs
- LinkLabelLinkClickedEvent.cs
- DesignerValidationSummaryAdapter.cs
- ObjectStorage.cs
- SingleConverter.cs
- WebHttpSecurity.cs
- PackageFilter.cs
- DataGridSortCommandEventArgs.cs
- PhoneCallDesigner.cs
- hresults.cs
- WindowsGraphicsCacheManager.cs
- BindUriHelper.cs
- XmlHierarchyData.cs
- SqlRecordBuffer.cs
- IntranetCredentialPolicy.cs
- DecimalAnimationBase.cs
- ExpressionBindings.cs
- Padding.cs
- InsufficientMemoryException.cs
- ResourceProperty.cs
- MulticastDelegate.cs
- TemplateAction.cs
- EdmFunctions.cs
- DSASignatureDeformatter.cs
- ListContractAdapter.cs
- SecurityTokenTypes.cs
- PageAsyncTask.cs
- XmlEventCache.cs
- CalendarModeChangedEventArgs.cs
- SimpleFileLog.cs
- FontStretches.cs
- ProfilePropertySettingsCollection.cs
- CngProperty.cs
- Helper.cs
- HiddenField.cs
- UTF32Encoding.cs
- PropertyDescriptorCollection.cs
- TemplateLookupAction.cs
- EntityDataSourceView.cs
- ColorConvertedBitmapExtension.cs
- TreeViewCancelEvent.cs
- XmlObjectSerializerContext.cs
- SpecularMaterial.cs
- OutputCacheSettings.cs
- MetadataSource.cs