当前位置: 首页>>代码示例>>PHP>>正文


PHP phpCAS::setCasServerCACert方法代码示例

本文整理汇总了PHP中phpCAS::setCasServerCACert方法的典型用法代码示例。如果您正苦于以下问题:PHP phpCAS::setCasServerCACert方法的具体用法?PHP phpCAS::setCasServerCACert怎么用?PHP phpCAS::setCasServerCACert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpCAS的用法示例。


在下文中一共展示了phpCAS::setCasServerCACert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_cas_result

function check_cas_result($config)
{
    require_once dirname(__DIR__) . '/vendor/autoload.php';
    try {
        $cas_version = $config->cas_version ? $config->cas_version : CAS_VERSION_2_0;
        // phpCAS::setDebug();
        phpCAS::client($cas_version, $config->cashostname, (int) $config->casport, $config->casbaseuri, false);
        // don't automatically clear tickets from the url, we're taking care of that
        phpCAS::setNoClearTicketsFromUrl();
        // if a certificate is provided, use it, otherwise don't
        if ($config->cas_server_ca_cert_path != "") {
            // here we sould set the server certificate for production
            // '/etc/pki/tls/certs/DigiCertCA.crt'
            phpCAS::setCasServerCACert($config->cas_server_ca_cert_path);
        } else {
            // if you want to skip ssl verification
            if ($config->cas_server_no_validation) {
                phpCAS::setNoCasServerValidation();
            }
        }
        // check authentication; returns true/false
        if (phpCAS::checkAuthentication()) {
            // grab username
            $NetUsername = phpCAS::getUser();
            return $NetUsername;
        } else {
            return false;
        }
    } catch (Exception $e) {
        error_log("CAS ERROR: " . $e->getMessage());
        register_error($e->getMessage());
        return false;
    }
}
开发者ID:AU-Landing-Project,项目名称:au_cas_auth,代码行数:34,代码来源:functions.php

示例2: __construct

 public function __construct()
 {
     // These are default values for the first login and should be changed via GUI
     $CAS_HOSTNAME = 'your.domain.org';
     $CAS_PORT = '443';
     $CAS_PATH = '/cas';
     $this->autocreate = OCP\Config::getAppValue('user_cas', 'cas_autocreate', true);
     $this->updateUserData = OCP\Config::getAppValue('user_cas', 'cas_update_user_data', true);
     $this->defaultGroup = OCP\Config::getAppValue('user_cas', 'cas_default_group', '');
     $this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
     $this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
     $this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
     $this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
     $casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
     $casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $CAS_HOSTNAME);
     $casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', $CAS_PORT);
     $casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', $CAS_PATH);
     $casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
     global $initialized_cas;
     if (!$initialized_cas) {
         phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
         if (!empty($casCertPath)) {
             phpCAS::setCasServerCACert($casCertPath);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         $initialized_cas = true;
     }
 }
开发者ID:anolisti,项目名称:apps,代码行数:29,代码来源:user_cas.php

示例3: init

 /**
  * Initialize the class, this must be called before anything else
  * @param $config
  * @param bool $changeSessionID Allow phpCAS to change the session_id (Single Sign Out/handleLogoutRequests is based on that change)
  * @param $debugLog Set to a path to enable debug log
  */
 public static function init($config, $changeSessionID = true, $debugLog = null)
 {
     if ($debugLog != null) {
         phpCAS::setDebug($debugLog);
     }
     phpCAS::client(CAS_VERSION_2_0, $config['site'], $config['port'], "cas", $changeSessionID);
     self::$config = $config;
     $private_key = null;
     if (isset($config['private_key'])) {
         $key = static::resolve_filename($config['private_key']);
         $private_key = openssl_get_privatekey("file:///{$key}");
         if ($private_key === false) {
             throw new NXAuthError("Failed to open private key {$key}");
         }
     }
     if (isset($config['ca_cert']) && $config['ca_cert'] != null) {
         self::$ca_cert = static::resolve_filename($config['ca_cert']);
         phpCAS::setCasServerCACert(self::$ca_cert);
     } else {
         phpCAS::setNoCasServerValidation();
         // Disable curl ssl verification
         phpCAS::setExtraCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
         phpCAS::setExtraCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
     }
     NXAPI::init(array('private_key' => $private_key, 'key_id' => $config['key_id'], 'url' => "https://" . $config['site'], 'ca_cert' => self::$ca_cert));
 }
开发者ID:nitroxy,项目名称:nxauth,代码行数:32,代码来源:NXAuth.php

示例4: initialized_php_cas

 public static function initialized_php_cas()
 {
     if (!self::$_initialized_php_cas) {
         $casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
         $casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $_SERVER['SERVER_NAME']);
         $casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', 443);
         $casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', '/cas');
         $casDebugFile = OCP\Config::getAppValue('user_cas', 'cas_debug_file', '');
         $casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
         $php_cas_path = OCP\Config::getAppValue('user_cas', 'cas_php_cas_path', 'CAS.php');
         if (!class_exists('phpCAS')) {
             if (empty($php_cas_path)) {
                 $php_cas_path = 'CAS.php';
             }
             OC_Log::write('cas', "Try to load phpCAS library ({$php_cas_path})", OC_Log::DEBUG);
             include_once $php_cas_path;
             if (!class_exists('phpCAS')) {
                 OC_Log::write('cas', 'Fail to load phpCAS library !', OC_Log::ERROR);
                 return false;
             }
         }
         if ($casDebugFile !== '') {
             phpCAS::setDebug($casDebugFile);
         }
         phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
         if (!empty($casCertPath)) {
             phpCAS::setCasServerCACert($casCertPath);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         self::$_initialized_php_cas = true;
     }
     return self::$_initialized_php_cas;
 }
开发者ID:GIP-RECIA,项目名称:user_cas,代码行数:34,代码来源:user_cas.php

示例5: init_cas_client

 private function init_cas_client()
 {
     if (class_exists('phpCAS')) {
         return true;
     }
     require getConfig('casldap_phpcas_path');
     $cas_debug_file = getConfig('cas_debug_file_path');
     if (!empty($cas_debug_file)) {
         phpCAS::setDebug($cas_debug_file);
     }
     $cas_host = getConfig('cas_host');
     $cas_port = getConfig('cas_port') or 443;
     $cas_context = getConfig('cas_context');
     switch (getConfig('cas_version')) {
         case 1:
             $cas_version = CAS_VERSION_1_0;
             break;
         case 2:
             $cas_version = CAS_VERSION_2_0;
             break;
         case 3:
             $cas_version = CAS_VERSION_3_0;
             break;
         default:
             $cas_version = CAS_VERSION_2_0;
             break;
     }
     phpCAS::client($cas_version, $cas_host, intval($cas_port), $cas_context);
     $cas_server_ca_cert_path = getConfig('cas_server_ca_cert_path');
     if ($cas_server_ca_cert_path) {
         phpCAS::setCasServerCACert($cas_server_ca_cert_path);
     } else {
         phpCAS::setNoCasServerValidation();
     }
 }
开发者ID:brenard,项目名称:phplist-casldap-plugin,代码行数:35,代码来源:CASLdapPlugin.php

示例6: __construct

 public function __construct(ComponentCollection $collection, $settings)
 {
     $this->settings['host'] = 'cas.ucdavis.edu';
     $this->settings['context'] = '/cas';
     $this->settings['port'] = 443;
     $this->settings['ca_cert_path'] = '/usr/share/ca-certificates/mozilla/AddTrust_External_Root.crt';
     phpCAS::client(CAS_VERSION_2_0, $this->settings['host'], $this->settings['port'], $this->settings['context']);
     phpCAS::setCasServerCACert($this->settings['ca_cert_path']);
     parent::__construct($collection, $settings);
 }
开发者ID:mbp-informatics,项目名称:payments.mousebiology.org,代码行数:10,代码来源:CasAuthenticate.php

示例7: initPhpCAS

function initPhpCAS($host, $port, $context, $CA_certificate_file)
{
    phpCAS::client(SAML_VERSION_1_1, $host, intval($port), $context, false);
    if ($CA_certificate_file) {
        phpCAS::setCasServerCACert($CA_certificate_file);
    } else {
        phpCAS::setNoCasServerValidation();
    }
    //phpCAS::setLang(PHPCAS_LANG_FRENCH);
}
开发者ID:prigaux,项目名称:bandeau-ENT,代码行数:10,代码来源:bandeau-ENT-js.php

示例8: assignConfiguration

 /**
  * Stores the configuration. Calls the parent configuration first,
  * then does additional operations.
  *
  * @param object Properties $configuration
  * @return object
  * @access public
  * @since 3/24/05
  */
 function assignConfiguration(Properties $configuration)
 {
     parent::assignConfiguration($configuration);
     $format = $configuration->getProperty('DISPLAY_NAME_FORMAT');
     ArgumentValidator::validate($format, RegexValidatorRule::getRule('/\\[\\[([^]]+)\\]\\]/'));
     $this->displayNameFormat = $format;
     if ($debug = $configuration->getProperty('CAS_DEBUG_PATH')) {
         ArgumentValidator::validate($debug, StringValidatorRule::getRule());
         phpCAS::setDebug($debug);
     }
     $host = $configuration->getProperty('CAS_HOST');
     ArgumentValidator::validate($host, RegexValidatorRule::getRule('/^[a-z0-9]+\\.[a-z0-9]+.[a-z]+$/'));
     $port = $configuration->getProperty('CAS_PORT');
     ArgumentValidator::validate($port, RegexValidatorRule::getRule('/^[0-9]+$/'));
     $path = $configuration->getProperty('CAS_PATH');
     ArgumentValidator::validate($path, RegexValidatorRule::getRule('/^\\/.*$/'));
     phpCAS::client(CAS_VERSION_2_0, $host, intval($port), $path, false);
     if ($cert = $configuration->getProperty('CAS_CERT')) {
         phpCAS::setCasServerCACert($cert);
     } else {
         phpCAS::setNoCasServerValidation();
     }
     // Allow group lookup via a CASDirectory:
     // https://mediawiki.middlebury.edu/wiki/LIS/CAS_Directory
     $dirUrl = $configuration->getProperty('CASDIRECTORY_BASE_URL');
     ArgumentValidator::validate($dirUrl, StringValidatorRule::getRule());
     $this->directoryUrl = $dirUrl;
     // set the callback URL for the PGT to be sent to. This must be an https url
     // whose certificate is trusted by CAS.
     // 		$callbackUrl = $configuration->getProperty('CALLBACK_URL');
     // 		ArgumentValidator::validate($callbackUrl, RegexValidatorRule::getRule('/^https:\/\/.*$/'));
     // 		phpCAS::setFixedCallbackURL($callbackUrl);
     $adminAccess = $configuration->getProperty('CASDIRECTORY_ADMIN_ACCESS');
     ArgumentValidator::validate($adminAccess, StringValidatorRule::getRule());
     $this->adminAccess = $adminAccess;
     $classRoot = $configuration->getProperty('CASDIRECTORY_CLASS_ROOT');
     if ($classRoot) {
         ArgumentValidator::validate($classRoot, StringValidatorRule::getRule());
         $this->classRoot = $classRoot;
     } else {
         $this->classRoot = null;
     }
     $groupIdRegex = $configuration->getProperty('CASDIRECTORY_GROUP_ID_REGEX');
     if ($groupIdRegex) {
         ArgumentValidator::validate($groupIdRegex, StringValidatorRule::getRule());
         $this->groupIdRegex = $groupIdRegex;
     } else {
         $this->groupIdRegex = null;
     }
     // Root Groups to expose
     ArgumentValidator::validate($configuration->getProperty('ROOT_GROUPS'), ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     $this->rootGroups = array_unique($configuration->getProperty('ROOT_GROUPS'));
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:62,代码来源:CASAuthNMethod.class.php

示例9: setCASSettings

 private function setCASSettings()
 {
     if ($this->options->IsCasDebugOn()) {
         phpCAS::setDebug($this->options->DebugFile());
     }
     phpCAS::client($this->options->CasVersion(), $this->options->HostName(), $this->options->Port(), $this->options->ServerUri(), $this->options->ChangeSessionId());
     if ($this->options->CasHandlesLogouts()) {
         phpCAS::handleLogoutRequests(true, $this->options->LogoutServers());
     }
     if ($this->options->HasCertificate()) {
         phpCAS::setCasServerCACert($this->options->Certificate());
     }
     phpCAS::setNoCasServerValidation();
 }
开发者ID:hugutux,项目名称:booked,代码行数:14,代码来源:CAS.php

示例10: __construct

 function __construct()
 {
     if (!self::$initialized) {
         global $cas_cfg;
         phpCAS::client(CAS_VERSION_2_0, $cas_cfg['host'], $cas_cfg['port'], $cas_cfg['context']);
         // Perform SSL validation only if server_ca_cert path is provided.
         if (isset($cas_cfg['server_ca_cert'])) {
             phpCAS::setCasServerCACert($cas_cfg['server_ca_cert']);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         self::$initialized = true;
     }
 }
开发者ID:rahulnht,项目名称:felicity16-website,代码行数:14,代码来源:cas_lib.php

示例11: __construct

 function __construct($collection, $settings)
 {
     $this->_Collection = $collection;
     if (Configure::read('CAS.debug_log_enabled')) {
         phpCAS::setDebug(TMP . 'phpCas.log.txt');
     }
     phpCAS::client(CAS_VERSION_2_0, Configure::read('CAS.hostname'), Configure::read('CAS.port'), Configure::read('CAS.uri'));
     $certServer = Configure::read('CAS.cert_path');
     if (empty($certServer)) {
         phpCAS::setNoCasServerValidation();
     } else {
         phpCAS::setCasServerCACert($certServer);
     }
 }
开发者ID:byu-oit-appdev,项目名称:eamWS,代码行数:14,代码来源:CasAuthenticate.php

示例12: __construct

 function __construct()
 {
     if (!self::$initialized) {
         global $cas_cfg;
         phpCAS::client(CAS_VERSION_2_0, $cas_cfg['host'], $cas_cfg['port'], $cas_cfg['context']);
         // Perform SSL validation only if server_ca_cert path is provided.
         if (isset($cas_cfg['server_ca_cert'])) {
             phpCAS::setCasServerCACert($cas_cfg['server_ca_cert']);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         setcookie('org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE', explode('_', setlocale(LC_ALL, '0'))[0], 0, '/');
         self::$initialized = true;
     }
 }
开发者ID:hharchani,项目名称:felicity16-website,代码行数:15,代码来源:cas_lib.php

示例13: init

 /**
  * Initializes the authority objects based on an associative array of arguments
  * @param array $args an associate array of arguments. The argument list is dependent on the authority
  *
  * General - Required keys:
  *   TITLE => The human readable title of the AuthorityImage
  *   INDEX => The tag used to identify this authority @see AuthenticationAuthority::getAuthenticationAuthority
  *
  * General - Optional keys:
  *   LOGGEDIN_IMAGE_URL => a url to an image/badge that is placed next to the user name when logged in
  *
  * CAS - Required keys:
  *   CAS_PROTOCOL => The protocol to use. Should be equivalent to one of the phpCAS constants, e.g. "2.0":
  *                   CAS_VERSION_1_0 => '1.0', CAS_VERSION_2_0 => '2.0', SAML_VERSION_1_1 => 'S1'
  *   CAS_HOST => The host name of the CAS server, e.g. "cas.example.edu"
  *   CAS_PORT => The port the CAS server is listening on, e.g. "443"
  *   CAS_PATH => The path of the CAS application, e.g. "/cas/"
  *   CAS_CA_CERT => The filesystem path to a CA certificate that will be used to validate the authenticity
  *                  of the CAS server, e.g. "/etc/tls/pki/certs/my_ca_cert.crt". If empty, no certificate
  *                  validation will be performed (not recommended for production).
  *
  * CAS - Optional keys:
  *   ATTRA_EMAIL => Attribute name for the user's email adress, e.g. "email". This only applies if your 
  *                  CAS server returns attributes in a SAML-1.1 or CAS-2.0 response.
  *   ATTRA_FIRST_NAME => Attribute name for the user's first name, e.g. "givename". This only applies if your 
  *                       CAS server returns attributes in a SAML-1.1 or CAS-2.0 response.
  *   ATTRA_LAST_NAME => Attribute name for the user's last name, e.g. "surname". This only applies if your 
  *                      CAS server returns attributes in a SAML-1.1 or CAS-2.0 response.
  *   ATTRA_FULL_NAME => Attribute name for the user's full name, e.g. "displayname". This only applies if your 
  *                      CAS server returns attributes in a SAML-1.1 or CAS-2.0 response.
  *   ATTRA_MEMBER_OF => Attribute name for the user's groups, e.g. "memberof". This only applies if your 
  *                      CAS server returns attributes in a SAML-1.1 or CAS-2.0 response.
  *
  * NOTE: Any subclass MUST call parent::init($args) to ensure proper operation
  *
  */
 public function init($args)
 {
     parent::init($args);
     // include the PHPCAS library
     if (empty($args['CAS_PHPCAS_PATH'])) {
         require_once 'CAS.php';
     } else {
         require_once $args['CAS_PHPCAS_PATH'] . '/CAS.php';
     }
     if (empty($args['CAS_PROTOCOL'])) {
         throw new KurogoConfigurationException('CAS_PROTOCOL value not set for ' . $this->AuthorityTitle);
     }
     if (empty($args['CAS_HOST'])) {
         throw new KurogoConfigurationException('CAS_HOST value not set for ' . $this->AuthorityTitle);
     }
     if (empty($args['CAS_PORT'])) {
         throw new KurogoConfigurationException('CAS_PORT value not set for ' . $this->AuthorityTitle);
     }
     if (empty($args['CAS_PATH'])) {
         throw new KurogoConfigurationException('CAS_PATH value not set for ' . $this->AuthorityTitle);
     }
     phpCAS::client($args['CAS_PROTOCOL'], $args['CAS_HOST'], intval($args['CAS_PORT']), $args['CAS_PATH'], false);
     if (empty($args['CAS_CA_CERT'])) {
         phpCAS::setNoCasServerValidation();
     } else {
         phpCAS::setCasServerCACert($args['CAS_CA_CERT']);
     }
     // Record any attribute mapping configured.
     if (!empty($args['ATTRA_EMAIL'])) {
         CASUser::mapAttribute('Email', $args['ATTRA_EMAIL']);
     }
     if (!empty($args['ATTRA_FIRST_NAME'])) {
         CASUser::mapAttribute('FirstName', $args['ATTRA_FIRST_NAME']);
     }
     if (!empty($args['ATTRA_LAST_NAME'])) {
         CASUser::mapAttribute('LastName', $args['ATTRA_LAST_NAME']);
     }
     if (!empty($args['ATTRA_FULL_NAME'])) {
         CASUser::mapAttribute('FullName', $args['ATTRA_FULL_NAME']);
     }
     // Store an attribute for group membership if configured.
     if (!empty($args['ATTRA_MEMBER_OF'])) {
         CASUser::mapAttribute('MemberOf', $args['ATTRA_MEMBER_OF']);
     }
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:81,代码来源:CASAuthentication.php

示例14: triggerAuth

 public function triggerAuth($service_url = null)
 {
     self::buildClient($this->config->get('cas-hostname'), $this->config->get('cas-port'), $this->config->get('cas-context'));
     // Force set the CAS service URL to the osTicket login page.
     if ($service_url) {
         phpCAS::setFixedServiceURL($service_url);
     }
     // Verify the CAS server's certificate, if configured.
     if ($this->config->get('cas-ca-cert-path')) {
         phpCAS::setCasServerCACert($this->config->get('cas-ca-cert-path'));
     } else {
         phpCAS::setNoCasServerValidation();
     }
     // Trigger authentication and set the user fields when validated.
     if (!phpCAS::isAuthenticated()) {
         phpCAS::forceAuthentication();
     } else {
         $this->setUser();
         $this->setEmail();
         $this->setName();
     }
 }
开发者ID:bpalme,项目名称:osTicket-auth-cas,代码行数:22,代码来源:cas.php

示例15: __construct

    public function __construct()
    {
        if (!function_exists('curl_init')) {
            show_error('<strong>ERROR:</strong> You need to install the PHP module
				<strong><a href="http://php.net/curl">curl</a></strong> to be able
				to use CAS authentication.');
        }
        $CI =& get_instance();
        $this->CI = $CI;
        $CI->config->load('cas');
        $this->phpcas_path = $CI->config->item('phpcas_path');
        $this->cas_server_url = $CI->config->item('cas_server_url');
        if (empty($this->phpcas_path) or filter_var($this->cas_server_url, FILTER_VALIDATE_URL) === FALSE) {
            $this->_cas_show_config_error();
        }
        $cas_lib_file = $this->phpcas_path . '/CAS.php';
        if (!file_exists($cas_lib_file)) {
            show_error("<strong>ERROR:</strong> Could not find a file <em>CAS.php</em> in directory\n\t\t\t\t<strong>{$this->phpcas_path}</strong><br /><br />\n\t\t\t\tPlease, check your config file <strong>config/cas.php</strong> and make sure the\n\t\t\t\tconfiguration <em>phpcas_path</em> is a valid phpCAS installation.");
        }
        require_once $cas_lib_file;
        if ($CI->config->item('cas_debug')) {
            phpCAS::setDebug();
        }
        // init CAS client
        $defaults = array('path' => '', 'port' => 443);
        $cas_url = array_merge($defaults, parse_url($this->cas_server_url));
        phpCAS::client(CAS_VERSION_2_0, $cas_url['host'], $cas_url['port'], $cas_url['path'], false);
        // configures SSL behavior
        if ($CI->config->item('cas_disable_server_validation')) {
            phpCAS::setNoCasServerValidation();
        } else {
            $ca_cert_file = $CI->config->item('cas_server_ca_cert');
            if (empty($ca_cert_file)) {
                $this->_cas_show_config_error();
            }
            phpCAS::setCasServerCACert($ca_cert_file);
        }
    }
开发者ID:hharchani,项目名称:mail-merge-portal,代码行数:38,代码来源:Cas.php


注:本文中的phpCAS::setCasServerCACert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。