X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=application%2Fcontrollers%2Ftest.php;h=3daefdeff95f02a9daea132ebe74a3257b3f1d03;hb=2881d1393f363efd3c5f0e9b58706e6e35e85717;hp=c1cc29cbb4fa2c3e0f2ce8b29b1710515dd20501;hpb=0bf49c6270a4166999d6e4c9bcff3f416e2f7eb6;p=living-lab-site.git diff --git a/application/controllers/test.php b/application/controllers/test.php index c1cc29c..3daefde 100644 --- a/application/controllers/test.php +++ b/application/controllers/test.php @@ -1,146 +1,155 @@ lang->load('openid', 'english'); - $this->load->library('openid'); - $this->load->helper('url'); - //$this->output->enable_profiler(TRUE); - } - - // Index - function index() - { - if ($this->input->post('action') == 'verify') - { - $user_id = $this->input->post('openid_identifier'); - $pape_policy_uris = $this->input->post('policies'); - - if (!$pape_policy_uris) - { - $pape_policy_uris = array(); - } - - $this->config->load('openid'); - $req = $this->config->item('openid_required'); - $opt = $this->config->item('openid_optional'); - $policy = site_url($this->config->item('openid_policy')); - $request_to = site_url($this->config->item('openid_request_to')); - - $this->openid->set_request_to($request_to); - $this->openid->set_trust_root(base_url()); - $this->openid->set_args(null); - $this->openid->set_sreg(true, $req, $opt, $policy); - $this->openid->set_pape(true, $pape_policy_uris); - $this->openid->authenticate($user_id); - } - - $data['pape_policy_uris'] = array( - PAPE_AUTH_MULTI_FACTOR_PHYSICAL, - PAPE_AUTH_MULTI_FACTOR, - PAPE_AUTH_PHISHING_RESISTANT - ); - - $this->load->view('view_openid', $data); - - } - - // Policy - function policy() - { - $this->load->view('view_policy'); - } - - // set message - function _set_message($msg, $val = '', $sub = '%s') - { - return str_replace($sub, $val, $this->lang->line($msg)); - } - - // Check - function check() - { - $this->config->load('openid'); - $request_to = site_url($this->config->item('openid_request_to')); - - $this->openid->set_request_to($request_to); - $response = $this->openid->getResponse(); - - switch ($response->status) - { - case Auth_OpenID_CANCEL: - $data['msg'] = $this->lang->line('openid_cancel'); - break; - case Auth_OpenID_FAILURE: - $data['error'] = $this->_set_message('openid_failure', $response->message); - break; - case Auth_OpenID_SUCCESS: - $openid = $response->getDisplayIdentifier(); - $esc_identity = htmlspecialchars($openid, ENT_QUOTES); - - $data['success'] = $this->_set_message('openid_success', array($esc_identity, $esc_identity), array('%s','%t')); - - if ($response->endpoint->canonicalID) { - $data['success'] .= $this->_set_message('openid_canonical', $response->endpoint->canonicalID); - } - - $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response); - $sreg = $sreg_resp->contents(); - - foreach ($sreg as $key => $value) - { - $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s','%t')); - } - - $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response); - - if ($pape_resp) - { - if ($pape_resp->auth_policies) - { - $data['success'] .= $this->lang->line('openid_pape_policies_affected'); - - foreach ($pape_resp->auth_policies as $uri) - { - $data['success'] .= "
  • $uri
  • "; - } - - $data['success'] .= ""; - } - else - { - $data['success'] .= $this->lang->line('openid_pape_not_affected'); - } - - if ($pape_resp->auth_age) - { - $data['success'] .= $this->_set_message('openid_auth_age', $pape_resp->auth_age); - } - - if ($pape_resp->nist_auth_level) - { - $data['success'] .= $this->_set_message('openid_nist_level', $pape_resp->nist_auth_level); - } - } - else - { - $data['success'] .= $this->lang->line('openid_pape_noresponse'); - } - break; - } - - $data['pape_policy_uris'] = array( - PAPE_AUTH_MULTI_FACTOR_PHYSICAL, - PAPE_AUTH_MULTI_FACTOR, - PAPE_AUTH_PHISHING_RESISTANT - ); - - $this->load->view('view_openid', $data); - } + function Test() + { + parent::__construct(); + + $this->lang->load('openid', 'english'); + $this->load->library('openid'); + $this->load->helper('url'); + //$this->output->enable_profiler(TRUE); + } + + // Index + function index() + { + if ($this->input->post('action') == 'verify') + { + $user_id = $this->input->post('openid_identifier'); + $pape_policy_uris = $this->input->post('policies'); + + if (!$pape_policy_uris) + { + $pape_policy_uris = array(); + } + + $this->config->load('openid'); + $req = $this->config->item('openid_required'); + $opt = $this->config->item('openid_optional'); + $policy = site_url($this->config->item('openid_policy')); + $request_to = site_url($this->config->item('openid_request_to')); + + $this->openid->set_request_to($request_to); + $this->openid->set_trust_root(base_url()); + $this->openid->set_args(null); + $this->openid->set_sreg(true, $req, $opt, $policy); + $this->openid->set_pape(true, $pape_policy_uris); + $this->openid->authenticate($user_id); + } + else + { + $data['pape_policy_uris'] = array( + PAPE_AUTH_MULTI_FACTOR_PHYSICAL, + PAPE_AUTH_MULTI_FACTOR, + PAPE_AUTH_PHISHING_RESISTANT + ); + + $this->load->view('view_openid', $data); + } + } + + // Policy + function policy() + { + $this->load->view('openid_policy_view'); + } + + // set message + function _set_message($msg, $val = '', $sub = '%s') + { + return str_replace($sub, $val, $this->lang->line($msg)); + } + + // Check + function check() + { + $this->config->load('openid'); + $request_to = site_url($this->config->item('openid_request_to')); + + $this->openid->set_request_to($request_to); + $response = $this->openid->getResponse(); + + switch ($response->status) + { + case Auth_OpenID_CANCEL: + $data['msg'] = $this->lang->line('openid_cancel'); + break; + case Auth_OpenID_FAILURE: + $data['error'] = $this->_set_message('openid_failure', $response->message); + break; + case Auth_OpenID_SUCCESS: + $openid = $response->getDisplayIdentifier(); + $esc_identity = htmlspecialchars($openid, ENT_QUOTES); + + $data['success'] = $this->_set_message('openid_success', array($esc_identity, $esc_identity), array('%s', '%t')); + + if ($response->endpoint->canonicalID) + { + $data['success'] .= $this->_set_message('openid_canonical', $response->endpoint->canonicalID); + } + + $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response); + $sreg = $sreg_resp->contents(); + + foreach ($sreg as $key => $value) + { + $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s', '%t')); + } + + $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response); + + if ($pape_resp) + { + if ($pape_resp->auth_policies) + { + $data['success'] .= $this->lang->line('openid_pape_policies_affected'); + + foreach ($pape_resp->auth_policies as $uri) + { + $data['success'] .= "
  • $uri
  • "; + } + + $data['success'] .= ""; + } + else + { + $data['success'] .= $this->lang->line('openid_pape_not_affected'); + } + + if (isset($pape_resp->auth_age) && $pape_resp->auth_age) + { + $data['success'] .= $this->_set_message('openid_auth_age', $pape_resp->auth_age); + } + + if ($pape_resp->nist_auth_level) + { + $data['success'] .= $this->_set_message('openid_nist_level', $pape_resp->nist_auth_level); + } + } + else + { + $data['success'] .= $this->lang->line('openid_pape_noresponse'); + } + break; + } + + $data['pape_policy_uris'] = array( + PAPE_AUTH_MULTI_FACTOR_PHYSICAL, + PAPE_AUTH_MULTI_FACTOR, + PAPE_AUTH_PHISHING_RESISTANT + ); + +// echo "nickname: $nickname"; +// echo "esc_identity: $esc_identity"; + + $this->load->view('view_openid', $data); + } } + ?>