public static void Publish(string path, Authority auth) { Node node = root; if (path == ".") { node.auth = auth; return; } string[] parts = path.Split('.'); for (int i = parts.Length-1; i > 0; --i) { if (parts[i] == "") continue; node = node.children[parts[i]]; } //string issuer = auth.Certificate.Issuer.Common; //if (node.auth.Certificate.Subject.Common != issuer) // throw new InvalidOperationException("This cert is not authorized to be published here"); if(!auth.Certificate.Verify(node.auth.Certificate.PublicKey)) throw new InvalidOperationException("This cert is not authorized to be published here"); string name = auth.Certificate.Subject.Common; Node newNode = new Node(); newNode.parent = node; newNode.children.Add(name, newNode); newNode.auth = auth; }
public static void Publish(string path, Authority auth) { Node node = root; if (path == ".") { node.auth = auth; return; } string[] parts = path.Split('.'); for (int i = parts.Length - 1; i > 0; --i) { if (parts[i] == "") { continue; } node = node.children[parts[i]]; } //string issuer = auth.Certificate.Issuer.Common; //if (node.auth.Certificate.Subject.Common != issuer) // throw new InvalidOperationException("This cert is not authorized to be published here"); if (!auth.Certificate.Verify(node.auth.Certificate.PublicKey)) { throw new InvalidOperationException("This cert is not authorized to be published here"); } string name = auth.Certificate.Subject.Common; Node newNode = new Node(); newNode.parent = node; newNode.children.Add(name, newNode); newNode.auth = auth; }
static void Authorities() { Authority root = Authority.Root; Authority com = new Authority("com"); Authority coco = new Authority("coco"); Authority frank = new Authority("frank"); Naming.Publish(root.FullName, root); com.Promote(root.Authorize(com.Request)); Naming.Publish(com.FullName, com); coco.Promote(com.Authorize(coco.Request)); Naming.Publish(coco.FullName, coco); frank.Promote(coco.Authorize(frank.Request)); Naming.Publish(frank.FullName, frank); Console.WriteLine(frank.Certificate); }