Ejemplo n.º 1
0
 protected virtual void ValidateIncomingTransport(object sender, ValidateTransportArgs e)
 {
     string rejection = configuration.ValidateIncomingTransport(this, e.Transport, e.Capabilities);
     if (rejection != null)
     {
         e.Reject(rejection);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Consult interested parties to see whether the incoming transport <see cref="t"/>
 /// should be accepted.  Subclasses may choose to override this method to add
 /// additional checks.  This method will log a false result with any accompanying
 /// reasons as to why the connection was rejected.
 /// </summary>
 /// <param name="transport">the incoming transport</param>
 /// <param name="capabilities">the capabilities from the remote</param>
 /// <returns>true if the new transport passes muster, false otherwise</returns>
 protected virtual bool ShouldAcceptTransport(ITransport transport, 
     IDictionary<string, string> capabilities)
 {
     if (ValidateTransport == null) { return true; }
     ValidateTransportArgs vta = new ValidateTransportArgs(transport, capabilities);
     NotifyValidateTransport(this, vta);
     if (vta.Valid) { return true; }
     if (vta.Reasons == null)
     {
         log.Warn("Incoming connection rejected; no reason provided");
     }
     else if (vta.Reasons.Count == 1)
     {
         log.Warn("Incoming connection rejected: " + vta.Reasons[0]);
     }
     else
     {
         StringBuilder result = new StringBuilder("Incoming connection rejected: ");
         for (int i = 0; i < vta.Reasons.Count; i++)
         {
             result.Append(i + 1);
             result.Append(". ");
             result.Append(vta.Reasons[i]);
             if (i +1 != vta.Reasons.Count) { result.Append("  "); }
         }
         log.Warn(result.ToString());
     }
     return false;
 }
Ejemplo n.º 3
0
 private void UnderlyingAcceptor_ValidateTransport(object sender, ValidateTransportArgs e)
 {
     NotifyValidateTransport(sender, e);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This only triggers the <see cref="ValidateTransport"/> event; subclasses
 /// of <see cref="BaseAcceptor"/> likely mean to call <see cref="ShouldAcceptTransport"/>
 /// instead.
 /// </summary>
 /// <param name="acceptor">the acceptor triggering the query</param>
 /// <param name="args">the validation state</param>
 protected void NotifyValidateTransport(object acceptor, ValidateTransportArgs args)
 {
     if(ValidateTransport == null) { return; }
     ValidateTransport(acceptor, args);
 }