public function __construct()
 {
     $config_datas = $this->parseCredentialConfig(CREDENTIAL_PATH);
     foreach ($config_datas as $key => $value) {
         $credential = new Credential();
         $credential->setDescription($value["description"]);
         $credential->setCred_id($value["cred_id"]);
         $credential->setType($value["type"]);
         $credential->setSecret_file($value["secret_file"]);
         $this->credentails[$key] = $credential;
     }
     //print_r($this->credentails);
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Credential::create([]);
     }
 }
 /**
  * @return string
  */
 public function generateSignature()
 {
     $dateKey = hash_hmac('sha256', $this->credential->getDate(), 'AWS4' . $this->secret, true);
     $dateRegionKey = hash_hmac('sha256', $this->credential->getRegion(), $dateKey, true);
     $dateRegionServiceKey = hash_hmac('sha256', $this->credential->getService(), $dateRegionKey, true);
     $signingKey = hash_hmac('sha256', $this->credential->getRequestType(), $dateRegionServiceKey, true);
     $signature = hash_hmac('sha256', $this->getBase64EncodedPolicy(), $signingKey);
     return $signature;
 }
 /**
  * @param Host $_host
  * @param string $_database
  * @param Credential $_credential
  * @param Logger $_logger
  */
 function __construct(Host $_host, $_database, Credential $_credential, Logger $_logger = null)
 {
     $this->logger = $_logger;
     $this->connection = mysql_connect($_host->getHost(), $_credential->getUsername(), $_credential->getPassword(), true);
     if (!$this->connection) {
         throw new DatabaseException(mysql_error($this->connection));
     }
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('mysql_connect: ' . $_host->getHost());
     }
     $selected = mysql_select_db($_database, $this->connection);
     if (!$selected) {
         throw new DatabaseException(mysql_error($this->connection));
     }
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('mysql_select_db: ' . $_database);
     }
 }
Exemple #5
0
 /**
  * Remove the specified resource from storage.
  * DELETE /users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // Delete everything related to the user
     Task::where('user_id', Auth::id())->delete();
     Credential::where('user_id', Auth::id())->delete();
     Project::where('user_id', Auth::id())->delete();
     Client::where('user_id', Auth::id())->delete();
     User::where('id', Auth::id())->delete();
     // Logout and redirect back to home page
     Auth::logout();
     return Redirect::to('/');
 }
Exemple #6
0
 public function testCredential()
 {
     $credential = new Credential("accessKeyId", "accessSecret");
     $this->assertEquals("accessKeyId", $credential->getAccessKeyId());
     $this->assertEquals("accessSecret", $credential->getAccessSecret());
     $this->assertNotNull($credential->getRefreshDate());
     $dateNow = gmdate('Y-m-d\\TH:i:s\\Z');
     $credential->setExpiredDate(1);
     $this->assertNotNull($credential->getExpiredDate());
     $this->assertTrue($credential->getExpiredDate() > $dateNow);
 }
Exemple #7
0
 /**     
  * Default constructor for ReportExecutionService.
  * @param Credential $credentials Object holding user credentials.
  * @param string $url Url of Report Server.
  */
 public function SSRSReport($credentials, $url, $proxy = null)
 {
     $this->_BaseUrl = $url[strlen($url) - 1] == '/' ? $url : $url . '/';
     $executionServiceUrl = $this->_BaseUrl . self::ExecutionService;
     $managementServiceUrl = $this->_BaseUrl . self::ManagementService;
     $options = $credentials->getCredentails();
     $stream_conext_params = array('http' => array('header' => array($credentials->getBase64Auth())));
     if (isset($proxy)) {
         $options = array_merge($options, $proxy->getProxy());
         $stream_conext_params['http']['proxy'] = 'tcp://' . $proxy->getHost() . ':' . $proxy->getPort();
         if ($proxy->getLogin() != null) {
             $stream_conext_params['http']['header'][1] = $proxy->getBase64Auth();
         }
     }
     /**
      * If the SoapClient call fails, we cannot catch exception or supress warning
      * since it throws php fatal exception.
      * http://bugs.php.net/bug.php?id=34657
      * So try to load the wsdl by
      * calling file_get_contents (with warning supressed i.e. using @ symbol
      * infront of the function call)
      * http://stackoverflow.com/questions/272361/how-can-i-handle-the-warning-of-filegetcontents-function-in-php
      */
     $context = stream_context_create($stream_conext_params);
     $content = @file_get_contents($executionServiceUrl, false, $context);
     if ($content === FALSE) {
         throw new SSRSReportException("", "Failed to connect to Reporting Service  <br/> Make sure " . "that the url ({$this->_BaseUrl}) and credentials are correct!");
     }
     $this->_soapHandle_Exe = new SoapClient($executionServiceUrl, $options);
     $this->_soapHandle_Mgt = new SoapClient($managementServiceUrl, $options);
     $this->ClearRequest();
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /credentials/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Credential::find($id)->delete();
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /projects/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $pTitle = "Projects";
     $project = Project::find(Input::get("id"));
     // delete everything associated with project
     Task::where('project_id', Input::get("id"))->delete();
     Credential::where('project_id', Input::get("id"))->delete();
     $project->members()->detach();
     // delete the project
     $project->delete();
     $counter = 0;
     $user = User::find(Auth::id());
     $projects = $user->projects()->get();
     $inProjects = $user->inProjects()->orderBy('created_at', 'desc')->take(5)->get();
     return View::make('projects.index', compact(['projects', 'counter', 'inProjects', 'pTitle']));
 }
Exemple #10
0
 public function reset()
 {
     self::$consumer = null;
     self::$requestStatus = null;
 }
 /**
  *  Delete credentials from DB
  *
  *	On error this method returning FALSE.
  *
  *  Possible options:
  *	 - none
  *
  *	@param	string		$uid
  *	@param	string		$did
  *	@param	string		$uname
  *	@param	string		$realm
  *	@param	Credential	$new_vals
  *	@param	array		$opt
  *	@return bool
  */
 function update_credentials($uid, $did, $uname, $realm, $new_vals, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table name */
     $t_name =& $config->data_sql->credentials->table_name;
     /* col names */
     $c =& $config->data_sql->credentials->cols;
     /* flags */
     $f =& $config->data_sql->credentials->flag_values;
     $set = array();
     if ($new_vals->did_changed()) {
         $set[] = $c->did . " = " . $this->sql_format($new_vals->get_did(), "s");
     }
     if ($new_vals->uname_changed()) {
         $set[] = $c->uname . " = " . $this->sql_format($new_vals->get_uname(), "s");
     }
     if ($new_vals->realm_changed()) {
         $set[] = $c->realm . " = " . $this->sql_format($new_vals->get_realm(), "s");
     }
     if ($new_vals->password_changed()) {
         if ($config->clear_text_pw) {
             $set[] = $c->password . " = " . $this->sql_format($new_vals->get_password(), "s");
         } else {
             $set[] = $c->password . " = " . $this->sql_format("", "s");
         }
     }
     if ($new_vals->ha1_changed()) {
         $set[] = $c->ha1 . " = " . $this->sql_format($new_vals->get_ha1(), "s");
         $set[] = $c->ha1b . " = " . $this->sql_format($new_vals->get_ha1b(), "s");
     }
     if ($new_vals->flags_changed()) {
         $set[] = $c->flags . " = " . $this->sql_format($new_vals->get_flags(), "s");
     }
     if (!count($set)) {
         return true;
     }
     // nothing to change
     $q = "update " . $t_name . "\n\t\t\t  set\t" . implode(", ", $set) . "\n\t\t      where " . $c->uid . "   = " . $this->sql_format($uid, "s") . " and\n\t\t            " . $c->uname . " = " . $this->sql_format($uname, "s") . " and\n\t\t            " . $c->realm . " = " . $this->sql_format($realm, "s");
     if ($config->auth['use_did']) {
         $q .= " and " . $c->did . " = " . $this->sql_format($did, "s");
     }
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     return true;
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /clients/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $pTitle = "Clients";
     $c_id = Input::get('id');
     $client = Client::find($c_id);
     // delete all related tasks and credentials
     foreach ($client->projects as $p) {
         Task::where('project_id', $p->id)->delete();
         Credential::where('project_id', $p->id)->delete();
         $p->members()->detach();
     }
     // delete related projects
     Project::where("client_id", $c_id)->delete();
     // delete client
     $client->delete();
     // ----------------------------------------------------
     $user = User::find(Auth::id());
     $clients = $user->clients()->orderBy('created_at', 'desc')->get();
     $counter = 0;
     return View::make('clients.index', compact(['clients', 'counter', 'pTitle']));
 }
Exemple #13
0
 public function getShow($id)
 {
     $user = $this->user->findOrFail($id);
     // $userid = Sentry::getUser()->id;
     // var_dump($userid); die();
     $userid = User::findOrFail($id)->id;
     $useremail = User::findOrFail($id)->email;
     // var_dump($userid); die();
     $galleries = Gallery::where('user_id', '=', $userid)->get();
     $credentials = Credential::where('user_id', '=', $userid)->get();
     $reviews = Review::where('to', '=', $useremail)->get();
     // $services =
     // $user = sentry::getUser();
     // var_dump($user); die('here');
     // $user = Sentry::findUserById($id);
     // if(All::checkViewRight($user)):
     // 	return All::checkViewRight($user);
     // endif;
     // return $galleries; die();
     // return $reviews; die('jere');
     return View::make('users.show', compact('user', 'galleries', 'reviews'));
     // return View::make('users.show', compact('user'));
 }
 public function setnewpasswordAction()
 {
     if ($this->request->isPost()) {
         $uniq = $this->request->getPost("uniq");
         $url = Tmprecoverpassword::findFirst(array('conditions' => 'idTmprecoverpassword = ?1', 'bind' => array(1 => $uniq)));
         $time = strtotime("-30 minutes");
         if (!$url && $url->date <= $time) {
             $this->flashSession->success('El tiempo para recuperar su contraseña, ha caducado, por favor haga el proceso desde cero');
             return $this->response->redirect('session/login');
         }
         $password1 = $this->request->getPost("password1");
         $password2 = $this->request->getPost("password2");
         if (empty($password1) || empty($password2)) {
             $this->flashSession->error("No has enviado las contraseñas");
             return $this->response->redirect('session/resetpassword/' . $uniq);
         }
         if (strlen($password1) < 8 || strlen($password2) > 40) {
             $this->flashSession->error("La contraseña es muy corta o muy larga, esta debe tener mínimo 8 y máximo 40 caracteres, por favor verifique la información");
             return $this->response->redirect('session/resetpassword/' . $uniq);
         }
         if ($password1 !== $password2) {
             $this->flashSession->error("Las contraseñas no coinciden, por favor verifique la información");
             return $this->response->redirect('session/resetpassword/' . $uniq);
         }
         $idUser = $this->session->get('idUser');
         $credential = Credential::findFirst(array('conditions' => 'idUser = ?1', 'bind' => array(1 => $idUser)));
         if (!$credential) {
             $this->flashSession->error("No existe el usuario, por favor valida la información");
             return $this->response->redirect('session/login');
         }
         $credential->password = $this->hash->hash($password1);
         if (!$credential->save()) {
             $this->flashSession->notice('Ha ocurrido un error, contacte con el administrador');
             foreach ($user->getMessages() as $msg) {
                 $this->logger->log('Error while recovering user password' . $msg);
             }
         }
         $this->flashSession->notice('Se ha actualizado el usuario exitosamente');
         return $this->response->redirect('session/login');
     }
 }