func (el EntityManager) getUser(name string) (*User, error) {
	e, exist := el.Users[name]
	if !exist {
		return nil, fmt.Errorf("%v '%v' is not in the entity list", userTypeStr, name)
	}
	return e, nil
}
Return the user from the EntityManager using the given user name
package entityManagement
import (
	"fmt"
	"strings"
	"reflect"
	"encoding/json"
	"sync"
	"github.com/ibm-security-innovation/libsecurity-go/accounts"
	defs "github.com/ibm-security-innovation/libsecurity-go/defs"
	logger "github.com/ibm-security-innovation/libsecurity-go/logger"
	ss "github.com/ibm-security-innovation/libsecurity-go/storage"
)
const (
	entityToken = "entity-"
)
var (
	protectedEntityManager = []string{defs.RootUserName, defs.AclAllEntryName}
	lock         sync.Mutex
	propertyLock sync.Mutex
	RemoveEntityFromAcl func(el1 interface{}, name string)
)
type Permission string
type uList map[string]*User
type gList map[string]*Group
type rList map[string]*Resource
type pList map[Permission]interface{}
type EntityManager struct {
	Users     uList
	Groups    gList
	Resources rList
	Permissions pList
}
func (el EntityManager) String() string {
	uArray := make([]string, 0, len(el.Users))
	gArray := make([]string, 0, len(el.Groups))
	rArray := make([]string, 0, len(el.Resources))
	for _, u := range el.Users {
		uArray = append(uArray, u.Name)
	}
	for _, g := range el.Groups {
		gArray = append(gArray, g.Name)
	}
	for _, r := range el.Resources {
		rArray = append(rArray, r.Name)
	}
	return fmt.Sprintf("Users list: %q, Groups list: %q, Resource list: %q", uArray, gArray, rArray)
}
func initList() *EntityManager {
	entityManager := &EntityManager{Users: make(uList), Groups: make(gList), Resources: make(rList), Permissions: make(pList)}
	for _, name := range protectedEntityManager {
		entityManager.AddUser(name)
	}
	return entityManager
}
func New() *EntityManager {
	return initList()
}
func (el *EntityManager) IsEntityInList(name string) bool {
	return el.isUserInList(name) || el.isGroupInList(name) || el.isResourceInList(name)
}
func (el *EntityManager) GetEntityAccount(name string, pwd []byte) (*accounts.AmUserInfo, error) {
	return el.GetEntityAccountHandler(name, pwd, defs.PasswordThrottlingMiliSec, defs.ThrottleMaxRandomMiliSec)
}
func (el *EntityManager) GetEntityAccountHandler(name string, pwd []byte, throttleMiliSec int64, randomThrottleMiliSec int64) (*accounts.AmUserInfo, error) {
	errStr := "entity name and password does not match"
	if el.IsEntityInList(name) == false {
		defs.TimingAttackSleep(throttleMiliSec, randomThrottleMiliSec)
		return nil, fmt.Errorf(errStr)
	}
	data, err := el.GetPropertyAttachedToEntity(name, defs.AmPropertyName)
	if err != nil {
		defs.TimingAttackSleep(throttleMiliSec, randomThrottleMiliSec)
		return nil, fmt.Errorf(errStr)
	}
	account := data.(*accounts.AmUserInfo)
	err = account.IsPasswordMatchHandler(pwd, throttleMiliSec, randomThrottleMiliSec)
	if err != nil {
		return nil, fmt.Errorf(errStr)
	}
	return account, nil
}
func (el *EntityManager) isNameValid(name string) error {
	err := IsEntityNameValid(name)
	if err != nil {
		return err
	}
	if el.IsEntityInList(name) {
		return fmt.Errorf("The name '%v' is already in the Entity list", name)
	}
	return nil
}
func (el *EntityManager) AddUser(name string) error {
	lock.Lock()
	defer lock.Unlock()
	err := el.isNameValid(name)
	if err != nil {
		return err
	}
	u, _ := newUser(name)
	el.Users[name] = u
	return nil
}
func (el *EntityManager) AddGroup(name string) error {
	lock.Lock()
	defer lock.Unlock()
	err := el.isNameValid(name)
	if err != nil {
		return err
	}
	g, _ := newGroup(name)
	el.Groups[name] = g
	return nil
}
func (el *EntityManager) AddResource(name string) error {
	lock.Lock()
	defer lock.Unlock()
	err := el.isNameValid(name)
	if err != nil {
		return err
	}
	r, _ := newResource(name)
	el.Resources[name] = r
	return nil
}
func (el *EntityManager) RemoveUser(name string) error {
	lock.Lock()
	defer lock.Unlock()
	for _, eName := range protectedEntityManager {
		if name == eName {
			return fmt.Errorf("%v '%v', cannot be removed because it is a protected name", userTypeStr, name)
		}
	}
	_, exist := el.Users[name]
	if exist == false {
		return fmt.Errorf("Cannot remove %v '%v', it is not part of the users in the entity list", userTypeStr, name)
	}
	for _, e := range el.Groups {
		e.removeUserFromGroup(name)
	}
	if RemoveEntityFromAcl != nil {
		RemoveEntityFromAcl(el, name)
	}
	delete(el.Users, name)
	return nil
}
func (el *EntityManager) RemoveGroup(name string) error {
	lock.Lock()
	defer lock.Unlock()
	_, exist := el.Groups[name]
	if exist == false {
		return fmt.Errorf("Cannot remove %v '%v', it is not part of the groups in the entity list", groupTypeStr, name)
	}
	if RemoveEntityFromAcl != nil {
		RemoveEntityFromAcl(el, name)
	}
	delete(el.Groups, name)
	return nil
}
func (el *EntityManager) RemoveResource(name string) error {
	lock.Lock()
	defer lock.Unlock()
	_, exist := el.Resources[name]
	if exist == false {
		return fmt.Errorf("Cannot remove %v '%v', it is not part of the resources in the entity list", resourceTypeStr, name)
	}
	delete(el.Resources, name)
	return nil
}