Skip to content

Commit

Permalink
Skip missing remote vetting attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
pablothedude committed Mar 3, 2021
1 parent 38901cc commit 33b61b9
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting;

use Psr\Log\LoggerInterface;
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidRemoteVettingMappingException;
use Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\Configuration\RemoteVettingConfiguration;
use Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\Dto\AttributeListDto;
Expand All @@ -29,10 +30,15 @@ class AttributeMapper
* @var RemoteVettingConfiguration
*/
private $configuration;
/**
* @var LoggerInterface
*/
private $logger;

public function __construct(RemoteVettingConfiguration $configuration)
public function __construct(RemoteVettingConfiguration $configuration, LoggerInterface $logger)
{
$this->configuration = $configuration;
$this->logger = $logger;
}

/**
Expand All @@ -52,17 +58,19 @@ public function map($identityProviderName, AttributeListDto $localAttributes, At
$matchCollection = new AttributeMatchCollection();
foreach ($attributeMapping as $localName => $remoteName) {
if (!array_key_exists($localName, $localMap)) {
throw new InvalidRemoteVettingMappingException(sprintf(
'Invalid remote vetting attribute mapping, local attribute with name "%s" not found',
$this->logger->warning(sprintf(
'Invalid remote vetting attribute mapping, local attribute with name "%s" not found, skipping',
$localName
));
continue;
}

if (!array_key_exists($remoteName, $remoteMap)) {
throw new InvalidRemoteVettingMappingException(sprintf(
'Invalid remote vetting attribute mapping, remote attribute with name "%s" not found',
$this->logger->warning(sprintf(
'Invalid remote vetting attribute mapping, remote attribute with name "%s" not found, skipping',
$remoteName
));
continue;
}

$attributeMatch = new AttributeMatch($localMap[$localName], $remoteMap[$remoteName], false, '');
Expand Down

0 comments on commit 33b61b9

Please sign in to comment.