Skip to content

Commit 9100d5a

Browse files
committed
hibakezelések
1 parent 0d1fb8b commit 9100d5a

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

lib/Auth/Process/AttributeFromRestApi.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ public function __construct($config, $reserved)
3737
public function process(&$state)
3838
{
3939
assert('is_array($state)');
40+
if (! array_key_exists($this->as_config['nameId_attribute_name'], $state['Attributes'])) {
41+
throw new SimpleSAML_Error_Exception(
42+
"Configuration error: There is no attribute named: "
43+
.$this->as_config['nameId_attribute_name']
44+
." in state['Attributes'] array."
45+
);
46+
}
4047
$nameId = $state['Attributes'][$this->as_config['nameId_attribute_name']][0];
4148
$this->config = SimpleSAML_Configuration::getInstance();
4249
$new_attributes = $this->getAttributes($nameId);
4350
$state['Attributes'][key($new_attributes)][0] = $new_attributes[key($new_attributes)];
44-
45-
// array_push($state['Attributes'], $this->getAttributes($nameId));
46-
47-
// var_dump($this->getAttributes($nameId)); exit;
48-
// var_dump($state['Attributes']); exit;
4951
}
5052

5153
public function getAttributes($nameId, $attributes = array())
@@ -74,13 +76,13 @@ public function getAttributes($nameId, $attributes = array())
7476
$http_response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
7577

7678
// Check for error; not even redirects are allowed here
77-
if ($response === false || !($http_response >= 200 && $http_response < 300)) {
79+
if ($http_response == 507) {
80+
throw new SimpleSAML_Error_Exception("Out of resources: " . $response);
81+
} elseif ($response === false || !($http_response >= 200 && $http_response < 300)) {
7882
SimpleSAML_Logger::error('[afra] API query failed: HTTP response code: '.$http_response.', curl error: "'.curl_error($ch)).'"';
7983
SimpleSAML_Logger::debug('[afra] API query failed: curl info: '.var_export(curl_getinfo($ch), 1));
8084
SimpleSAML_Logger::debug('[afra] API query failed: HTTP response: '.var_export($response, 1));
81-
throw new \Exception("Hiba, ". $response, 1);
82-
} elseif (false) {
83-
# egyéb hibaüzenetek
85+
throw new SimpleSAML_Error_Exception("Error at REST API response: ". $response . $http_response);
8486
} else {
8587
$data = json_decode($response, true);
8688
SimpleSAML_Logger::info('[afra] got reply from API');

0 commit comments

Comments
 (0)