public function retrieveUserFromAssertion(Assertion $assertion)
    {
        $user = null;
        $role = null;

        foreach ($assertion->getAllAttributeStatements() as $attributeStatement) {
            foreach ($attributeStatement->getAllAttributes() as $attribute) {
                switch ($attribute->getName()) {
                    case 'user_entity':
                        $user = new User(\json_decode($attribute->getFirstAttributeValue(), true));
                        break;
                    case ClaimTypes::ROLE:
                        $role = $attribute->getFirstAttributeValue();
                }
            }
        }

        if ($user instanceof User) {
            $user->setCurrentRole($role);
        }

        return $user;
    }