func (u *AmUserInfo) UpdateUserPwd(userName string, currentPwd []byte, pwd []byte, checkPwdStrength bool) error {
	newPwd, err := u.Pwd.UpdatePassword(currentPwd, pwd, checkPwdStrength)
	if err != nil {
		return err
	}
	u.Pwd.Password = newPwd
	u.Pwd.Expiration = getPwdExpiration(userName)
	return nil
}
UpdateUserPwd : Update the AM property password to the given password and set the expiration time
The password will be updated only if the new password is valid and the curent password matches the given one
package accounts
import (
	"encoding/json"
	"fmt"
	"reflect"
	"sync"
	"strings"
	"time"
	defs "github.com/ibm-security-innovation/libsecurity-go/defs"
	"github.com/ibm-security-innovation/libsecurity-go/password"
	"github.com/ibm-security-innovation/libsecurity-go/salt"
	ss "github.com/ibm-security-innovation/libsecurity-go/storage"
)
const (
	SuperUserPermission = "Super-user"
	AdminPermission = "Admin"
	UserPermission = "User"
	rootPwdExpirationDays = 3550
	pwdExpirationDays     = 90
)
var (
	usersPrivilege UsersPrivilege
	lock sync.Mutex
)
type UsersPrivilege map[string]interface{}
func (u UsersPrivilege) String() string {
	pArray := make([]string, 0, len(u))
	for p := range u {
		pArray = append(pArray, fmt.Sprintf("'%v'", p))
	}
	return strings.Join(pArray, ",")
}
type AmUserInfo struct {
	Pwd       password.UserPwd
	Privilege string
}
type Serializer struct{}
func (u AmUserInfo) String() string {
	return fmt.Sprintf("Privilege: '%v', Password: %v", u.Privilege, u.Pwd)
}
func init() {
	usersPrivilege = make(UsersPrivilege)
	usersPrivilege[UserPermission] = ""
	usersPrivilege[SuperUserPermission] = ""
	usersPrivilege[AdminPermission] = ""
	defs.Serializers[defs.AmPropertyName] = &Serializer{}
}
func NewUserAm(privilege string, pass []byte, saltData []byte, checkPwdStrength bool) (*AmUserInfo, error) {
	err := IsValidPrivilege(privilege)
	if err != nil {
		return nil, err
	}
	userPwd, err := password.NewUserPwd(pass, saltData, checkPwdStrength)
	if err != nil {
		return nil, err
	}
	return &AmUserInfo{Pwd: *userPwd, Privilege: privilege}, nil
}
func IsValidPrivilege(privilege string) error {
	_, exist := usersPrivilege[privilege]
	if !exist {
		return fmt.Errorf("The user privilege '%v' is not legal, it must be one of %v",
			privilege, usersPrivilege)
	}
	return nil
}
func GetUsersPrivilege() UsersPrivilege {
	return usersPrivilege
}
func getPwdExpiration(id string) time.Time {
	if id != defs.RootUserName {
		return time.Now().Add(time.Hour * 24 * pwdExpirationDays)
	}
	return time.Now().Add(time.Hour * 24 * rootPwdExpirationDays)
}
func (u *AmUserInfo) UpdateUserPrivilege(privilege string) error {
	err := IsValidPrivilege(privilege)
	if err != nil {
		return err
	}
	u.Privilege = privilege
	return nil
}