Skip to content
Snippets Groups Projects
Verified Commit b5af9500 authored by Dominik František Bučík's avatar Dominik František Bučík
Browse files

fix: :bug: Reworked how Jurisdiction is read

parent 1b0f05b3
No related branches found
No related tags found
1 merge request!38fix: 🐛 Reworked how Jurisdiction is read
Pipeline #219906 passed
......@@ -5,54 +5,60 @@ namespace SimpleSAML\Module\elixir;
class ConsentHelper
{
private const EU_EAA = [
'AT' => 'Austria',
'BE' => 'Belgium',
'BG' => 'Bulgaria',
'HR' => 'Croatia',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DK' => 'Denmark',
'EE' => 'Estonia',
'FI' => 'Finland',
'FR' => 'France',
'DE' => 'Germany',
'EL' => 'Greece',
'HU' => 'Hungary',
'IE' => 'Ireland',
'IT' => 'Italy',
'LV' => 'Latvia',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MT' => 'Malta',
'NL' => 'Netherlands',
'PT' => 'Portugal',
'RO' => 'Romania',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'ES' => 'Spain',
'SE' => 'Sweden',
'NO' => 'Norway',
'IS' => 'Iceland',
'LI' => 'Liechtenstein',
'GB' => 'United Kingdom',
'AUT' => 'Austria',
'BEL' => 'Belgium',
'BGR' => 'Bulgaria',
'HRV' => 'Croatia',
'CYP' => 'Cyprus',
'CZE' => 'Czech Republic',
'DNK' => 'Denmark',
'EST' => 'Estonia',
'FIN' => 'Finland',
'FRA' => 'France',
'DEU' => 'Germany',
'GRC' => 'Greece',
'HUN' => 'Hungary',
'IRL' => 'Ireland',
'ITA' => 'Italy',
'LVA' => 'Latvia',
'LTU' => 'Lithuania',
'LUX' => 'Luxembourg',
'MLT' => 'Malta',
'NLD' => 'Netherlands',
'PRT' => 'Portugal',
'ROU' => 'Romania',
'SVK' => 'Slovakia',
'SVN' => 'Slovenia',
'ESP' => 'Spain',
'SWE' => 'Sweden',
'NOR' => 'Norway',
'ISL' => 'Iceland',
'LIE' => 'Liechtenstein',
'GBR' => 'United Kingdom',
];
private const JURISDICTION_INTERNATIONAL_ORG = 'International organisation';
private const JURISDICTION_EMBL = 'EMBL intergovernmental organisation';
public function __construct()
{
}
public static function getJurisdiction($dstMetadata): string
{
$countryCodes = json_decode(file_get_contents('http://country.io/names.json'), true);
$jurisdiction = empty($dstMetadata['jurisdiction']) ? '' : $dstMetadata['jurisdiction'];
if (empty($jurisdiction) || array_key_exists($jurisdiction, self::EU_EAA)) {
return '';
}
if ('INT' === $jurisdiction || 'EMBL' === $jurisdiction) {
$pattern = "/\(\K[A-Z]{3}/";
$jurisdictionCode = preg_match($pattern, $jurisdiction, $out) ? $out[0] : $jurisdiction;
if (
self::JURISDICTION_INTERNATIONAL_ORG === $jurisdictionCode
|| self::JURISDICTION_EMBL === $jurisdictionCode
) {
return $jurisdiction;
} elseif (empty($jurisdictionCode) || array_key_exists($jurisdictionCode, self::EU_EAA)) {
return '';
}
return 'in ' . $countryCodes[$jurisdiction];
return 'in ' . $jurisdiction;
}
public static function printUserAttributes(array $attributes, $translator)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment