ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Auth_OpenID_KVForm Class Reference

Container for key-value/comma-newline OpenID format and parsing. More...

+ Collaboration diagram for Auth_OpenID_KVForm:

Static Public Member Functions

static toArray ($kvs, $strict=false)
 Convert an OpenID colon/newline separated string into an associative array. More...
 
static fromArray ($values)
 Convert an array into an OpenID colon/newline separated string. More...
 

Detailed Description

Container for key-value/comma-newline OpenID format and parsing.

Definition at line 21 of file KVForm.php.

Member Function Documentation

◆ fromArray()

static Auth_OpenID_KVForm::fromArray (   $values)
static

Convert an array into an OpenID colon/newline separated string.

@access private

Definition at line 81 of file KVForm.php.

82 {
83 if ($values === null) {
84 return null;
85 }
86
87 ksort($values);
88
89 $serialized = '';
90 foreach ($values as $key => $value) {
91 if (is_array($value)) {
92 list($key, $value) = array($value[0], $value[1]);
93 }
94
95 if (strpos($key, ':') !== false) {
96 return null;
97 }
98
99 if (strpos($key, "\n") !== false) {
100 return null;
101 }
102
103 if (strpos($value, "\n") !== false) {
104 return null;
105 }
106 $serialized .= "$key:$value\n";
107 }
108 return $serialized;
109 }

Referenced by Auth_OpenID_ServerError\encodeToKVForm(), Auth_OpenID_Association\serialize(), Auth_OpenID_Association\sign(), and Auth_OpenID_Message\toKVForm().

+ Here is the caller graph for this function:

◆ toArray()

static Auth_OpenID_KVForm::toArray (   $kvs,
  $strict = false 
)
static

Convert an OpenID colon/newline separated string into an associative array.

@access private

Definition at line 29 of file KVForm.php.

30 {
31 $lines = explode("\n", $kvs);
32
33 $last = array_pop($lines);
34 if ($last !== '') {
35 array_push($lines, $last);
36 if ($strict) {
37 return false;
38 }
39 }
40
41 $values = array();
42
43 for ($lineno = 0; $lineno < count($lines); $lineno++) {
44 $line = $lines[$lineno];
45 $kv = explode(':', $line, 2);
46 if (count($kv) != 2) {
47 if ($strict) {
48 return false;
49 }
50 continue;
51 }
52
53 $key = $kv[0];
54 $tkey = trim($key);
55 if ($tkey != $key) {
56 if ($strict) {
57 return false;
58 }
59 }
60
61 $value = $kv[1];
62 $tval = trim($value);
63 if ($tval != $value) {
64 if ($strict) {
65 return false;
66 }
67 }
68
69 $values[$tkey] = $tval;
70 }
71
72 return $values;
73 }

Referenced by Auth_OpenID_Association\deserialize(), and Auth_OpenID_Message\fromKVForm().

+ Here is the caller graph for this function:

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