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

Source for file openid_options.php

Documentation is available at openid_options.php

  1. <?php
  2. /**
  3.  * File containing the ezcAuthenticationOpenidOptions 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 OpenID authentication filter.
  30.  *
  31.  * Example of use:
  32.  * <code>
  33.  * // create an options object
  34.  * $options = new ezcAuthenticationOpenidOptions();
  35.  * $options->mode = ezcAuthenticationOpenidFilter::MODE_SMART;
  36.  * $options->store = new ezcAuthenticationOpenidFileStore( '/tmp/store' );
  37.  * $options->timeout = 5;
  38.  * $options->timeoutOpen = 3;
  39.  * $options->requestSource = $_POST;
  40.  * $options->immediate = true;
  41.  * $options->returnUrl = 'http://example.com';
  42.  * $options->openidVersion = ezcAuthenticationOpenidFilter::VERSION_2_0;
  43.  *
  44.  * // use the options object when creating a new OpenID filter
  45.  * $filter = new ezcAuthenticationOpenidFilter( $options );
  46.  *
  47.  * // alternatively, you can set the options to an existing filter
  48.  * $filter = new ezcAuthenticationSession();
  49.  * $filter->setOptions( $options );
  50.  * </code>
  51.  *
  52.  * @property int $mode 
  53.  *            The OpenID mode to use for authentication. It is either dumb
  54.  *            (ezcAuthenticationOpenidFilter::MODE_DUMB, default) or smart
  55.  *            (ezcAuthenticationOpenidFilter::MODE_SMART). In dumb mode
  56.  *            the OpenID server does most of the work, but an extra check
  57.  *            is required (check_authentication step). In smart mode the
  58.  *            server and the OpenIP provider establish a shared secret (with
  59.  *            an expiry period) that is used to sign the responses, so the
  60.  *            check_authentication step is not required.
  61.  * @property ezcAuthenticationOpenidStore $store 
  62.  *            The store to use to hold the nonces and (for MODE_SMART) the
  63.  *            associations between the server and the OpenID provider. Default
  64.  *            is null which means nonces are not used. If you enable MODE_SMART
  65.  *            you have to specify also a valid store.
  66.  * @property string $nonceKey 
  67.  *            The query key that identifies the nonce value, default 'nonce'.
  68.  * @property int $nonceLength 
  69.  *            The length of the generated nonces, default 6.
  70.  * @property int $nonceValidity 
  71.  *            The amount of seconds the nonces are allowed to be valid.
  72.  * @property int $timeout 
  73.  *            The amount of seconds allowed as timeout for fetching content
  74.  *            during HTML or Yadis discovery.
  75.  * @property int $timeoutOpen 
  76.  *            The amount of seconds allowed as timeout when creating a connection
  77.  *            with fsockopen() for the HTML or Yadis discovery.
  78.  * @property array(string=>mixed) $requestSource 
  79.  *            From where to get the parameters returned by the OpenID provider.
  80.  *            Default is $_GET.
  81.  * @property bool $immediate 
  82.  *            Enables OpenID checkid_immediate instead of checkid_setup. See the
  83.  *            ezcAuthenticationOpenidFilter class documentation for more details.
  84.  *            It is false by default (use checkid_setup by default).
  85.  * @property string $returnUrl 
  86.  *            URL to return to after the successful authentication by the
  87.  *            OpenID provider. Default value is null, in which case the OpenID
  88.  *            provider will return to the current URL (the URL that initiated
  89.  *            the authentication, from HTTP_HOST + REQUEST_URI server variables).
  90.  * @property string $openidVersion 
  91.  *            Which OpenID protocol version to try. Default is "1.1". Other
  92.  *            possible values are "1.0" and "2.0".
  93.  *
  94.  * @package Authentication
  95.  * @version //autogen//
  96.  */
  97. {
  98.     /**
  99.      * Constructs an object with the specified values.
  100.      *
  101.      * @throws ezcBasePropertyNotFoundException
  102.      *          if $options contains a property not defined
  103.      * @throws ezcBaseValueException
  104.      *          if $options contains a property with a value not allowed
  105.      * @param array(string=>mixed) $options Options for this class
  106.      */
  107.     public function __constructarray $options array() )
  108.     {
  109.         $this->mode ezcAuthenticationOpenidFilter::MODE_DUMB// stateless mode
  110.         $this->store null;
  111.         $this->nonceKey 'nonce';
  112.         $this->nonceLength 6// characters
  113.         $this->nonceValidity 24 60 60// seconds
  114.         $this->timeout 3// seconds
  115.         $this->timeoutOpen 3// seconds
  116.         $this->requestSource $_GET !== null $_GET array();
  117.         $this->immediate false;
  118.         $this->returnUrl null// default = return to the currently called URL
  119.         $this->openidVersion ezcAuthenticationOpenidFilter::VERSION_1_1;
  120.  
  121.         parent::__construct$options );
  122.     }
  123.  
  124.     /**
  125.      * Sets the option $name to $value.
  126.      *
  127.      * @throws ezcBasePropertyNotFoundException
  128.      *          if the property $name is not defined
  129.      * @throws ezcBaseValueException
  130.      *          if $value is not correct for the property $name
  131.      * @param string $name The name of the property to set
  132.      * @param mixed $value The new value of the property
  133.      * @ignore
  134.      */
  135.     public function __set$name$value )
  136.     {
  137.         switch $name )
  138.         {
  139.             case 'mode':
  140.                 $allowedValues array(
  141.                                         ezcAuthenticationOpenidFilter::MODE_DUMB,
  142.                                         ezcAuthenticationOpenidFilter::MODE_SMART
  143.                                       );
  144.                 if !in_array$value$allowedValuestrue ) )
  145.                 {
  146.                     throw new ezcBaseValueException$name$valueimplode', '$allowedValues ) );
  147.                 }
  148.                 $this->properties[$name$value;
  149.                 break;
  150.  
  151.             case 'store':
  152.                 if $value !== null && !$value instanceof ezcAuthenticationOpenidStore )
  153.                 {
  154.                     throw new ezcBaseValueException$name$value'ezcAuthenticationOpenidStore || null' );
  155.                 }
  156.                 $this->properties[$name$value;
  157.                 break;
  158.  
  159.             case 'nonceKey':
  160.                 if !is_string$value ) )
  161.                 {
  162.                     throw new ezcBaseValueException$name$value'string' );
  163.                 }
  164.                 $this->properties[$name$value;
  165.                 break;
  166.  
  167.             case 'nonceLength':
  168.             case 'nonceValidity':
  169.             case 'timeout':
  170.             case 'timeoutOpen':
  171.                 if !is_numeric$value || $value ) )
  172.                 {
  173.                     throw new ezcBaseValueException$name$value'int >= 1' );
  174.                 }
  175.                 $this->properties[$name$value;
  176.                 break;
  177.  
  178.             case 'requestSource':
  179.                 if !is_array$value ) )
  180.                 {
  181.                     throw new ezcBaseValueException$name$value'array' );
  182.                 }
  183.                 $this->properties[$name$value;
  184.                 break;
  185.  
  186.             case 'immediate':
  187.                 if !is_bool$value ) )
  188.                 {
  189.                     throw new ezcBaseValueException$name$value'bool' );
  190.                 }
  191.                 $this->properties[$name$value;
  192.                 break;
  193.  
  194.             case 'returnUrl':
  195.                 if !is_string$value && !is_null$value ) )
  196.                 {
  197.                     throw new ezcBaseValueException$name$value'string' );
  198.                 }
  199.                 $this->properties[$name$value;
  200.                 break;
  201.  
  202.             case 'openidVersion':
  203.                 if !is_string$value && !is_null$value ) )
  204.                 {
  205.                     throw new ezcBaseValueException$name$value'string' );
  206.                 }
  207.                 $this->properties[$name$value;
  208.                 break;
  209.  
  210.             default:
  211.                 parent::__set$name$value );
  212.         }
  213.     }
  214. }
  215. ?>
Documentation generated by phpDocumentor 1.4.3