Brunet.Security.PeerSec.Symphony.SymphonySecurityOverlord.HandleRpc C# (CSharp) Method

HandleRpc() public method

public HandleRpc ( ISender caller, string method, IList args, object rs ) : void
caller ISender
method string
args IList
rs object
return void
    public void HandleRpc(ISender caller, string method, IList args, object rs)
    {
      object result = null;
      try {
        if(method.Equals("AddCertificate")) {
          ReqrepManager.ReplyState rqrs = caller as ReqrepManager.ReplyState;
          if(rqrs == null || !(rqrs.ReturnPath is Node)) {
            throw new Exception("Call must be made locally for security reasons!");
          }
          string path = (string) args[0];
          result = _ch.AddCertificate(path);
        } else if(method.Equals("GetState")) {
          if(args.Count != 1) {
            throw new Exception("Not enough arguments");
          } else if(!(args[0] is string)) {
            throw new Exception("Argument should be a string");
          }
          Address addr = AddressParser.Parse(args[0] as string);
          SecurityAssociation sa = CheckForSecureSender(addr);
          if(sa == null) {
            result = "No SA";
          } else {
            result = sa.ToString();
          }
        } else {
          result = new Exception("Invalid method");
        }
      } catch (Exception e) {
        result = e;
      }
      _node.Rpc.SendResult(rs, result);
    }