/** * @param AssertionAdapter $assertionAdapter * @param EntityId[] $authenticatingAuthorities * * @return AuthenticatedUser * @throws RuntimeException */ public static function createFrom(AssertionAdapter $assertionAdapter, array $authenticatingAuthorities) { $attributes = []; /** @var Attribute $attribute */ foreach ($assertionAdapter->getAttributeSet() as $attribute) { $definition = $attribute->getAttributeDefinition(); // We only want to replace the eduPersonTargetedID attribute value as that is a nested NameID attribute if ($definition->getName() !== 'eduPersonTargetedID') { $attributes[] = $attribute; continue; } $eptiValues = $attribute->getValue(); $attributes[] = new Attribute($definition, [$eptiValues[0]['Value']]); } return new self($assertionAdapter->getNameId(), AttributeSet::create($attributes), $authenticatingAuthorities); }