Esempio n. 1
0
        public virtual baseResponse runAction(HttpContext context)
        {
            //In Release Mode we don't support request via HTTP-Get
            if (context.Request.HttpMethod == "GET")
            {
                throw new Exception("Sorry, GET is not allowed. Use POST instead.");
            }

            //Authenticate, if Required
            if (requiresAuthentication)
            {
                loginAction   login    = new loginAction();
                loginResponse response = (loginResponse)login.runAction(context);

                if (response.responseCode == responseCodes.Error)
                {
                    throw new Exception(string.Format("Authentication failed [{0}]", response.responseMessage));
                }

                if (requiresAdministrator && !response.userIsAdministrator)
                {
                    throw new Exception("An Administratoraccount is required in order to Perform this Action.");
                }

                userIsAdministrator = response.userIsAdministrator;
            }

            return(null);
        }
Esempio n. 2
0
		public virtual baseResponse runAction(HttpContext context) {

			//In Release Mode we don't support request via HTTP-Get
			if(context.Request.HttpMethod == "GET")
				throw new Exception("Sorry, GET is not allowed. Use POST instead.");

			//Authenticate, if Required
			if(requiresAuthentication) {
				loginAction login = new loginAction();
				loginResponse response = (loginResponse)login.runAction(context);

				if (response.responseCode == responseCodes.Error)
					throw new Exception(string.Format("Authentication failed [{0}]", response.responseMessage));

				if (requiresAdministrator && !response.userIsAdministrator)
					throw new Exception("An Administratoraccount is required in order to Perform this Action.");

				userIsAdministrator = response.userIsAdministrator;
			}

			return null;
		}
Esempio n. 3
0
		public void executeHandler() {

			if(!isRequestAuthorized()) {
				_context.Response.StatusCode = 403;
				return;
			}

			string action = _context.Request["action"];
			baseAction actionHandler = null;
			switch (action) {

					// Usermanagement
				case "login":
					actionHandler = new loginAction();
					break;
				case "addUser":
					actionHandler = new addUserAction();
					break;
				case "getUser":
					actionHandler = new getUserAction();
					break;
				case "editUser":
					actionHandler = new editUserAction();
					break;
				case "deleteUser":
					actionHandler = new deleteUserAction();
					break;

				//Projectmanagement
				case "getProjects":
					actionHandler = new getProjectsAction();
					break;
				case "getProject":
					actionHandler = new getProjectAction();
					break;
				case "addProject":
					actionHandler = new addProjectAction();
					break;
				case "deleteProject":
					actionHandler = new deleteProjectAction();
					break;
				case "editProject":
					actionHandler = new editProjectAction();
					break;

				//updateLog
				case "addLog":
					actionHandler = new addLogAction();
					break;
				case "addLogDebug":
					actionHandler = new addLogDebugAction();
					break;
				case "getLog":
					actionHandler = new getLogAction();
					break;
				case "cleanupLog":
					actionHandler = new cleanLogAction();
					break;
			}

			baseResponse response = actionHandler != null
			                        	? actionHandler.runAction(_context)
			                        	: new defaultResponse
			                        	  {responseCode = responseCodes.Error, responseMessage = "Invalid Action"};

			response.sendResponse(_context.Response);
			response.Dispose();
			if (actionHandler != null)
				actionHandler.Dispose();
			GC.Collect();
		}