Get the authentication token of the user for the provided cluster name in its Hadoop Token form.
@return null if the user does not have the token, otherwise the auth token for the cluster.
504489
private static Token<EsTokenIdentifier> getAuthToken(ClusterName clusterName, User user) {
        EsToken esToken = getEsAuthToken(clusterName, user);
        if (esToken == null) {
            return null;
        } else {
            return EsTokenIdentifier.createTokenFrom(esToken);
        }
    }
1110175
def cluster_manager(self):
        
        credentials = self.authenticator.get_credentials()['options']
        connection_string = str(self.connstr)
        return Admin(credentials.get('username'), credentials.get('password'), connection_string=connection_string)
266723
@Restricted(NoExternalUse.class)
    public @Nullable ApiTokenStore.HashedToken getLegacyTokenOf(@Nonnull User user) {
        ApiTokenProperty apiTokenProperty = user.getProperty(ApiTokenProperty.class);
        return apiTokenProperty.getTokenStore().getLegacyToken();
    }
1276301
public User getRemoteUser() {
        HttpServletRequest request = ServletActionContext.getRequest();

        if (request != null) {
            String remoteUserName = request.getRemoteUser();

            if (remoteUserName != null) {
                return getUserAccessor().getUserIfAvailable(remoteUserName);
            }
        }

        return AuthenticatedUserThreadLocal.getUser();
    }
276120
private function getUserId()
    {
        $id = null;

        if (null !== $this->tokenStorage && null !== $this->tokenStorage->getToken()) {
            $user = $this->tokenStorage->getToken()->getUser();

            if ($user instanceof UserInterface) {
                $id = $user->getId();
            }
        }

        return $id;
    }
1287924
static public function getToken()
    {
        if ( self::$token === null )
        {
            self::$token = sha1( self::getSecret() . self::getIntention() . session_id() );
        }

        return self::$token;
    }
645630
public static String getUserNameFromToken(String authToken) {
        if (null == authToken) {
            return null;
        }

        return authToken.split(TOKEN_SEPARATOR)[0];
    }
1328095
protected function getAuthUserId()
    {
        $token = $this->tokenStorage->getToken();
        if (null === $token) {
            return;
        }

        $user = $token->getUser();
        if (!is_object($user)) {
            return;
        }

        return $user->getId();
    }
369154
private String getAuthorizationToken(final HttpHeaders headers) {
        if (headers.getCookies() != null) {
            for (Map.Entry<String, Cookie> entry : headers.getCookies().entrySet()) {
                if (AuthorizationTokenCookie.COOKIE_NAME.equals(entry.getValue().getName())) {
                    return entry.getValue().getValue();
                }
            }
        }
        final List<String> header = headers.getRequestHeader("Authorization");
        if (header != null) {
            final String bearer = header.get(0);
            if (bearer != null) {
                return bearer.substring("Bearer ".length());
            }
        }
        return null;
    }
200876
@SuppressWarnings("unchecked")
  private String tokenViaExecCredential(Map<String, Object> execMap) {
    if (execMap == null) {
      return null;
    }
    String apiVersion = (String) execMap.get("apiVersion");
    if (!"client.authentication.k8s.io/v1beta1".equals(apiVersion)
        && !"client.authentication.k8s.io/v1alpha1".equals(apiVersion)) {
      log.error("Unrecognized user.exec.apiVersion: {}", apiVersion);
      return null;
    }
    String command = (String) execMap.get("command");
    JsonElement root = runExec(command, (List) execMap.get("args"), (List) execMap.get("env"));
    if (root == null) {
      return null;
    }
    if (!"ExecCredential".equals(root.getAsJsonObject().get("kind").getAsString())) {
      log.error("Unrecognized kind in response");
      return null;
    }
    if (!apiVersion.equals(root.getAsJsonObject().get("apiVersion").getAsString())) {
      log.error("Mismatched apiVersion in response");
      return null;
    }
    JsonObject status = root.getAsJsonObject().get("status").getAsJsonObject();
    JsonElement token = status.get("token");
    if (token == null) {
      // TODO handle clientCertificateData/clientKeyData
      // (KubeconfigAuthentication is not yet set up for that to be dynamic)
      log.warn("No token produced by {}", command);
      return null;
    }
    log.debug("Obtained a token from {}", command);
    return token.getAsString();
    // TODO cache tokens between calls, up to .status.expirationTimestamp
    // TODO a 401 is supposed to force a refresh,
    // but KubeconfigAuthentication hardcodes AccessTokenAuthentication which does not support that
    // and anyway ClientBuilder only calls Authenticator.provide once per ApiClient;
    // we would need to do it on every request
  }
781901
private function get_access_token() {
        global $SESSION;
        if (isset($SESSION->{self::SESSIONKEY}) && $SESSION->{self::SESSIONKEY}) {
            $this->client->setAccessToken($SESSION->{self::SESSIONKEY});
            return $SESSION->{self::SESSIONKEY};
        }
        return null;
    }
892001
private function getSecurityToken()
    {
        if ($this->container->get('security.context')->getToken() instanceof TokenInterface) {
            return $this->container->get('security.context')->getToken();
        }

        return null;
    }
600152
public Authentication getAuthentication(String token) {
		if (null != token) {
			TokenContainer container = tokens.get(token);
			if (null != container) {
				if (container.isValid()) {
					return container.getAuthentication();
				} else {
					logout(token);
				}
			}
		}
		return null;
	}
366965
public Token<DelegationTokenIdentifier> selectTokenFromFsOwner() throws IOException {
    return lookupToken(user.getCredentials(), service, tokenBinding.getKind());
  }
1245283
public function getUserId() {
    if (array_key_exists(self::USER_ATTR, $this->payload)) {
      return $this->payload[self::USER_ATTR];
    }
    throw new AuthException("No user_id in token");
  }
504003
private Map<String, String> getHttpHeaderStrong() throws Exception {
        
        final OAuthToken token = root.getOAuthTokenManager().getToken();
        
        if (token == null || token.getAccessToken().length() == 0 || token.getTokenType().length() == 0)
            throw new Exception ("OAuth token is not created (or is invalid) for strong authentication");
                
        return new HashMap<String, String>(){{
            put("Authorization", token.getTokenType() + " " + token.getAccessToken());
        }};
    }
1323825
public static String getCloudmadeToken() {

		if (mToken.length() == 0) {
			synchronized (mToken) {
				// check again because it may have been set while we were blocking
				if (mToken.length() == 0) {
					final String url = "http://auth.cloudmade.com/token/" + mKey + "?userid=" + mAndroidId;

					HttpURLConnection urlConnection=null;
					BufferedReader br=null;
					InputStreamReader is=null;
					try {
						final URL urlToRequest = new URL(url);
						urlConnection = (HttpURLConnection) urlToRequest.openConnection();
						urlConnection.setDoOutput(true);
						urlConnection.setRequestMethod("POST");
						urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
						urlConnection.setRequestProperty(Configuration.getInstance().getUserAgentHttpHeader(), Configuration.getInstance().getUserAgentValue());
						for (final Map.Entry<String, String> entry : Configuration.getInstance().getAdditionalHttpRequestProperties().entrySet()) {
							urlConnection.setRequestProperty(entry.getKey(), entry.getValue());
						}
						urlConnection.connect();
						if (DEBUGMODE) {
							Log.d(IMapView.LOGTAG,"Response from Cloudmade auth: " + urlConnection.getResponseMessage());
						}
						if (urlConnection.getResponseCode() == 200) {
							is = new InputStreamReader(urlConnection.getInputStream(),"UTF-8");
							br =new BufferedReader(is,StreamUtils.IO_BUFFER_SIZE);
							final String line = br.readLine();
							if (DEBUGMODE) {
								Log.d(IMapView.LOGTAG,"First line from Cloudmade auth: " + line);
							}
							mToken = line.trim();
							if (mToken.length() > 0) {
								mPreferenceEditor.putString(CLOUDMADE_TOKEN, mToken);
								mPreferenceEditor.commit();
								// we don't need the editor any more
								mPreferenceEditor = null;
							} else {
								Log.e(IMapView.LOGTAG,"No authorization token received from Cloudmade");
							}
						}
					} catch (final IOException e) {
						Log.e(IMapView.LOGTAG,"No authorization token received from Cloudmade: " + e);
					} finally {
						if (urlConnection!=null)
							try {
								urlConnection.disconnect();
							}
							catch (Exception ex){}
						if (br!=null)
							try{
								br.close();
							}catch (Exception ex){}
						if (is!=null)
							try{
								is.close();
							}catch (Exception ex){}
					}
				}
			}
		}

		return mToken;
	}