Fetch username from authenticated token.

@return string Supplied username from authenticated token

@throw ServerErrorException If supplied token is not a standard TokenInterface instance.
168877
protected function checkUsername()
    {
        $token = $this->tokenStorage->getToken();
        if (!$token instanceof RememberMeToken && !$token instanceof UsernamePasswordToken) {
            throw new ServerErrorException([
                'error_description' => 'The authorization server encountered an unexpected condition that prevented it from fulfilling the request.',
            ]);
        }

        return $token->getUsername();
    }
643249
def get_web_auth_session_key_username(self, url, token=""):
        

        if url in self.web_auth_tokens.keys():
            token = self.web_auth_tokens[url]
        else:
            # This will raise a WSError if token is blank or unauthorized
            token = token

        request = _Request(self.network, "auth.getSession", {"token": token})

        # default action is that a request is signed only when
        # a session key is provided.
        request.sign_it()

        doc = request.execute()

        session_key = doc.getElementsByTagName("key")[0].firstChild.data
        username = doc.getElementsByTagName("name")[0].firstChild.data
        return session_key, username
853999
@JsonIgnore
	public String getUsername() {
		if (App.isRoot(user.getAppid())) {
			return user.getIdentifier();
		} else {
			return user.getAppid() + "/" + user.getIdentifier();
		}
	}
1249764
public function getCurrentUser()
    {
        if ($token = $this->tokenStorage->getToken()) {
            if (($user = $token->getUser()) && is_object($user)) {
                return $user;
            }
        }

        throw new \Exception('Authorization needed', ErrorCode::CODE_UNAUTHORIZED);
    }
327134
private function getSavedPasswordTokenData()
    {
        if ($this->isNewRecord()) {
            // We can't fulfil the request as we have no UserID which is required for the StringColumn.
            throw new TokenException("The user has not been saved");
        }

        return sha1($this->Username . $this->Password . $this->FullName . $this->Enabled . $this->UserID);
    }
3747
@Override
    public String getUserName(HttpServletRequest req) {
        Principal princ = null;
        if (req != null && (princ = req.getUserPrincipal()) != null) {
            String userName = princ.getName();
            if (userName != null && !userName.isEmpty()) {
                LOG.debug("HTTP request had user (" + userName + ")");
                return userName;
            }
        }
        return null;
    }
1236644
public function getUserId()
  {
    if (array_key_exists(self::USER_ATTR, $this->payload)) {
      return $this->payload[self::USER_ATTR];
    }
    throw new Google_Auth_Exception("No user_id in token");
  }
46130
@Override
    public String getName() {
        final Object attributeValue = this.getAttributeValue(this.userNameAttribute);
        if (attributeValue == null) {
            return null;
        }

        return attributeValue.toString();
    }
1063189
@Override
    public String getUserName() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getUserName");
        String userName = jcaConnectionFactory.getUserName();
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getUserName", userName);
        return userName;
    }
1114764
private function authenticateByToken()
    {
        $tokenType = $this->tokenType();
        $authToken = $this->tokenFactory()->create($tokenType);

        if ($authToken->metadata()->enabled() !== true) {
            return null;
        }

        $tokenData = $authToken->getTokenDataFromCookie();
        if (!$tokenData) {
            return null;
        }
        $userId = $authToken->getUserIdFromToken($tokenData['ident'], $tokenData['token']);
        if (!$userId) {
            return null;
        }

        $u = $this->userFactory()->create($this->userType());
        $u->load($userId);

        if ($u->id()) {
            $u->saveToSession();
            return $u;
        } else {
            return null;
        }
    }
882667
protected function getUserId()
    {
        try {
            if (Auth::check()) {
                return Auth::user()->getAuthIdentifier();
            }
        } catch (Exception $e) {
            Log::emergency($e);
            return;
        }

        return;
    }
1228409
public static String getUserName() throws Exception {
        Subject subject = getRunAsSubjectInternal();
        if (subject == null) {
            return null;
        }
        Set<Principal> principals = subject.getPrincipals();
        Iterator<Principal> principalsIterator = principals.iterator();
        if (principalsIterator.hasNext()) {
            Principal principal = principalsIterator.next();
            return principal.getName();
        }
        return null;
    }
713635
protected function getUsername()
    {

        // initialize the name
        $name = null;

        // query whether or not we've an principal
        if ($identity = $this->getIdentity()) {
            $name = $identity->getName();
        }

        // return the name
        return $name;
    }
811293
@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/username/{username}")
    @Description("Returns the user having the given username.")
    public PrincipalUserDto getUserByUsername(@Context HttpServletRequest req,
        @PathParam("username") final String userName) {

        Enumeration<String> headerNames = req.getHeaderNames();
        while(headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            String headerValue = req.getHeader(headerName);
            System.out.println(headerName + ": " + headerValue);
        }

        if (userName == null || userName.isEmpty()) {
            throw new WebApplicationException("Username cannot be null or empty.", Status.BAD_REQUEST);
        }

        PrincipalUser remoteUser = validateAndGetOwner(req, null);
        PrincipalUser user = _uService.findUserByUsername(userName);

        if (user != null) {
            super.validateResourceAuthorization(req, user, remoteUser);
            return PrincipalUserDto.transformToDto(user);
        } else if (!remoteUser.isPrivileged()) {
            throw new WebApplicationException(Response.Status.FORBIDDEN.getReasonPhrase(), Response.Status.FORBIDDEN);
        } else {
            throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
        }
    }
1309913
public function getAuthUserParamName() : ?string
   {

      foreach ( $this->_attributes as $attribute )
      {
         if ( Type::USERNAME_PARAM === $attribute->getType() )
         {
            return $attribute->getName();
         }
      }

      return null;

   }
374767
public function user()
    {
        /*
         * If we have already retrieved the user for the current request we can
         * just return it back immediately.
         */
        if (! is_null($this->user)) {
            return $this->user;
        }

        // Attempt to retrieve the token from the request
        $token = $this->jwt->getToken();
        if (! $token) {
            return null;
        }

        // Get the user associated with the token
        try {
            $user = $this->jwt->toUser($token);
        } catch (JWTException $e) {
            return null;
        }

        return $this->user = $user;
    }
1336112
public int auth_getUserId(String authToken)
    throws FacebookException, IOException {
    /*
     * Get the session information if we don't have it; this will populate
	   * the user ID as well.
	   */
    if (null == this._sessionKey)
      auth_getSession(authToken);
    return this._userId;
  }