Beispiel #1
0
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
}
Beispiel #2
0
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
}