Security API additions.

-Principal can now get a slice of blessings that match a name.
-Principal can now get a name for a blessing that belongs to it.
-BlessingStore exports a map of all the pattern/blessings that have been added.

Change-Id: Idaa8d9ddf8acd03a7d2b72d5bf408566d1a8cdc1
diff --git a/security/agent/client.go b/security/agent/client.go
index 6a3925f..cd26573 100644
--- a/security/agent/client.go
+++ b/security/agent/client.go
@@ -128,6 +128,33 @@
 	return c.key
 }
 
+func (c *client) BlessingsByName(pattern security.BlessingPattern) []security.Blessings {
+	var wbResults []security.WireBlessings
+	err := c.caller.call("BlessingsByName", results(&wbResults), pattern)
+	if err != nil {
+		vlog.Errorf("error calling BlessingsByName: %v", err)
+		return nil
+	}
+	blessings := make([]security.Blessings, len(wbResults))
+	for i, wb := range wbResults {
+		var err error
+		blessings[i], err = security.NewBlessings(wb)
+		if err != nil {
+			vlog.Errorf("error creating Blessing from WireBlessings: %v", err)
+		}
+	}
+	return blessings
+}
+
+func (c *client) BlessingsInfo(blessings security.Blessings) []string {
+	var names []string
+	err := c.caller.call("BlessingsInfo", results(&names), security.MarshalBlessings(blessings))
+	if err != nil {
+		vlog.Errorf("error calling BlessingsInfo: %v", err)
+		return nil
+	}
+	return names
+}
 func (c *client) BlessingStore() security.BlessingStore {
 	return &blessingStore{c.caller, c.key}
 }
@@ -192,6 +219,25 @@
 	return b.key
 }
 
+func (b *blessingStore) PeerBlessings() map[security.BlessingPattern]security.Blessings {
+	var wbMap map[security.BlessingPattern]security.WireBlessings
+	err := b.caller.call("BlessingStorePeerBlessings", results(&wbMap))
+	if err != nil {
+		vlog.Errorf("error calling BlessingStorePeerBlessings: %v", err)
+		return nil
+	}
+	bMap := make(map[security.BlessingPattern]security.Blessings)
+	for pattern, wb := range wbMap {
+		blessings, err := security.NewBlessings(wb)
+		if err != nil {
+			vlog.Errorf("error creating Blessing from WireBlessings: %v", err)
+			return nil
+		}
+		bMap[pattern] = blessings
+	}
+	return bMap
+}
+
 func (b *blessingStore) DebugString() (s string) {
 	err := b.caller.call("BlessingStoreDebugString", results(&s))
 	if err != nil {