| import "veyron2/security" |
| // JSPublicIDHandles is a store for PublicIDs in use by JS code. |
| // We don't pass the full PublicID to avoid serializing and deserializing a |
| // potentially huge forest of blessings. Instead we pass to JS a handle to a public |
| // identity and have all operations involve cryptographic operations call into go. |
| type JSPublicIDHandles struct { |
| store map[int64]security.PublicID |
| // NewJSPublicIDHandles returns a newly initialized JSPublicIDHandles |
| func NewJSPublicIDHandles() *JSPublicIDHandles { |
| return &JSPublicIDHandles{ |
| store: map[int64]security.PublicID{}, |
| // Add adds a PublicID to the store and returns the handle to it. |
| func (s *JSPublicIDHandles) Add(identity security.PublicID) int64 { |
| s.store[handle] = identity |
| // Remove removes the PublicID associated with the handle. |
| func (s *JSPublicIDHandles) Remove(handle int64) { |
| // Get returns the PublicID represented by the handle. Returns nil |
| // if no PublicID exists for the handle. |
| func (s *JSPublicIDHandles) Get(handle int64) security.PublicID { |