public function switchRole($role)
    {
        if ($this->isAuthenticated()) {
            $entityId = $this->getConfig()->getEntityID();

            try {
                $isRole = false;

                /** @var Attribution $attribution **/
                foreach ($this->getUser()->getAttributions() as $attribution) {
                    if ($attribution->getRole()->getRole() == $role
                        && $attribution->getTarget()->getUrl() == $entityId
                    ) {
                        $isRole = true;
                    }
                }

                if ($isRole) {
                    $this->setUser($this->getUser()->setCurrentRole($role));
                } else {
                    throw new UserAttributionException('Role not found.', 400);
                }
            } catch (\Exception $e) {
                throw new UserAttributionException($e->getMessage(), $e->getCode(), $e->getPrevious());
            }
        } else {
            throw new UserAttributionException('User not found.', 400);
        }
    }