public function loginSubmit()
 {
     if (CommonUtilities::form_submitted()) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         try {
             if (WSIS::authenticate($username, $password)) {
                 if (in_array(Config::get('pga_config.wsis')['admin-role-name'], (array) WSIS::getUserRoles($username))) {
                     Session::put("admin", true);
                 }
                 CommonUtilities::store_id_in_session($username);
                 CommonUtilities::print_success_message('Login successful! You will be redirected to your home page shortly.');
                 Session::put("gateway_id", Config::get('pga_config.wsis')['gateway-id']);
                 //TODO::If this option is not safe, have to find a better method to send credentials to identity server on every connection.
                 Session::put("password", $_POST["password"]);
                 return Redirect::to("home");
             } else {
                 return Redirect::to("login")->with("invalid-credentials", true);
             }
         } catch (Exception $ex) {
             return Redirect::to("login")->with("invalid-credentials", true);
         }
     }
 }
 /**
  * Cancel the experiment with the given ID
  * @param $expId
  */
 public static function cancel_experiment($expId)
 {
     try {
         Airavata::terminateExperiment(Session::get('authz-token'), $expId, Config::get('pga_config.airavata')["gateway-id"]);
         CommonUtilities::print_success_message("Experiment canceled!");
     } catch (InvalidRequestException $ire) {
         CommonUtilities::print_error_message('<p>There was a problem canceling the experiment.
         Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>');
     } catch (ExperimentNotFoundException $enf) {
         CommonUtilities::print_error_message('<p>There was a problem canceling the experiment.
         Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>ExperimentNotFoundException: ' . $enf->getMessage() . '</p>');
     } catch (AiravataClientException $ace) {
         CommonUtilities::print_error_message('<p>There was a problem canceling the experiment.
         Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataClientException: ' . $ace->getMessage() . '</p>');
     } catch (AiravataSystemException $ase) {
         CommonUtilities::print_error_message('<p>There was a problem canceling the experiment.
         Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataSystemException: ' . $ase->getMessage() . '</p>');
     } catch (TTransportException $tte) {
         CommonUtilities::print_error_message('<p>There was a problem canceling the experiment.
         Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>TTransportException: ' . $tte->getMessage() . '</p>');
     } catch (Exception $e) {
         CommonUtilities::print_error_message('<p>There was a problem canceling the experiment.
         Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>Exception: ' . $e->getMessage() . '</p>');
     }
 }
 public function resetPasswordSubmit()
 {
     $rules = array("new_password" => "required|min:6", "confirm_new_password" => "required|same:new_password");
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to("reset-password")->withInput(Input::except('new_password', 'confirm)new_password'))->withErrors($validator);
     }
     $key = $_POST['key'];
     $username = $_POST['username'];
     $new_password = $_POST['new_password'];
     try {
         $result = WSIS::resetPassword($username, $new_password, $key);
         if ($result) {
             CommonUtilities::print_success_message("User password was reset successfully");
             return View::make("account/login");
         } else {
             CommonUtilities::print_error_message("Resetting user password operation failed");
             return View::make("account/home");
         }
     } catch (Exception $e) {
         CommonUtilities::print_error_message("Resetting user password operation failed");
         return View::make("account/home");
     }
 }
 public static function create_project()
 {
     $project = new Project();
     $project->owner = Session::get('username');
     $project->name = $_POST['project-name'];
     $project->description = $_POST['project-description'];
     $projectId = null;
     try {
         $projectId = Airavata::createProject(Session::get('authz-token'), Config::get('pga_config.airavata')['gateway-id'], $project);
         if ($projectId) {
             CommonUtilities::print_success_message("<p>Project {$_POST['project-name']} created!</p>" . '<p>You will be redirected to the summary page shortly, or you can
                 <a href="project/summary?projId=' . $projectId . '">go directly</a> to the project summary page.</p>');
         } else {
             CommonUtilities::print_error_message("Error creating project {$_POST['project-name']}!");
         }
     } catch (InvalidRequestException $ire) {
         CommonUtilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage());
     } catch (AiravataClientException $ace) {
         CommonUtilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage());
     } catch (AiravataSystemException $ase) {
         CommonUtilities::print_error_message('AiravataSystemException!<br><br>' . $ase->getMessage());
     }
     return $projectId;
 }