Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / LaxModeSecurityHeaderElementInferenceEngine.cs / 1 / LaxModeSecurityHeaderElementInferenceEngine.cs
//---------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Security { using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; using System.Xml; using SignedXml = System.IdentityModel.SignedXml; using StandardSignedInfo = System.IdentityModel.StandardSignedInfo; class LaxModeSecurityHeaderElementInferenceEngine : SecurityHeaderElementInferenceEngine { static LaxModeSecurityHeaderElementInferenceEngine instance = new LaxModeSecurityHeaderElementInferenceEngine(); protected LaxModeSecurityHeaderElementInferenceEngine() {} internal static LaxModeSecurityHeaderElementInferenceEngine Instance { get { return instance; } } public override void ExecuteProcessingPasses(ReceiveSecurityHeader securityHeader, XmlDictionaryReader reader) { // pass 1 securityHeader.ExecuteReadingPass(reader); // pass 1.5 securityHeader.ExecuteDerivedKeyTokenStubPass(false); // pass 2 securityHeader.ExecuteSubheaderDecryptionPass(); // pass 2.5 securityHeader.ExecuteDerivedKeyTokenStubPass(true); // layout-specific inferences MarkElements(securityHeader.ElementManager, securityHeader.RequireMessageProtection); // pass 3 securityHeader.ExecuteSignatureEncryptionProcessingPass(); } public override void MarkElements(ReceiveSecurityHeaderElementManager elementManager, bool messageSecurityMode) { bool primarySignatureFound = false; for (int position = 0; position < elementManager.Count; position++) { ReceiveSecurityHeaderEntry entry; elementManager.GetElementEntry(position, out entry); if (entry.elementCategory == ReceiveSecurityHeaderElementCategory.Signature) { if (!messageSecurityMode) { elementManager.SetBindingMode(position, ReceiveSecurityHeaderBindingModes.Endorsing); continue; } SignedXml signedXml = (SignedXml) entry.element; StandardSignedInfo signedInfo = (StandardSignedInfo) signedXml.Signature.SignedInfo; bool targetsSignature = false; if (signedInfo.ReferenceCount == 1) { string uri = signedInfo[0].Uri; string id; if (uri != null && uri.Length > 1 && uri[0] == '#') { id = uri.Substring(1); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new MessageSecurityException(SR.GetString(SR.UnableToResolveReferenceUriForSignature, uri))); } for (int j = 0; j < elementManager.Count; j++) { ReceiveSecurityHeaderEntry inner; elementManager.GetElementEntry(j, out inner); if (j != position && inner.elementCategory == ReceiveSecurityHeaderElementCategory.Signature && inner.id == id) { targetsSignature = true; break; } } } if (targetsSignature) { elementManager.SetBindingMode(position, ReceiveSecurityHeaderBindingModes.Endorsing); continue; } else { if (primarySignatureFound) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.AtMostOnePrimarySignatureInReceiveSecurityHeader))); } primarySignatureFound = true; elementManager.SetBindingMode(position, ReceiveSecurityHeaderBindingModes.Primary); continue; } } } } } } // 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
- ErrorFormatter.cs
- PeerName.cs
- EarlyBoundInfo.cs
- XmlReflectionMember.cs
- SamlDoNotCacheCondition.cs
- XPathScanner.cs
- DataBinding.cs
- HandlerBase.cs
- ReadOnlyDataSource.cs
- OutputCacheSection.cs
- DrawingContextDrawingContextWalker.cs
- FormatException.cs
- EndPoint.cs
- LiteralControl.cs
- TimeSpanConverter.cs
- EditingCoordinator.cs
- Int16AnimationBase.cs
- ReferenceAssemblyAttribute.cs
- FacetValueContainer.cs
- SafeCryptContextHandle.cs
- TableCellCollection.cs
- Light.cs
- ConfigXmlCDataSection.cs
- RichTextBoxAutomationPeer.cs
- Input.cs
- EnumConverter.cs
- FontWeightConverter.cs
- XmlSchemaAnyAttribute.cs
- QueryOptionExpression.cs
- MarkupProperty.cs
- Processor.cs
- BatchServiceHost.cs
- PenCursorManager.cs
- UrlSyndicationContent.cs
- QueueProcessor.cs
- ExtendedPropertyCollection.cs
- DesignObjectWrapper.cs
- XmlValidatingReaderImpl.cs
- CopyOfAction.cs
- StaticContext.cs
- CompositeDuplexElement.cs
- SingleAnimation.cs
- TextElementEnumerator.cs
- SQLInt32Storage.cs
- DrawingImage.cs
- SafeCryptContextHandle.cs
- HeaderLabel.cs
- CodeTypeMember.cs
- EndOfStreamException.cs
- RequestCacheEntry.cs
- UidPropertyAttribute.cs
- COM2ComponentEditor.cs
- ProfilePropertyMetadata.cs
- DataRow.cs
- XmlMemberMapping.cs
- SiteOfOriginPart.cs
- MetadataStore.cs
- ErrorFormatter.cs
- DivideByZeroException.cs
- ObjectCacheHost.cs
- StringStorage.cs
- MsmqTransportElement.cs
- XmlUtf8RawTextWriter.cs
- EntityDataSourceViewSchema.cs
- GroupBox.cs
- HttpCachePolicyElement.cs
- ValidatorCompatibilityHelper.cs
- OracleLob.cs
- Rect.cs
- XmlEntity.cs
- ObjectComplexPropertyMapping.cs
- ResizeGrip.cs
- ClientConfigurationSystem.cs
- HwndHost.cs
- Decimal.cs
- PassportPrincipal.cs
- HttpListenerContext.cs
- PropertyFilterAttribute.cs
- SerializerProvider.cs
- XmlReflectionImporter.cs
- URIFormatException.cs
- FileVersion.cs
- ReaderWriterLock.cs
- Inline.cs
- StrongNameIdentityPermission.cs
- WindowsStreamSecurityUpgradeProvider.cs
- FixedLineResult.cs
- DbMetaDataColumnNames.cs
- SafeSecurityHandles.cs
- PropertyState.cs
- GenericEnumerator.cs
- ToolStripDropDownDesigner.cs
- XomlCompilerParameters.cs
- ButtonFieldBase.cs
- BindingExpression.cs
- XhtmlTextWriter.cs
- Profiler.cs
- Funcletizer.cs
- AtomMaterializerLog.cs
- UdpAnnouncementEndpoint.cs