Used to respond to server SASL tokens.
@param token Server's SASL token
@return response to send back to the server.
353177
public synchronized byte[] response(byte[] token) {
    try {
      return saslServer != null ? saslServer.evaluateResponse(token) : new byte[0];
    } catch (SaslException e) {
      throw Throwables.propagate(e);
    }
  }
407299
public Optional<String> authenticate(String token) {
    String tokenHash = tokenGenerator.hash(token);
    try (DbSession dbSession = dbClient.openSession(false)) {
      UserTokenDto userToken = dbClient.userTokenDao().selectByTokenHash(dbSession, tokenHash);
      if (userToken == null) {
        return empty();
      }
      userLastConnectionDatesUpdater.updateLastConnectionDateIfNeeded(userToken);
      return of(userToken.getUserUuid());
    }
  }
168874
public final boolean isValid(HttpServletRequest req, String token) {
		String storedToken = getStoredToken(req);
		
		if (storedToken == null)
			return false;
		
		return storedToken.equals(token);
	}
944358
async def _sasl_respond(self):
        
        # Formulate a response.
        if self._sasl_client:
            try:
                response = self._sasl_client.process(self._sasl_challenge)
            except puresasl.SASLError:
                response = None

            if response is None:
                self.logger.warning('SASL challenge processing failed: aborting SASL authentication.')
                await self._sasl_abort()
        else:
            response = b''

        response = base64.b64encode(response).decode(self.encoding)
        to_send = len(response)
        self._sasl_challenge = b''

        # Send response in chunks.
        while to_send > 0:
            await self.rawmsg('AUTHENTICATE', response[:RESPONSE_LIMIT])
            response = response[RESPONSE_LIMIT:]
            to_send -= RESPONSE_LIMIT

        # If our message fit exactly in SASL_RESPOSE_LIMIT-byte chunks, send an empty message to indicate we're done.
        if to_send == 0:
            await self.rawmsg('AUTHENTICATE', EMPTY_MESSAGE)
723513
public boolean resetPassword(String password, String token) {
		UserRecoverRequest req = this.retrieveRecoverRequest(token);
		if (req == null)
			return false;
		User user = req.getUser();
		user.setPassword(CryptManager.passwordHash(password));
		this.dao.persist(user);
		req.setRecover(new Date());
		req.setRecoverIp(this.request.getRemoteAddr());
		req.setUsed(true);
		this.dao.persist(req);
		return true;
	}
353856
private String getTokenOrBlank(final List<String> tokens, final int reverseIndex) {

		final int length = tokens.size();
		final int index  = length - reverseIndex - 1;

		if (index >= 0 && length > 0 && index < length) {
			return tokens.get(index);
		}

		return "";
	}
1246616
public static SematextClient newInstance(String token) {
    if (token == null) {
      throw new IllegalArgumentException("Token should be defined.");
    }
    return newInstance(new ClientProperties(token, null, null));
  }
1320215
public function createSession(Token $token)
    {
        $response = $this->sendInstallationPostRequest(
            '/v1/session-server',
            [
                'headers' => [
                    'X-Bunq-Client-Authentication' => $token->toString(),
                ],
                'json'    => [
                    'secret' => $this->apiKey,
                ],
            ]
        );

        $responseArray = \json_decode((string)$response->getBody(), true);

        return $responseArray['Response'][1]['Token']['token'];
    }
222183
private static TokenRange tokenRange(Token token) {
        JavaToken javaToken = token.javaToken;
        return new TokenRange(javaToken, javaToken);
    }
38572
public static final void signAuthToken(AuthToken token) {
        String signature = generateSignature(token);
        token.setSignature(signature);
    }
150053
private void checkToken(String token) {
        for (int i = 0; i < token.length(); i++) {
            char ch = token.charAt(i);
            if (!TOKEN.get(ch)) {
                throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + token + "\"");
            }
        }
    }
983965
public <T> T execute(String token, WePayRequest<T> req) throws IOException, WePayException {

		String uri = currentUrl + req.getEndpoint();

		String postJson = MAPPER.writeValueAsString(req);

		if (log.isTraceEnabled()) {
			log.trace("request to {}:  {}", uri, postJson);
		}

		// Use the data provider to get an input stream response. This is faked out in tests.
		InputStream is = dataProvider.getData(uri, postJson, token);

		JsonNode resp;
		if (log.isTraceEnabled()) {
			String results = IOUtils.toString(is);
			log.trace("response: " + results);
			resp = MAPPER.readTree(results);
		} else {
			resp = MAPPER.readTree(is);
		}

		// if there is an error in the response from wepay, it'll get thrown in this call.
		this.checkForError(resp);

		// This is a little bit of black magic with jackson.  We know that any request passed extends
		// the abstract WePayRequest and de-genericizes it.  This means the concrete class has full
		// generic type information, and we can use this to determine what type to deserialize.  The
		// trickiest case is WePayAccountFindRequest, whose response type is List<AccountWithUri>.
		ParameterizedType paramType = (ParameterizedType)req.getClass().getGenericSuperclass();
		JavaType type = MAPPER.constructType(paramType.getActualTypeArguments()[0]);

		return MAPPER.readValue(MAPPER.treeAsTokens(resp), type);
	}
59796
@Deprecated
    public static TokenResponse getTokenFromSaml(SAMLBearerRequest tokenRequest) throws ClientException {
        Result<TokenResponse> responseResult = getTokenFromSamlResult(tokenRequest);
        if (responseResult.isSuccess()) {
            return responseResult.getResult();
        }
        throw new ClientException(responseResult.getError());
    }
354540
public String findUsername( String token ) {
		return token == null ? null : this.tokenToUsername.get( token );
	}
1047518
@NotNull
    @ObjectiveCName("joinGroupViaLinkCommandWithToken:")
    public Command<Integer> joinGroupViaToken(String token) {
        return callback -> modules.getGroupsModule().joinGroupByToken(token)
                .then(v -> callback.onResult(v))
                .failure(e -> callback.onError(e));
    }
1242943
public Token createToken(Token token) throws BaseException {
		
		logger.debug("Enter TokenService::createToken");

		// prepare API url
		String apiUrl = requestContext.getBaseUrl() + "tokens";
		logger.info("apiUrl - " + apiUrl);

		// assign TypeReference for deserialization
		TypeReference<Token> typeReference = new TypeReference<Token>() {
		};

		// prepare service request
		Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).ignoreAuthHeader(true)
				.requestObject(token).typeReference(typeReference).context(requestContext).build();

		// make API call
		Response response = sendRequest(request);
		// retrieve response
		Token tokenResponse = (Token) response.getResponseObject();

		// set additional attributes
		prepareResponse(request, response, tokenResponse);
		return tokenResponse;
	}
188721
public TokenRequest setTokenServerUrl(GenericUrl tokenServerUrl) {
    this.tokenServerUrl = tokenServerUrl;
    Preconditions.checkArgument(tokenServerUrl.getFragment() == null);
    return this;
  }