public function authenticate()
    {
        if (empty($this->authResult)) {
            if ($this->hasIdentity()) {
                $this->clearIdentity();
            }

            return new Result(
                Result::FAILURE_UNCATEGORIZED,
                null,
                ['no result set']
            );
        }

        if ($this->hasIdentity()) {
            $this->clearIdentity();
        }

        if ($this->authResult->isValid()) {
            $this->getStorage()->write($this->authResult->getIdentity());
        }

        $result = $this->authResult;
        $this->authResult = null;

        return $result;
    }