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
- Run.cs
- messageonlyhwndwrapper.cs
- Util.cs
- ButtonStandardAdapter.cs
- PenContexts.cs
- WebEventTraceProvider.cs
- SqlProviderServices.cs
- __TransparentProxy.cs
- InvokeProviderWrapper.cs
- UpdatableWrapper.cs
- SQLByte.cs
- ObjectDisposedException.cs
- ApplicationDirectory.cs
- HMACSHA384.cs
- Transform.cs
- SoapIgnoreAttribute.cs
- ToolStripDropDownClosingEventArgs.cs
- Exceptions.cs
- StateDesigner.TransitionInfo.cs
- MutexSecurity.cs
- InputBuffer.cs
- HostUtils.cs
- OneToOneMappingSerializer.cs
- ConfigurationProperty.cs
- SafeArrayRankMismatchException.cs
- CodeParameterDeclarationExpression.cs
- DispatcherOperation.cs
- recordstatefactory.cs
- PasswordTextNavigator.cs
- RuntimeConfig.cs
- _FtpControlStream.cs
- ReaderOutput.cs
- ApplicationProxyInternal.cs
- XPathNodeIterator.cs
- CodeExporter.cs
- CellConstantDomain.cs
- SchemaElement.cs
- CheckedPointers.cs
- XPathSingletonIterator.cs
- EntityParameter.cs
- DataGridViewCellStateChangedEventArgs.cs
- DateBoldEvent.cs
- DataBindingExpressionBuilder.cs
- ConstantSlot.cs
- Model3DCollection.cs
- BooleanAnimationUsingKeyFrames.cs
- DataExpression.cs
- XmlSchemaAll.cs
- ProxyWebPartManagerDesigner.cs
- DrawingGroup.cs
- HttpAsyncResult.cs
- WebServiceFault.cs
- ActionFrame.cs
- FontDialog.cs
- RTLAwareMessageBox.cs
- HttpGetProtocolImporter.cs
- XmlUtil.cs
- ResourceIDHelper.cs
- CorePropertiesFilter.cs
- ProcessModelSection.cs
- ToolStripDropTargetManager.cs
- SelfIssuedAuthAsymmetricKey.cs
- GenericPrincipal.cs
- PathGeometry.cs
- UseAttributeSetsAction.cs
- DesignTimeVisibleAttribute.cs
- SQLString.cs
- WhereQueryOperator.cs
- EmissiveMaterial.cs
- StatusBarDrawItemEvent.cs
- HostVisual.cs
- ParallelActivityDesigner.cs
- ClientProtocol.cs
- StylusPointPropertyInfoDefaults.cs
- HashCodeCombiner.cs
- PermissionSetEnumerator.cs
- Timer.cs
- SmiRecordBuffer.cs
- KeySpline.cs
- BooleanFunctions.cs
- ModulesEntry.cs
- WebEventTraceProvider.cs
- OleDbMetaDataFactory.cs
- DynamicControl.cs
- Block.cs
- XmlCollation.cs
- InternalEnumValidatorAttribute.cs
- EncoderFallback.cs
- TextSimpleMarkerProperties.cs
- OutputCacheProfile.cs
- SqlUserDefinedAggregateAttribute.cs
- NameValuePair.cs
- MessageQueueKey.cs
- TimelineClockCollection.cs
- DefaultPropertyAttribute.cs
- EventLogPermissionEntry.cs
- DataControlImageButton.cs
- HandlerBase.cs
- ItemAutomationPeer.cs
- StylusButtonCollection.cs