예제 #1
0
파일: BrunetRpc.cs 프로젝트: xujyan/brunet
 public BrunetRpc() {
   _rrm = new ReqrepManager("BrunetRpc");
   _rrm.Subscribe(this, null);
   Rpc = new RpcManager(_rrm);
   IPHandler = new IPHandler();
   IPHandler.Subscribe(this, null);
   _running = 1;
   _timer = new Thread(TimerThread);
   _timer.IsBackground = true;
   _timer.Start();
 }
예제 #2
0
 public SecurityOverlord(RSACryptoServiceProvider rsa, ReqrepManager rrman, CertificateHandler ch) {
   _private_key = rsa;
   _private_key_lock = new object();
   _ch = ch;
   _spi = new Dictionary<int, Dictionary<ISender, SecurityAssociation>>();
   _cookie = new byte[CookieLength];
   _rand = new Random();
   _rand.NextBytes(_cookie);
   _rrman = rrman;
   _last_heartbeat = DateTime.UtcNow;
   _rrman.Subscribe(this, null);
 }
예제 #3
0
    protected SecurityOverlord CreateInvalidSO(string name, int level) {
      if(rsa == null) {
        rsa = new RSACryptoServiceProvider();
        byte[] blob = rsa.ExportCspBlob(false);
        RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
        rsa_pub.ImportCspBlob(blob);
        CertificateMaker cm = new CertificateMaker("United States", "UFL", 
            "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
            "brunet:node:abcdefghijklmnopqrs");
        Certificate cert = cm.Sign(cm, rsa);
        x509 = cert.X509;
      }

      CertificateHandler ch = new CertificateHandler();
      if(level == 2 || level == 0) {
        ch.AddCACertificate(x509);
      }
      if(level == 3 || level == 0) {
        ch.AddSignedCertificate(x509);
      }
      ReqrepManager rrm = new ReqrepManager("so" + name);
      _timeout += rrm.TimeoutChecker;
      SecurityOverlord so = new SecurityOverlord(rsa_safe, rrm, ch);
      so.AnnounceSA += AnnounceSA;
      RoutingDataHandler rdh = new RoutingDataHandler();
      rrm.Subscribe(so, null);
      so.Subscribe(rdh, null);
      rdh.Subscribe(rrm, null);
      return so;
    }