public PeerMessageDispatcher(PeerMessageQueueAdapter <ChannelInterfaceType, TChannel> queueHandler, PeerNodeImplementation peerNode, ChannelManagerBase channelManager, EndpointAddress to, Uri via) { this.quotaHelper = new PeerQuotaHelper(0x7fffffff); PeerNodeImplementation.ValidateVia(via); this.queueHandler = queueHandler; this.peerNode = peerNode; this.to = to; this.via = via; this.channelManager = channelManager; EndpointAddress address = null; this.securityProtocol = ((IPeerFactory)channelManager).SecurityManager.CreateSecurityProtocol <ChannelInterfaceType>(to, ServiceDefaults.SendTimeout); if (typeof(IDuplexChannel).IsAssignableFrom(typeof(ChannelInterfaceType))) { address = to; } PeerMessageFilter[] filters = new PeerMessageFilter[] { new PeerMessageFilter(via, address) }; peerNode.RegisterMessageFilter(this, this.via, filters, (ITransportFactorySettings)this.channelManager, new PeerNodeImplementation.MessageAvailableCallback(this.OnMessageAvailable), this.securityProtocol); this.registered = true; }
private bool TryGetTokenSynchronouslyForOutgoingSecurity(Message message, SecurityProtocolCorrelationState correlationState, bool isBlockingCall, TimeSpan timeout, out SecurityToken encryptingToken, out SecurityToken signingToken, out IList <SupportingTokenSpecification> supportingTokens, out SecurityProtocolCorrelationState newCorrelationState) { AsymmetricSecurityProtocolFactory factory = this.Factory; encryptingToken = null; signingToken = null; newCorrelationState = null; supportingTokens = null; TimeoutHelper helper = new TimeoutHelper(timeout); if (factory.ActAsInitiator) { if (!isBlockingCall || !base.TryGetSupportingTokens(this.Factory, base.Target, base.Via, message, helper.RemainingTime(), isBlockingCall, out supportingTokens)) { return(false); } if (factory.ApplyConfidentiality) { encryptingToken = base.GetTokenAndEnsureOutgoingIdentity(this.initiatorAsymmetricTokenProvider, true, helper.RemainingTime(), this.initiatorAsymmetricTokenAuthenticator); } if (factory.ApplyIntegrity) { signingToken = SecurityProtocol.GetToken(this.initiatorCryptoTokenProvider, base.Target, helper.RemainingTime()); newCorrelationState = base.GetCorrelationState(signingToken); } } else { if (factory.ApplyConfidentiality) { encryptingToken = base.GetCorrelationToken(correlationState); } if (factory.ApplyIntegrity) { signingToken = SecurityProtocol.GetToken(factory.RecipientAsymmetricTokenProvider, null, helper.RemainingTime()); } } return(true); }
public DuplexSecurityProtocol(SecurityProtocol outgoingProtocol, SecurityProtocol incomingProtocol) : base(incomingProtocol.SecurityProtocolFactory, null, null) { this.outgoingProtocol = outgoingProtocol; this.incomingProtocol = incomingProtocol; }
public DuplexSecurityProtocol(SecurityProtocol outgoingProtocol, SecurityProtocol incomingProtocol) : base(incomingProtocol.SecurityProtocolFactory, null, null) { this.outgoingProtocol = outgoingProtocol; this.incomingProtocol = incomingProtocol; }
protected SecurityChannel(ChannelManagerBase channelManager, TChannel innerChannel, SecurityProtocol securityProtocol) : base(channelManager, innerChannel) { _securityProtocol = securityProtocol; }
public GetSupportingTokensAsyncResult(Message m, SecurityProtocol binding, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.message = m; this.binding = binding; this.timeoutHelper = new TimeoutHelper(timeout); }
protected override SecurityProtocolCorrelationState VerifyIncomingMessageCore(ref Message message, string actor, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates) { IList <SupportingTokenAuthenticatorSpecification> list; AsymmetricSecurityProtocolFactory factory = this.Factory; TimeoutHelper helper = new TimeoutHelper(timeout); ReceiveSecurityHeader securityHeader = base.ConfigureReceiveSecurityHeader(message, string.Empty, correlationStates, out list); SecurityToken requiredSigningToken = null; if (factory.ActAsInitiator) { SecurityTokenAuthenticator initiatorAsymmetricTokenAuthenticator; SecurityToken token = null; SecurityToken primaryToken = null; if (factory.RequireIntegrity) { primaryToken = SecurityProtocol.GetToken(this.initiatorAsymmetricTokenProvider, null, helper.RemainingTime()); requiredSigningToken = primaryToken; } if (factory.RequireConfidentiality) { token = base.GetCorrelationToken(correlationStates); if (!System.ServiceModel.Security.SecurityUtils.HasSymmetricSecurityKey(token)) { securityHeader.WrappedKeySecurityTokenAuthenticator = this.Factory.WrappedKeySecurityTokenAuthenticator; } } if (factory.AllowSerializedSigningTokenOnReply) { initiatorAsymmetricTokenAuthenticator = this.initiatorAsymmetricTokenAuthenticator; requiredSigningToken = null; } else { initiatorAsymmetricTokenAuthenticator = null; } securityHeader.ConfigureAsymmetricBindingClientReceiveHeader(primaryToken, factory.AsymmetricTokenParameters, token, factory.CryptoTokenParameters, initiatorAsymmetricTokenAuthenticator); } else { SecurityToken token4; if ((this.Factory.RecipientAsymmetricTokenProvider != null) && this.Factory.RequireConfidentiality) { token4 = SecurityProtocol.GetToken(factory.RecipientAsymmetricTokenProvider, null, helper.RemainingTime()); } else { token4 = null; } securityHeader.ConfigureAsymmetricBindingServerReceiveHeader(this.Factory.RecipientCryptoTokenAuthenticator, this.Factory.CryptoTokenParameters, token4, this.Factory.AsymmetricTokenParameters, list); securityHeader.WrappedKeySecurityTokenAuthenticator = this.Factory.WrappedKeySecurityTokenAuthenticator; securityHeader.ConfigureOutOfBandTokenResolver(base.MergeOutOfBandResolvers(list, this.Factory.RecipientOutOfBandTokenResolverList)); } base.ProcessSecurityHeader(securityHeader, ref message, requiredSigningToken, helper.RemainingTime(), correlationStates); SecurityToken signatureToken = securityHeader.SignatureToken; SecurityToken encryptionToken = securityHeader.EncryptionToken; if (factory.RequireIntegrity) { if (factory.ActAsInitiator) { ReadOnlyCollection <IAuthorizationPolicy> recipientTokenPolicies = this.initiatorAsymmetricTokenAuthenticator.ValidateToken(signatureToken); MessageSecurityProtocol.EnsureNonWrappedToken(signatureToken, message); this.DoIdentityCheckAndAttachInitiatorSecurityProperty(message, encryptionToken, signatureToken, recipientTokenPolicies); } else { MessageSecurityProtocol.EnsureNonWrappedToken(signatureToken, message); this.AttachRecipientSecurityProperty(message, signatureToken, encryptionToken, securityHeader.BasicSupportingTokens, securityHeader.EndorsingSupportingTokens, securityHeader.SignedEndorsingSupportingTokens, securityHeader.SignedSupportingTokens, securityHeader.SecurityTokenAuthorizationPoliciesMapping); } } return(base.GetCorrelationState(signatureToken, securityHeader)); }
public OutputChannelSendAsyncResult(Message message, SecurityProtocol binding, IOutputChannel channel, TimeSpan timeout, AsyncCallback callback, object state) : base(binding, channel, timeout, callback, state) { this.Begin(message, null); }
public GetSupportingTokensAsyncResult(Message m, SecurityProtocol binding, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.message = m; this.binding = binding; this.timeoutHelper = new TimeoutHelper(timeout); }