| // LoadIdentity reads a PrivateID from r, assuming that it was written using |
| func LoadIdentity(r io.Reader) (security.PrivateID, error) { |
| var id security.PrivateID |
| if err := vom.NewDecoder(base64.NewDecoder(base64.URLEncoding, r)).Decode(&id); err != nil { |
| // SaveIdentity writes a serialized form of a PrivateID to w, which can be |
| // recovered using LoadIdentity. |
| func SaveIdentity(w io.Writer, id security.PrivateID) error { |
| closer := base64.NewEncoder(base64.URLEncoding, w) |
| if err := vom.NewEncoder(closer).Encode(id); err != nil { |
| // Must close the base64 encoder to flush out any partially written blocks. |
| if err := closer.Close(); err != nil { |
| // LoadACL reads an ACL from the provided Reader containing a JSON encoded ACL. |
| func LoadACL(r io.Reader) (security.ACL, error) { |
| if err := json.NewDecoder(r).Decode(&acl); err != nil { |
| // SaveACL encodes an ACL in JSON format and writes it to the provided Writer. |
| func SaveACL(w io.Writer, acl security.ACL) error { |
| return json.NewEncoder(w).Encode(acl) |