|
@@ -23,6 +23,7 @@
|
23
|
23
|
*/
|
24
|
24
|
|
25
|
25
|
require_once(dirname(__FILE__) . '/bigmath.inc.php');
|
|
26
|
+ require_once(dirname(__FILE__) . '/logging.inc.php');
|
26
|
27
|
require_once(dirname(__FILE__) . '/poster.inc.php');
|
27
|
28
|
require_once(dirname(__FILE__) . '/urlbuilder.inc.php');
|
28
|
29
|
|
|
@@ -60,12 +61,14 @@
|
60
|
61
|
*
|
61
|
62
|
* @param String $server The server to associate with
|
62
|
63
|
*/
|
63
|
|
- public static function associate($server) {
|
64
|
|
- $data = URLBuilder::buildAssociate($server, $_SESSION['openid']['version']);
|
|
64
|
+ public static function associate($server, $assocType = null, $sessionType = null) {
|
|
65
|
+ Logger::log('Attempting to associate with %s, assocType: %s, sessionType: %s', $server, $assocType, $sessionType);
|
|
66
|
+ $data = URLBuilder::buildAssociate($server, $_SESSION['openid']['version'], $assocType, $sessionType);
|
65
|
67
|
|
66
|
68
|
try {
|
67
|
69
|
$res = Poster::post($server, $data);
|
68
|
70
|
} catch (Exception $ex) {
|
|
71
|
+ Logger::log('Exception while posting: %s', $ex->getMessage());
|
69
|
72
|
return;
|
70
|
73
|
}
|
71
|
74
|
|
|
@@ -77,6 +80,27 @@
|
77
|
80
|
}
|
78
|
81
|
}
|
79
|
82
|
|
|
83
|
+ if (isset($data['error_code']) && $data['error_code'] == 'unsupported-type') {
|
|
84
|
+ $cont = false;
|
|
85
|
+
|
|
86
|
+ if (isset($data['session_type']) && $data['session_type'] != $sessionType) {
|
|
87
|
+ // TODO: Check we support it before actually trying
|
|
88
|
+ $sessionType = $data['session_type'];
|
|
89
|
+ $cont = true;
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ if (isset($data['assoc_type']) && $data['assoc_type'] != $assocType) {
|
|
93
|
+ $assocType = $data['assoc_type'];
|
|
94
|
+ $cont = true;
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ if ($cont) {
|
|
98
|
+ self::associate($server, $assocType, $sessionType);
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ return;
|
|
102
|
+ }
|
|
103
|
+
|
80
|
104
|
try {
|
81
|
105
|
$data = self::decodeKey($server, $data);
|
82
|
106
|
} catch (Exception $ex) {
|