Apache Zeta Components Manual :: File Source for typekey_options.php

Source for file typekey_options.php

Documentation is available at typekey_options.php

  1. <?php
  2. /**
  3.  * File containing the ezcAuthenticationTypekeyOptions class.
  4.  *
  5.  * Licensed to the Apache Software Foundation (ASF) under one
  6.  * or more contributor license agreements.  See the NOTICE file
  7.  * distributed with this work for additional information
  8.  * regarding copyright ownership.  The ASF licenses this file
  9.  * to you under the Apache License, Version 2.0 (the
  10.  * "License"); you may not use this file except in compliance
  11.  * with the License.  You may obtain a copy of the License at
  12.  * 
  13.  *   http://www.apache.org/licenses/LICENSE-2.0
  14.  * 
  15.  * Unless required by applicable law or agreed to in writing,
  16.  * software distributed under the License is distributed on an
  17.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18.  * KIND, either express or implied.  See the License for the
  19.  * specific language governing permissions and limitations
  20.  * under the License.
  21.  *
  22.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  23.  * @filesource
  24.  * @package Authentication
  25.  * @version //autogen//
  26.  */
  27.  
  28. /**
  29.  * Class containing the options for the TypeKey authentication filter.
  30.  *
  31.  * Example of use:
  32.  * <code>
  33.  * // create an options object
  34.  * $options = new ezcAuthenticationTypekeyOptions();
  35.  * $options->validity = 60;
  36.  * $options->keysFile = '/tmp/typekey_keys.txt';
  37.  * $options->requestSource = $_POST;
  38.  *
  39.  * // use the options object when creating a new TypeKey filter
  40.  * $filter = new ezcAuthenticationTypekeyFilter( $options );
  41.  *
  42.  * // alternatively, you can set the options to an existing filter
  43.  * $filter = new ezcAuthenticationTypekeyFilter();
  44.  * $filter->setOptions( $options );
  45.  * </code>
  46.  *
  47.  * @property int $validity 
  48.  *            The maximum timespan that can exist between the timestamp
  49.  *            sent by the application server at log-in and the timestamp sent
  50.  *            by the TypeKey server. A value of 0 means the validity value
  51.  *            is not taken into consideration when validating the response
  52.  *            sent by the TypeKey server. Do not use a value too small, as
  53.  *            the servers might not be synchronized.
  54.  * @property string $keysFile 
  55.  *            The file from where to retrieve the public keys which are used
  56.  *            for checking the TypeKey signature. Can be a local file or a
  57.  *            URL. Default is http://www.typekey.com/extras/regkeys.txt.
  58.  *            Developers can save the file locally once per day to improve the
  59.  *            speed of the TypeKey authentication (which reads this file
  60.  *            at every authentication attempt).
  61.  * @property array(string=>mixed) $requestSource 
  62.  *            From where to get the parameters returned by the TypeKey server.
  63.  *            Default is $_GET.
  64.  *
  65.  * @package Authentication
  66.  * @version //autogen//
  67.  */
  68. {
  69.     /**
  70.      * Constructs an object with the specified values.
  71.      *
  72.      * @throws ezcBasePropertyNotFoundException
  73.      *          if $options contains a property not defined
  74.      * @throws ezcBaseValueException
  75.      *          if $options contains a property with a value not allowed
  76.      * @throws ezcBaseFileNotFoundException
  77.      *          if the $value file does not exist
  78.      * @throws ezcBaseFilePermissionException
  79.      *          if the $value file cannot be opened for reading
  80.      * @param array(string=>mixed) $options Options for this class
  81.      */
  82.     public function __constructarray $options array() )
  83.     {
  84.         $this->validity 0// seconds
  85.         $this->keysFile 'http://www.typekey.com/extras/regkeys.txt';
  86.         $this->requestSource $_GET !== null $_GET array();
  87.  
  88.         parent::__construct$options );
  89.     }
  90.  
  91.     /**
  92.      * Sets the option $name to $value.
  93.      *
  94.      * @throws ezcBasePropertyNotFoundException
  95.      *          if the property $name is not defined
  96.      * @throws ezcBaseValueException
  97.      *          if $value is not correct for the property $name
  98.      * @throws ezcBaseFileNotFoundException
  99.      *          if the $value file does not exist
  100.      * @throws ezcBaseFilePermissionException
  101.      *          if the $value file cannot be opened for reading
  102.      * @param string $name The name of the property to set
  103.      * @param mixed $value The new value of the property
  104.      * @ignore
  105.      */
  106.     public function __set$name$value )
  107.     {
  108.         switch $name )
  109.         {
  110.             case 'validity':
  111.                 if !is_numeric$value || $value ) )
  112.                 {
  113.                     throw new ezcBaseValueException$name$value'int >= 0' );
  114.                 }
  115.                 $this->properties[$name$value;
  116.                 break;
  117.  
  118.             case 'keysFile':
  119.                 if !is_string$value ) )
  120.                 {
  121.                     throw new ezcBaseValueException$name$value'string' );
  122.                 }
  123.  
  124.                 if strpos$value'://' === false )
  125.                 {
  126.                     // if $value is not an URL
  127.                     if !file_exists$value ) )
  128.                     {
  129.                         throw new ezcBaseFileNotFoundException$value );
  130.                     }
  131.  
  132.                     if !is_readable$value ) )
  133.                     {
  134.                         throw new ezcBaseFilePermissionException$valueezcBaseFileException::READ );
  135.                     }
  136.                 }
  137.                 else
  138.                 {
  139.                     // if $value is an URL
  140.  
  141.                     // hide the notices caused by getaddrinfo (php_network_getaddresses)
  142.                     // in case of unreachable hosts ("Name or service not known")
  143.                     $headers @get_headers$value );
  144.                     if $headers === false
  145.                          || count$headers === // get_headers returns an empty array for unreachable hosts
  146.                          || strpos$headers[0]'404 Not Found' !== false
  147.                        )
  148.                     {
  149.                         throw new ezcBaseFileNotFoundException$value );
  150.                     }
  151.                 }
  152.                 $this->properties[$name$value;
  153.                 break;
  154.  
  155.             case 'requestSource':
  156.                 if !is_array$value ) )
  157.                 {
  158.                     throw new ezcBaseValueException$name$value'array' );
  159.                 }
  160.                 $this->properties[$name$value;
  161.                 break;
  162.  
  163.             default:
  164.                 parent::__set$name$value );
  165.         }
  166.     }
  167. }
  168. ?>
Documentation generated by phpDocumentor 1.4.3