示例#1
0
文件: acl.go 项目: kosmikko/go.sec
func (acl *ACL) LoadFrom(adpt adapter.ACLAdapter) error {
	ers, err := adpt.AllRecord()
	if err != nil {
		return err
	}
	for er := range ers {
		err := acl.Append(er.Type, er.SecureId, er.Operation, er.Target, er.Permit, er.Ctx, er.RunOnce)
		if err != nil {
			return err
		}
	}
	return nil
}
示例#2
0
文件: acl.go 项目: kosmikko/go.sec
func (acl *ACL) SaveTo(adpt adapter.ACLAdapter) error {
	acl.Lock()
	defer acl.Unlock()
	if err := adpt.Clear(); err != nil {
		return err
	}
	for _, v := range acl.entryCollection {
		for i, e := range v {
			if err := adpt.SaveEntry(i, e.Record()); err != nil {
				return err
			}
		}
	}
	return nil
}