Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / RequestSecurityTokenForRemoteTokenFactory.cs / 1 / RequestSecurityTokenForRemoteTokenFactory.cs
namespace Microsoft.InfoCards { using System; using System.Xml; using System.Collections; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // This derviced variant of RequestSecurityToken is used to generate an RST to the remote token factory. // internal class RequestSecurityTokenForRemoteTokenFactory : RequestSecurityToken { public RequestSecurityTokenForRemoteTokenFactory( RequestSecurityTokenParameters rstParams ) : base( rstParams ) { } protected override void WriteAppliesToElement() { switch( AppliesToBehaviorDecisionTable.GetAppliesToBehaviorDecisionForRst( Policy, m_rstParams.Card.RequireAppliesto ) ) { case AppliesToBehaviorDecision.SendRPAppliesTo: IDT.TraceDebug( "IPSTSCLIENT: Writing RP AppliesTo to RST" ); Serializer.WriteAppliesToElement( Policy.PolicyAppliesTo, m_rstParams.Version ); break; case AppliesToBehaviorDecision.SendCustomAppliesTo: IDT.TraceDebug( "IPSTSCLIENT: Writing Recipient Identity to RST to create a custom AppliesTo" ); Serializer.WriteAppliesToElement( Policy.ImmediateTokenRecipient.Address, m_rstParams.Version ); break; default: // // Do not write AppliesTo // break; } } protected override void WriteSecondaryParametersElement() { // // Write out a copy of the policy XML to the SecondaryParameters element if we are using the // oasis 2007 version of WS-Trust. // if( XmlNames.WSSpecificationVersion.WSTrustOasis2007 == ProtocolVersionProfile.WSTrust.Version ) { // // If the policy contains optional claims but the user has elected to not sent optional claims, then we // cannot sent secondaryParameters (as we do not want accidental disclosure of information to a // non-auditing STS). // bool writeSeconaryParameters = true; if( Policy.OptionalClaims.Length > 0 ) { // // If the policy contains one or more optional claims, check to see if the user // is willing to send optional claims. // writeSeconaryParameters = m_rstParams.DiscloseOptionalClaims && !( OptionalClaimsExceedCard( m_rstParams.Card, m_rstParams.Policy ) ); } // // Write the secondaryParameters element only when AppliesTo is present // switch( AppliesToBehaviorDecisionTable.GetAppliesToBehaviorDecisionForRst( Policy, m_rstParams.Card.RequireAppliesto ) ) { case AppliesToBehaviorDecision.SendRPAppliesTo: case AppliesToBehaviorDecision.SendCustomAppliesTo: break; default: // // Do not write SecondaryParameters as the appliesTo decision is either 'not send' or 'failed match' // writeSeconaryParameters = false; break; } if( writeSeconaryParameters ) { if( null != Policy.RelyingPartyPolicy ) { Serializer.WriteSecondaryParametersElement( Policy.RelyingPartyPolicy.PolicyXml ); } else { // // If the incoming RST Template did not contain SecondaryParameters, we simply write the // original request. // Serializer.WriteSecondaryParametersElement( Policy.ClientPolicy.PolicyXml ); } } } } protected override void CustomWriteBodyContents( XmlDictionaryWriter writer ) { InitializeWriters( writer ); WriteRSTOpeningElement(); WriteRequestTypeElement(); WriteInfoCardReferenceElement(); WriteClaimsElement(); WriteKeyTypeElement(); WriteKeySupportingElements(); WriteAppliesToElement(); WritePPIDElement(); WriteEncryptionAlgorithmElement(); WritePassOnElements(); WriteDisplayTokenElement(); WriteUnprocessedPolicyElements(); WriteSecondaryParametersElement(); WriteEndElement(); } // // Summary // Checks to see if the optional claims in the policy exceed the claims present in the card. // // Returns // True if at least one optional claim in the policy is not present in the card. False otherwise. // private bool OptionalClaimsExceedCard( InfoCard card, InfoCardPolicy policy ) { // // Compare the set of requested optional claims in the policy against the card's claims. // InfoCardClaimCollection claims = card.GetClaims(); bool claimNotFoundInCard = false; foreach( string claimUri in policy.OptionalClaims ) { if( !claims.ContainsKey( claimUri ) ) { claimNotFoundInCard = true; } } return claimNotFoundInCard; } } } // 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
- SecurityRuntime.cs
- HTTPNotFoundHandler.cs
- XmlBindingWorker.cs
- SinglePageViewer.cs
- FileSystemEventArgs.cs
- ProgressBarHighlightConverter.cs
- CriticalFinalizerObject.cs
- ParsedAttributeCollection.cs
- Statements.cs
- PrintDialog.cs
- HwndMouseInputProvider.cs
- ServiceOperationParameter.cs
- FocusWithinProperty.cs
- NullableBoolConverter.cs
- XmlSerializerAssemblyAttribute.cs
- TextPenaltyModule.cs
- PngBitmapEncoder.cs
- WindowsScroll.cs
- SoapInteropTypes.cs
- AndMessageFilterTable.cs
- SoapInteropTypes.cs
- QueryPageSettingsEventArgs.cs
- IEnumerable.cs
- XPathNode.cs
- DrawingContextDrawingContextWalker.cs
- _NativeSSPI.cs
- ParameterElementCollection.cs
- SatelliteContractVersionAttribute.cs
- MSAAWinEventWrap.cs
- HttpWrapper.cs
- DynamicQueryableWrapper.cs
- InputReport.cs
- ParallelDesigner.cs
- ConfigurationProperty.cs
- DynamicDataResources.Designer.cs
- SerializableAttribute.cs
- RightsManagementResourceHelper.cs
- COM2ComponentEditor.cs
- BindingGraph.cs
- NetworkAddressChange.cs
- BaseDataBoundControl.cs
- TCPListener.cs
- RemotingAttributes.cs
- FlowDecisionLabelFeature.cs
- TextRange.cs
- CodeComment.cs
- RequestUriProcessor.cs
- DependencyPropertyHelper.cs
- XmlTextReader.cs
- SrgsElementFactory.cs
- RecognizedPhrase.cs
- TemplateInstanceAttribute.cs
- PreservationFileReader.cs
- ScrollProperties.cs
- RangeValidator.cs
- ComboBox.cs
- SourceInterpreter.cs
- SmiGettersStream.cs
- TileModeValidation.cs
- XmlLoader.cs
- XmlBinaryReader.cs
- EventMappingSettingsCollection.cs
- StringDictionary.cs
- InkCollectionBehavior.cs
- StringDictionary.cs
- DataGridColumnHeaderAutomationPeer.cs
- TextFormatterImp.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- AssemblyAttributes.cs
- oledbmetadatacolumnnames.cs
- XPathCompiler.cs
- ConditionChanges.cs
- RelationshipManager.cs
- SchemaMapping.cs
- WebHttpDispatchOperationSelector.cs
- MatcherBuilder.cs
- ClientTargetSection.cs
- WSDualHttpBindingCollectionElement.cs
- AdornedElementPlaceholder.cs
- SqlXmlStorage.cs
- ServiceEndpointAssociationProvider.cs
- DPTypeDescriptorContext.cs
- Menu.cs
- ObjectQueryProvider.cs
- ConnectionsZoneDesigner.cs
- ParameterSubsegment.cs
- HttpPostedFileBase.cs
- HttpCookieCollection.cs
- AmbientValueAttribute.cs
- ComponentEvent.cs
- CookieHandler.cs
- ChangeBlockUndoRecord.cs
- ScrollItemPatternIdentifiers.cs
- COM2IPerPropertyBrowsingHandler.cs
- RolePrincipal.cs
- HtmlButton.cs
- ZipIOExtraFieldZip64Element.cs
- NestedContainer.cs
- RootProfilePropertySettingsCollection.cs
- ImageSourceTypeConverter.cs