From 0c96c46a27883599bf72e1837bef9a7842fee7f6 Mon Sep 17 00:00:00 2001 From: Yoann DAVID Date: Mon, 3 Feb 2014 21:33:23 +0100 Subject: [PATCH] Make attribute private + remove atribute (no more used, is used instead) + add getter and setter for + Yubico URLs set in constructor --- Yubico.php | 91 +++++++++++++++++++++++------------------------------- 1 file changed, 39 insertions(+), 52 deletions(-) diff --git a/Yubico.php b/Yubico.php index 71b5f72..dd660d2 100644 --- a/Yubico.php +++ b/Yubico.php @@ -42,55 +42,49 @@ class Auth_Yubico * Yubico client ID * @var string */ - var $_id; + private $_id; /** * Yubico client key * @var string */ - var $_key; - - /** - * URL part of validation server - * @var string - */ - var $_url; + private $_key; /** * List with URL part of validation servers * @var array */ - var $_url_list; + private $_url_list; /** * index to _url_list * @var int */ - var $_url_index; + private $_url_index; /** * Last query to server * @var string */ - var $_lastquery; + private $_lastquery; /** * Response from server * @var string */ - var $_response; + private $_response; /** * Flag whether to use https or not. * @var boolean */ - var $_https; + private $_https; /** * Flag whether to verify HTTPS server certificates or not. * @var boolean */ - var $_httpsverify; + private $_httpsverify; /** * Constructor @@ -110,35 +104,33 @@ function Auth_Yubico($id, $key = '', $https = 0, $httpsverify = 1) $this->_key = base64_decode($key); $this->_https = $https; $this->_httpsverify = $httpsverify; - } - - /** - * Specify to use a different URL part for verification. - * The default is "api.yubico.com/wsapi/verify". - * - * @param string $url New server URL part to use - * @access public - */ - function setURLpart($url) - { - $this->_url = $url; - } - - /** - * Get URL part to use for validation. - * - * @return string Server URL part - * @access public - */ - function getURLpart() - { - if ($this->_url) { - return $this->_url; - } else { - return "api.yubico.com/wsapi/verify"; - } - } - + $this->_url_list = array('api.yubico.com/wsapi/2.0/verify', + 'api2.yubico.com/wsapi/2.0/verify', + 'api3.yubico.com/wsapi/2.0/verify', + 'api4.yubico.com/wsapi/2.0/verify', + 'api5.yubico.com/wsapi/2.0/verify'); + } + + /** + * Specify to use a different URL part list for verification. + * The default is "api[2-5]?.yubico.com/wsapi/2.0/verify". + * + * @param array $url_list New server URL part list to use + * @access public + */ + function setURLpartList(array $url_list) { + $this->_url_list = $url_list; + } + + /** + * Get URL part list to use for validation. + * + * @return string Server URL part list + * @access public + */ + function getURLpartList() { + return $this->_url_list; + } /** * Get next URL part from list to use for validation. @@ -148,15 +140,10 @@ function getURLpart() */ function getNextURLpart() { - if ($this->_url_list) $url_list=$this->_url_list; - else $url_list=array('api.yubico.com/wsapi/2.0/verify', - 'api2.yubico.com/wsapi/2.0/verify', - 'api3.yubico.com/wsapi/2.0/verify', - 'api4.yubico.com/wsapi/2.0/verify', - 'api5.yubico.com/wsapi/2.0/verify'); - - if ($this->_url_index>=count($url_list)) return false; - else return $url_list[$this->_url_index++]; + if ($this->_url_index >= count($this->_url_list)) + return false; + else + return $this->_url_list[$this->_url_index++]; } /**