## 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. */
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. class ezcAuthenticationOpenidOptions extends ezcAuthenticationFilterOptions
98. {
99. /**
100. * Constructs an object with the specified values.
101. *
102. * @throws ezcBasePropertyNotFoundException
103. * if $options contains a property not defined
104. * @throws ezcBaseValueException
105. * if $options contains a property with a value not allowed
106. * @param array(string=>mixed) $options Options for this class
107. */
108. public function __construct ( array $options = array() )
109. {
110. $this->mode = ezcAuthenticationOpenidFilter ::MODE_DUMB; // stateless mode
111. $this->store = null;
112. $this->nonceKey = 'nonce';
113. $this->nonceLength = 6; // characters
114. $this->nonceValidity = 24 * 60 * 60; // seconds
115. $this->timeout = 3; // seconds
116. $this->timeoutOpen = 3; // seconds
117. $this->requestSource = ( $_GET !== null ) ? $_GET : array();
118. $this->immediate = false;
119. $this->returnUrl = null; // default = return to the currently called URL
120. $this->openidVersion = ezcAuthenticationOpenidFilter ::VERSION_1_1;
122. parent:: __construct ( $options );
123. }
125. /**
126. * Sets the option $name to $value.
127. *
128. * @throws ezcBasePropertyNotFoundException
129. * if the property $name is not defined
130. * @throws ezcBaseValueException
131. * if $value is not correct for the property $name
132. * @param string $name The name of the property to set
133. * @param mixed $value The new value of the property
134. * @ignore
135. */
136. public function __set( $name, $value )
137. {
138. switch ( $name )
139. {
140. case 'mode':
141. $allowedValues = array(
142. ezcAuthenticationOpenidFilter ::MODE_DUMB,
143. ezcAuthenticationOpenidFilter ::MODE_SMART
144. );
145. if ( ! in_array ( $value, $allowedValues, true ) )
146. {
147. throw new ezcBaseValueException ( $name, $value, implode ( ', ', $allowedValues ) );
148. }
149. $this-> properties [$name] = $value;
150. break;
152. case 'store':
153. if ( $value !== null && !$value instanceof ezcAuthenticationOpenidStore )
154. {
155. throw new ezcBaseValueException ( $name, $value, 'ezcAuthenticationOpenidStore || null' );
156. }
157. $this-> properties [$name] = $value;
158. break;
160. case 'nonceKey':
161. if ( ! is_string ( $value ) )
162. {
163. throw new ezcBaseValueException ( $name, $value, 'string' );
164. }
165. $this-> properties [$name] = $value;
166. break;
168. case 'nonceLength':
169. case 'nonceValidity':
170. case 'timeout':
171. case 'timeoutOpen':
172. if ( ! is_numeric ( $value ) || ( $value < 1 ) )
173. {
174. throw new ezcBaseValueException ( $name, $value, 'int >= 1' );
175. }
176. $this-> properties [$name] = $value;
177. break;
179. case 'requestSource':
180. if ( ! is_array ( $value ) )
181. {
182. throw new ezcBaseValueException ( $name, $value, 'array' );
183. }
184. $this-> properties [$name] = $value;
185. break;
187. case 'immediate':
188. if ( ! is_bool ( $value ) )
189. {
190. throw new ezcBaseValueException ( $name, $value, 'bool' );
191. }
192. $this-> properties [$name] = $value;
193. break;
195. case 'returnUrl':
196. if ( ! is_string ( $value ) && ! is_null ( $value ) )
197. {
198. throw new ezcBaseValueException ( $name, $value, 'string' );
199. }
200. $this-> properties [$name] = $value;
201. break;
203. case 'openidVersion':
204. if ( ! is_string ( $value ) && ! is_null ( $value ) )
205. {
206. throw new ezcBaseValueException ( $name, $value, 'string' );
207. }
208. $this-> properties [$name] = $value;
209. break;
211. default:
212. parent::__set( $name, $value );
213. }
214. }
215. }
216. ?>

Documentation generated by phpDocumentor 1.4.3