예제 #1
0
        public virtual JsonResult GetRoles(string operationNumber, string auth, string username)
        {
            List <string> roleCollection = null;

            try
            {
                roleCollection = SecurityManagerProxy.GetRoles(username, operationNumber);

                return(Json(new
                {
                    CurrentUser = IDBContext.Current.UserLoginName,
                    roles = string.Join(", ", roleCollection.ToArray())
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new
                {
                    Error_Message = e.Message,
                    Error_StackTrace = e.StackTrace
                },
                            JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
        public virtual JsonResult PermissionsByUser(string operationNumber, string ticket)
        {
            try
            {
                Logger.GetLogger().WriteDebug("SecurityController", string.Format(
                                                  "Authenticating ticket: {0} In PermissionsByUser - Controller Method", ticket));

                if (string.IsNullOrEmpty(operationNumber) || string.IsNullOrEmpty(ticket))
                {
                    return(Json(string.Empty, JsonRequestBehavior.AllowGet));
                }

                var username = string.IsNullOrEmpty(IDBContext.Current.UserName) ?
                               string.Empty :
                               IDBContext.Current.UserName;

                var roles       = SecurityManagerProxy.GetRoles(ticket, operationNumber);
                var permissions = SecurityManagerProxy
                                  .GetPermissions(operationNumber, roles, username);

                return(Json(permissions, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Logger.GetLogger().WriteError(
                    "SecurityController",
                    string.Format(
                        "Error when getting permissions by user. Operation: {0} ticket: {1}",
                        operationNumber,
                        ticket),
                    e);
                return(Json(e.Message, JsonRequestBehavior.AllowGet));
            }
        }