ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Auth_OpenID_SRegRequest Class Reference
+ Inheritance diagram for Auth_OpenID_SRegRequest:
+ Collaboration diagram for Auth_OpenID_SRegRequest:

Public Member Functions

 parseExtensionArgs ($args, $strict=false)
 Parse the unqualified simple registration request parameters and add them to this object. More...
 
 allRequestedFields ()
 A list of all of the simple registration fields that were requested, whether they were required or optional. More...
 
 wereFieldsRequested ()
 Have any simple registration fields been requested? More...
 
 contains ($field_name)
 Was this field in the request? More...
 
 requestField ($field_name, $required=false, $strict=false)
 Request the specified field from the OpenID user. More...
 
 requestFields ($field_names, $required=false, $strict=false)
 Add the given list of fields to the request. More...
 
 getExtensionArgs ()
 Get a dictionary of unqualified simple registration arguments representing this request. More...
 
- Public Member Functions inherited from Auth_OpenID_Extension
 getExtensionArgs ()
 Get the string arguments that should be added to an OpenID message for this extension. More...
 
 toMessage ($message)
 Add the arguments from this extension to the provided message. More...
 

Static Public Member Functions

static build ($required=null, $optional=null, $policy_url=null, $sreg_ns_uri=Auth_OpenID_SREG_NS_URI, $cls='Auth_OpenID_SRegRequest')
 Initialize an empty simple registration request. More...
 
static fromOpenIDRequest ($request, $cls='Auth_OpenID_SRegRequest')
 Create a simple registration request that contains the fields that were requested in the OpenID request with the given arguments. More...
 
- Static Public Member Functions inherited from Auth_OpenID_SRegBase
static _getSRegNS ($message)
 Extract the simple registration namespace URI from the given OpenID message. More...
 

Data Fields

 $ns_alias = 'sreg'
 
- Data Fields inherited from Auth_OpenID_Extension
 $ns_uri = null
 ns_uri: The namespace to which to add the arguments for this extension More...
 
 $ns_alias = null
 

Detailed Description

Definition at line 169 of file SReg.php.

Member Function Documentation

◆ allRequestedFields()

Auth_OpenID_SRegRequest::allRequestedFields ( )

A list of all of the simple registration fields that were requested, whether they were required or optional.

Definition at line 287 of file SReg.php.

288 {
289 return array_merge($this->required, $this->optional);
290 }

Referenced by wereFieldsRequested().

+ Here is the caller graph for this function:

◆ build()

static Auth_OpenID_SRegRequest::build (   $required = null,
  $optional = null,
  $policy_url = null,
  $sreg_ns_uri = Auth_OpenID_SREG_NS_URI,
  $cls = 'Auth_OpenID_SRegRequest' 
)
static

Initialize an empty simple registration request.

Definition at line 176 of file SReg.php.

180 {
181 $obj = new $cls();
182
183 $obj->required = array();
184 $obj->optional = array();
185 $obj->policy_url = $policy_url;
186 $obj->ns_uri = $sreg_ns_uri;
187
188 if ($required) {
189 if (!$obj->requestFields($required, true, true)) {
190 return null;
191 }
192 }
193
194 if ($optional) {
195 if (!$obj->requestFields($optional, false, true)) {
196 return null;
197 }
198 }
199
200 return $obj;
201 }

Referenced by ilAuthOpenId\callProvider().

+ Here is the caller graph for this function:

◆ contains()

Auth_OpenID_SRegRequest::contains (   $field_name)

Was this field in the request?

Definition at line 303 of file SReg.php.

304 {
305 return (in_array($field_name, $this->required) ||
306 in_array($field_name, $this->optional));
307 }

Referenced by requestField().

+ Here is the caller graph for this function:

◆ fromOpenIDRequest()

static Auth_OpenID_SRegRequest::fromOpenIDRequest (   $request,
  $cls = 'Auth_OpenID_SRegRequest' 
)
static

Create a simple registration request that contains the fields that were requested in the OpenID request with the given arguments.

$request: The OpenID authentication request from which to extract an sreg request.

$cls: name of class to use when creating sreg request object. Used for testing.

Returns the newly created simple registration request

Definition at line 216 of file SReg.php.

217 {
218
219 $obj = call_user_func_array(array($cls, 'build'),
220 array(null, null, null, Auth_OpenID_SREG_NS_URI, $cls));
221
222 // Since we're going to mess with namespace URI mapping, don't
223 // mutate the object that was passed in.
224 $m = $request->message;
225
226 $obj->ns_uri = $obj->_getSRegNS($m);
227 $args = $m->getArgs($obj->ns_uri);
228
229 if ($args === null || Auth_OpenID::isFailure($args)) {
230 return null;
231 }
232
233 $obj->parseExtensionArgs($args);
234
235 return $obj;
236 }
const Auth_OpenID_SREG_NS_URI
Definition: SReg.php:86
static isFailure($thing)
Return true if $thing is an Auth_OpenID_FailureResponse object; false if not.
Definition: OpenID.php:118

References Auth_OpenID_SREG_NS_URI, and Auth_OpenID\isFailure().

+ Here is the call graph for this function:

◆ getExtensionArgs()

Auth_OpenID_SRegRequest::getExtensionArgs ( )

Get a dictionary of unqualified simple registration arguments representing this request.

This method is essentially the inverse of C{L{parseExtensionArgs}}. This method serializes the simple registration request fields.

Reimplemented from Auth_OpenID_Extension.

Definition at line 389 of file SReg.php.

390 {
391 $args = array();
392
393 if ($this->required) {
394 $args['required'] = implode(',', $this->required);
395 }
396
397 if ($this->optional) {
398 $args['optional'] = implode(',', $this->optional);
399 }
400
401 if ($this->policy_url) {
402 $args['policy_url'] = $this->policy_url;
403 }
404
405 return $args;
406 }

◆ parseExtensionArgs()

Auth_OpenID_SRegRequest::parseExtensionArgs (   $args,
  $strict = false 
)

Parse the unqualified simple registration request parameters and add them to this object.

This method is essentially the inverse of getExtensionArgs. This method restores the serialized simple registration request fields.

If you are extracting arguments from a standard OpenID checkid_* request, you probably want to use fromOpenIDRequest, which will extract the sreg namespace and arguments from the OpenID request. This method is intended for cases where the OpenID server needs more control over how the arguments are parsed than that method provides.

$args == $message->getArgs($ns_uri); $request->parseExtensionArgs($args);

$args: The unqualified simple registration arguments

strict: Whether requests with fields that are not defined in the simple registration specification should be tolerated (and ignored)

Definition at line 262 of file SReg.php.

263 {
264 foreach (array('required', 'optional') as $list_name) {
265 $required = ($list_name == 'required');
266 $items = Auth_OpenID::arrayGet($args, $list_name);
267 if ($items) {
268 foreach (explode(',', $items) as $field_name) {
269 if (!$this->requestField($field_name, $required, $strict)) {
270 if ($strict) {
271 return false;
272 }
273 }
274 }
275 }
276 }
277
278 $this->policy_url = Auth_OpenID::arrayGet($args, 'policy_url');
279
280 return true;
281 }
requestField($field_name, $required=false, $strict=false)
Request the specified field from the OpenID user.
Definition: SReg.php:320
static arrayGet($arr, $key, $fallback=null)
Convenience function for getting array values.
Definition: OpenID.php:242

References Auth_OpenID\arrayGet(), and requestField().

+ Here is the call graph for this function:

◆ requestField()

Auth_OpenID_SRegRequest::requestField (   $field_name,
  $required = false,
  $strict = false 
)

Request the specified field from the OpenID user.

$field_name: the unqualified simple registration field name

required: whether the given field should be presented to the user as being a required to successfully complete the request

strict: whether to raise an exception when a field is added to a request more than once

Definition at line 320 of file SReg.php.

322 {
323 if (!Auth_OpenID_checkFieldName($field_name)) {
324 return false;
325 }
326
327 if ($strict) {
328 if ($this->contains($field_name)) {
329 return false;
330 }
331 } else {
332 if (in_array($field_name, $this->required)) {
333 return true;
334 }
335
336 if (in_array($field_name, $this->optional)) {
337 if ($required) {
338 unset($this->optional[array_search($field_name,
339 $this->optional)]);
340 } else {
341 return true;
342 }
343 }
344 }
345
346 if ($required) {
347 $this->required[] = $field_name;
348 } else {
349 $this->optional[] = $field_name;
350 }
351
352 return true;
353 }
Auth_OpenID_checkFieldName($field_name)
Check to see that the given value is a valid simple registration data field name.
Definition: SReg.php:65
contains($field_name)
Was this field in the request?
Definition: SReg.php:303

References Auth_OpenID_checkFieldName(), and contains().

Referenced by parseExtensionArgs(), and requestFields().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ requestFields()

Auth_OpenID_SRegRequest::requestFields (   $field_names,
  $required = false,
  $strict = false 
)

Add the given list of fields to the request.

field_names: The simple registration data fields to request

required: Whether these values should be presented to the user as required

strict: whether to raise an exception when a field is added to a request more than once

Definition at line 366 of file SReg.php.

367 {
368 if (!is_array($field_names)) {
369 return false;
370 }
371
372 foreach ($field_names as $field_name) {
373 if (!$this->requestField($field_name, $required, $strict=$strict)) {
374 return false;
375 }
376 }
377
378 return true;
379 }

References requestField().

+ Here is the call graph for this function:

◆ wereFieldsRequested()

Auth_OpenID_SRegRequest::wereFieldsRequested ( )

Have any simple registration fields been requested?

Definition at line 295 of file SReg.php.

296 {
297 return count($this->allRequestedFields());
298 }
allRequestedFields()
A list of all of the simple registration fields that were requested, whether they were required or op...
Definition: SReg.php:287

References allRequestedFields().

+ Here is the call graph for this function:

Field Documentation

◆ $ns_alias

Auth_OpenID_SRegRequest::$ns_alias = 'sreg'

Definition at line 171 of file SReg.php.


The documentation for this class was generated from the following file: