Ejemplo n.º 1
0
func (l amRestful) getAM(request *restful.Request, response *restful.Response, userName string) *am.AmUserInfo {
	data, err := cr.GetPropertyData(userName, stc.AmPropertyName, l.st.UsersList)
	if err != nil {
		l.setError(response, http.StatusNotFound, err)
		return nil
	}
	return data.(*am.AmUserInfo)
}
Ejemplo n.º 2
0
func (p pwdRestful) getPwdData(request *restful.Request, response *restful.Response) *password.UserPwd {
	userName := request.PathParameter(userIdParam)
	data, err := cr.GetPropertyData(userName, stc.PwdPropertyName, p.st.UsersList)
	if err != nil {
		p.setError(response, http.StatusNotFound, err)
		return nil
	}
	return data.(*password.UserPwd)
}
Ejemplo n.º 3
0
func (o ocraRestful) getOcra(request *restful.Request, response *restful.Response) *ocra.UserOcra {
	userName := request.PathParameter(userIdParam)
	data, err := cr.GetPropertyData(userName, stc.OcraPropertyName, o.st.UsersList)
	if err != nil {
		o.setError(response, http.StatusNotFound, err)
		return nil
	}
	return data.(*ocra.UserOcra)
}
Ejemplo n.º 4
0
func (u otpRestful) getOtp(request *restful.Request, response *restful.Response) *otp.OtpUser {
	userName := request.PathParameter(userIdParam)
	data, err := cr.GetPropertyData(userName, stc.OtpPropertyName, u.st.UsersList)
	if err != nil {
		u.setError(response, http.StatusNotFound, err)
		return nil
	}
	return data.(*otp.OtpUser)
}
Ejemplo n.º 5
0
func (a *aclRestful) getResourceAclData(request *restful.Request, response *restful.Response) (*acl.Acl, *resource, error) {
	var aclInfo resource
	var aclData *acl.Acl

	aclInfo.UserName = request.PathParameter(entityNameParam)
	aclInfo.ResourceName = request.PathParameter(resourceNameParam)
	aclInfo.Permission = request.PathParameter(permissionParam)
	data, err := cr.GetPropertyData(aclInfo.ResourceName, stc.AclPropertyName, a.st.UsersList)
	if err != nil {
		return nil, &aclInfo, err
	}
	aclData, ok := data.(*acl.Acl)
	if ok == false {
		return nil, &aclInfo, fmt.Errorf("ACL for resource '%v' is not valid", aclInfo.ResourceName)
	}
	return aclData, &aclInfo, nil
}
Ejemplo n.º 6
0
func (a *aclRestful) getResourceAclData(request *restful.Request, response *restful.Response) (*acl.Acl, *resource, error) {
	var aclInfo resource
	var aclData *acl.Acl

	err := request.ReadEntity(&aclInfo)
	if err != nil {
		return nil, nil, err
	}
	data, err := cr.GetPropertyData(aclInfo.ResourceName, stc.AclPropertyName, a.st.UsersList)
	if err != nil {
		return nil, &aclInfo, err
	}
	aclData, ok := data.(*acl.Acl)
	if ok == false {
		return nil, &aclInfo, fmt.Errorf("ACL for resource '%v' is not valid", aclInfo.ResourceName)
	}
	return aclData, &aclInfo, nil
}