1 Reply Latest reply on Aug 2, 2018 9:59 PM by patrick.byrne.0

    Trust Authentication Ticket

    Stan Lee

      Dear Sir,

      Would like to know how can we resolve the issue for version 10.4 for the Trusted Authentication Ticket, as per our checking, we are unable to get the ticket:

       

       

      My Code:

       

      <?php

      defined('BASEPATH') OR exit('No direct script access allowed');

       

       

      class Dashboard extends MY_Controller {

       

       

      var $template = array();

       

      public function __construct()

      {

      parent::__construct();

       

      $this->is_logged_in();

      if(empty($this->auth_user_id)){

      redirect('login');

      }

      if($this->auth_level < ACL_SALESPERSON) {

      redirect('access/admin_access_deny');

      }

       

      $this->load->model('setting_dashboard_category_model');

      }

       

       

      public function apims_dashboard($id = null){

      if(!in_array(APIMS, $this->session->userdata('USER_PERMISSION'))){

      redirect('access/admin_access_deny');

      }

       

      if(sizeof($data['detail'] = $this->setting_dashboard_category_model->get_detail_by_category_and_id(APIMS, $id)) == 0){

      show_404();

      }

       

      $data['detail']->url = empty($data['detail']->url)? '' : ((empty($data['detail']->user) || empty($data['detail']->server))? $data['detail']->url : $this->get_full_url($data['detail']));

      $this->template['title'] = 'Dashboard - APIMS';

      $this->template['content'] = $this->load->view('dashboard', $data, true);

      $this->load->view('template', $this->template);

      }

       

      public function ekas_dashboard($id = null){

      if(!in_array(EKAS, $this->session->userdata('USER_PERMISSION'))){

      redirect('access/admin_access_deny');

      }

       

      if(sizeof($data['detail'] = $this->setting_dashboard_category_model->get_detail_by_category_and_id(EKAS, $id)) == 0){

      show_404();

      }

       

      $data['detail']->url = empty($data['detail']->url)? '' : ((empty($data['detail']->user) || empty($data['detail']->server))? $data['detail']->url : $this->get_full_url($data['detail']));

      $this->template['title'] = 'Dashboard - eKAS';

      $this->template['content'] = $this->load->view('dashboard', $data, true);

      $this->load->view('template', $this->template);

      }

       

      public function cems_dashboard($id = null){

      if(!in_array(CEMS, $this->session->userdata('USER_PERMISSION'))){

      redirect('access/admin_access_deny');

      }

       

      if(sizeof($data['detail'] = $this->setting_dashboard_category_model->get_detail_by_category_and_id(CEMS, $id)) == 0){

      show_404();

      }

       

      $data['detail']->url = empty($data['detail']->url)? '' : ((empty($data['detail']->user) || empty($data['detail']->server))? $data['detail']->url : $this->get_full_url($data['detail']));

      $this->template['title'] = 'Dashboard - CEMS';

      $this->template['content'] = $this->load->view('dashboard', $data, true);

      $this->load->view('template', $this->template);

      }

       

      public function mobile_sources_dashboard($id = null){

      if(!in_array(MOBILE_SOURCES, $this->session->userdata('USER_PERMISSION'))){

      redirect('access/admin_access_deny');

      }

       

      if(sizeof($data['detail'] = $this->setting_dashboard_category_model->get_detail_by_category_and_id(MOBILE_SOURCES, $id)) == 0){

      show_404();

      }

       

      $data['detail']->url = empty($data['detail']->url)? '' : ((empty($data['detail']->user) || empty($data['detail']->server))? $data['detail']->url : $this->get_full_url($data['detail']));

      $this->template['title'] = 'Dashboard - Mobile Sources';

      $this->template['content'] = $this->load->view('dashboard', $data, true);

      $this->load->view('template', $this->template);

      }

       

      public function get_full_url($data = ''){

      if( $this->uri->uri_string() == 'dashboard/get_full_url'){           

      show_404();       

      }

       

      $token = $this->get_token($data);

      $parse = parse_url($data->url);

      log_message('error','---'.$parse['scheme'].'://'.$parse['host'].'/trusted/'.$token.''.$parse['path'].'?'.$parse['query'].'&:refresh=yes');

      return $parse['scheme'].'://'.$parse['host'].'/trusted/'.$token.''.$parse['path'].'?'.$parse['query'].'&:refresh=yes';

      }

       

      public function get_token($data){

      if( $this->uri->uri_string() == 'dashboard/get_token'){           

      show_404();       

      }

      /*

      $opts = array('https' =>

      array(

          'method'  => 'POST',

          'header'  => 'Content-type: application/x-www-form-urlencoded',

          'content' => 'username='.$data->user,

      //'cafile'  => '/opt/lampp/apache2/conf/adms.pem',

      //'verify_peer' => true,

      //'verify_peer_name' => true,

      'verify_peer' => false,

      'verify_peer_name' => false,

      )

      ); 

       

      $context  = stream_context_create($opts);

      $result = file_get_contents($data->server, false, $context);

       

       

      if ($result === false) {

      throw new Exception("Problem reading data from $url, $php_errormsg");

       

      }else{

      return $result;

      }    */

       

          $ch = curl_init();

          curl_setopt($ch, CURLOPT_HEADER, 0);

          curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));

          curl_setopt($ch, CURLOPT_URL, $data->server);

          curl_setopt($ch, CURLOPT_POST, 1);

          curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".$data->user);

          curl_setopt($ch, CURLOPT_SSLVERSION,3);

          curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);

          curl_setopt($ch, CURLOPT_CAINFO, "/opt/lampp/apache2/conf/visualnregovmy.crt");

          //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

          //curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);

          //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

          //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //2

      $result = curl_exec($ch);

          if($result === false){

      log_message('error','--'.curl_error($ch));

          }

          curl_close($ch);

      log_message('error','-----result '.$result);

          return $result;

       

       

       

       

      }

      }

       

       

      Anyway we can test it, as we log file does not create the token.

       

      Hope to get advice.

       

      Thank you,

       

      Regards,
      Stan Lee