Skip to content
Snippets Groups Projects
Unverified Commit 0526e1b6 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

Reduce code duplication

parent 3fcc032b
Branches
Tags
No related merge requests found
...@@ -60,11 +60,9 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -60,11 +60,9 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
assert(array_key_exists('Attributes', $state)); assert(array_key_exists('Attributes', $state));
$logAttribute = 'NA'; $logAttribute = 'NA';
$source = 'NA';
$dest = 'NA';
$isPassive = ''; $isPassive = '';
if(array_key_exists('isPassive', $state) && $state['isPassive'] === true) { if (array_key_exists('isPassive', $state) && $state['isPassive'] === true) {
if ($this->skipPassive === true) { if ($this->skipPassive === true) {
// We have a passive request. Skip logging statistics // We have a passive request. Skip logging statistics
return; return;
...@@ -72,22 +70,12 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -72,22 +70,12 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
$isPassive = 'passive-'; $isPassive = 'passive-';
} }
if (array_key_exists($this->attribute, $state['Attributes'])) $logAttribute = $state['Attributes'][$this->attribute][0]; if (array_key_exists($this->attribute, $state['Attributes'])) {
if (array_key_exists('Source', $state)) { $logAttribute = $state['Attributes'][$this->attribute][0];
if (isset($state['Source']['core:statistics-id'])) { }
$source = $state['Source']['core:statistics-id'];
} else {
$source = $state['Source']['entityid'];
}
}
if (array_key_exists('Destination', $state)) { $source = $this->setIdentifier('Source', $state);
if (isset($state['Destination']['core:statistics-id'])) { $dest = $this->setIdentifier('Destination', $state);
$dest = $state['Destination']['core:statistics-id'];
} else {
$dest = $state['Destination']['entityid'];
}
}
if (!array_key_exists('PreviousSSOTimestamp', $state)) { if (!array_key_exists('PreviousSSOTimestamp', $state)) {
// The user hasn't authenticated with this SP earlier in this session // The user hasn't authenticated with this SP earlier in this session
...@@ -97,4 +85,21 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -97,4 +85,21 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
SimpleSAML\Logger::stats($isPassive . $this->typeTag . ' ' . $dest . ' ' . $source . ' ' . $logAttribute); SimpleSAML\Logger::stats($isPassive . $this->typeTag . ' ' . $dest . ' ' . $source . ' ' . $logAttribute);
} }
/**
* @param string &$direction Either 'Source' or 'Destination'.
* @param array $state The current state.
*
* @return string
*/
private function setIdentitier($direction, $state)
{
if (array_key_exists($direction, $state)) {
if (isset($state[$direction]['core:statistics-id'])) {
return $state[$direction]['core:statistics-id'];
} else {
return $state[$direction]['entityid'];
}
}
return 'NA';
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment