Пример #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)
}
Пример #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)
}
Пример #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)
}
Пример #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)
}
Пример #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
}
Пример #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
}