Adds a token-based {@link Authorizer}.
544856
public <T> HttpAuthServiceBuilder addTokenAuthorizer(
            Function<HttpHeaders, T> tokenExtractor, Authorizer<? super T> authorizer) {
        requireNonNull(tokenExtractor, "tokenExtractor");
        requireNonNull(authorizer, "authorizer");
        final Authorizer<HttpRequest> requestAuthorizer = (ctx, req) -> {
            final T token = tokenExtractor.apply(req.headers());
            if (token == null) {
                return CompletableFuture.completedFuture(false);
            }
            return authorizer.authorize(ctx, token);
        };
        add(requestAuthorizer);
        return this;
    }
212382
public ElasticHashinator addTokens(NavigableMap<Integer, Integer> tokensToAdd)
    {
        // figure out the interval
        long interval = deriveTokenInterval(m_tokensMap.get().keySet());

        Map<Integer, Integer> tokens = Maps.newTreeMap();
        for (Map.Entry<Integer, Integer> e : m_tokensMap.get().entrySet()) {
            if (tokensToAdd.containsKey(e.getKey())) {
                continue;
            }

            // see if we are moving an intermediate token forward
            if (isIntermediateToken(e.getKey(), interval)) {
                Map.Entry<Integer, Integer> floorEntry = tokensToAdd.floorEntry(e.getKey());
                // If the two tokens belong to the same partition and bucket, we are moving the one on the ring
                // forward, so remove it from the ring
                if (floorEntry != null &&
                    floorEntry.getValue().equals(e.getValue()) &&
                    containingBucket(floorEntry.getKey(), interval) == containingBucket(e.getKey(), interval)) {
                    continue;
                }
            }

            tokens.put(e.getKey(), e.getValue());
        }
        tokens.putAll(tokensToAdd);

        return new ElasticHashinator(ImmutableSortedMap.copyOf(tokens));
    }
486008
public TokenOrListParam add(String theSystem, String theValue) {
		add(new TokenParam(theSystem, theValue));
		return this;
	}
1222614
function AuthorizerBase(mainLogger, gmeConfig) {

    /**
     * @type {{PROJECT: string, USER: string}}
     */
    this.ENTITY_TYPES = ENTITY_TYPES;

    /**
     * @type {GmeConfig}
     */
    this.logger = mainLogger.fork('Authorizer');

    /**
     * @type {GmeLogger}
     */
    this.gmeConfig = gmeConfig;
}
577040
public void authorize(GSSContext context, String host)
	throws AuthorizationException {
	logger.debug("Authorization: HOST/SELF");

	try {

            GSSName expected = this.hostAuthz.getExpectedName(null, host);

            GSSName target = null;
            if (context.isInitiator()) {
                target = context.getTargName();
            } else {
                target = context.getSrcName();
            }

            if (!expected.equals(target)) {
                logger.debug("Host authorization failed. Expected "
                             + expected + " target is " + target);

                if (!context.getSrcName().equals(context.getTargName())) {
                    if (context.isInitiator()) {
                        expected = context.getSrcName();
                    } else {
                        expected = context.getTargName();
                    }
                    generateAuthorizationException(expected, target);
                }
            }
	} catch (GSSException e) {
	    throw new AuthorizationException("Authorization failure", e);
	}
    }
992211
private void insertOrUpdateToken(io.motown.ocpi.dto.Token tokenUpdate, Integer subscriptionId) {
        Token token = ocpiRepository.findTokenByUidAndIssuingCompany(tokenUpdate.uid, tokenUpdate.issuer);
        if (token == null) {
            token = new Token();
            token.setUid(tokenUpdate.uid);
            token.setSubscriptionId(subscriptionId);
            token.setDateCreated(new Date());
        }
        token.setTokenType(tokenUpdate.type);
        token.setAuthId(tokenUpdate.auth_id);
        token.setVisualNumber(tokenUpdate.visual_number);
        token.setIssuingCompany(tokenUpdate.issuer);
        token.setValid(tokenUpdate.valid);
        token.setWhitelist(tokenUpdate.whitelist);
        token.setLanguageCode(tokenUpdate.languageCode);

        try {
            token.setLastUpdated(AppConfig.DATE_FORMAT.parse(tokenUpdate.last_updated));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        ocpiRepository.insertOrUpdate(token);
    }
89036
def add_token(self, token_identifier, delegation_token):
    
    self.send_add_token(token_identifier, delegation_token)
    return self.recv_add_token()
409853
protected <T extends InvocationMarshaller<?>> T addProvider (
        InvocationProvider prov, Class<T> mclass)
    {
        return _plmgr.addProvider(prov, mclass);
    }
622374
public function authorizerToken($authorizerAppId, $authorizerRefreshToken)
    {
        return $this->auth(function () use ($authorizerAppId, $authorizerRefreshToken) {
            return $this->callHttp([
                'url' => 'api_authorizer_token?component_access_token=' . $this->accessToken,
                'data' => [
                    'component_appid' => $this->getAppId(),
                    'authorizer_appid' => $authorizerAppId,
                    'authorizer_refresh_token' => $authorizerRefreshToken,
                ],
            ]);
        });
    }
150356
private void addURIToAuthorize(final HttpServletRequest httpRequest, final URI uri) {
        @SuppressWarnings("unchecked")
        Set<URI> targetURIs = (Set<URI>) httpRequest.getAttribute(URIS_TO_AUTHORIZE);
        if (targetURIs == null) {
            targetURIs = new HashSet<>();
            httpRequest.setAttribute(URIS_TO_AUTHORIZE, targetURIs);
        }
        targetURIs.add(uri);
    }
230876
@Override
  public void addTokens(final byte[] tokens) {

    try (final DataInputBuffer buf = new DataInputBuffer()) {

      buf.reset(tokens, tokens.length);
      final Credentials credentials = new Credentials();
      credentials.readTokenStorageStream(buf);

      final UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
      ugi.addCredentials(credentials);
      LOG.log(Level.FINEST, "Added {0} tokens for user {1}", new Object[] {credentials.numberOfTokens(), ugi});

    } catch (final IOException ex) {
      LOG.log(Level.SEVERE, "Could not access tokens in user credentials.", ex);
      throw new RuntimeException(ex);
    }
  }
1155490
public static void initialize(String token, ExecutorService executor) {
    if (token == null) {
      throw new IllegalArgumentException("Token should be defined.");
    }
    if (executor == null) {
      throw new IllegalArgumentException("Executor should be defined.");
    }
    initialize(new ClientProperties(token, null, executor));
  }
820984
static <T> CompletionStage<Boolean> authorize(Authorizer<T> authorizer, ServiceRequestContext ctx, T data) {
        try {
            final CompletionStage<Boolean> f = authorizer.authorize(ctx, data);
            if (f == null) {
                throw new NullPointerException("An " + Authorizer.class.getSimpleName() +
                                               " returned null: " + authorizer);
            }
            return f;
        } catch (Throwable cause) {
            return CompletableFutures.exceptionallyCompletedFuture(cause);
        }
    }
326782
@Override
    public boolean authorizeURLRequest(Request.Builder builder) {
        loadTokens();
        if (IDToken != null && !haveSessionCookie) {
            String auth = String.format(Locale.ENGLISH, "Bearer ", IDToken);
            builder.addHeader("Authorization", auth);
            return true;
        } else {
            return false;
        }
    }
1206296
public static void authorize(Subject user, Class<?> protocol) 
  throws AuthorizationException {
    Permission permission = protocolToPermissionMap.get(protocol);
    if (permission == null) {
      permission = new ConnectionPermission(protocol);
      protocolToPermissionMap.put(protocol, permission);
    }
    
    checkPermission(user, permission);
  }
602222
public boolean add(Token token,
                       Transaction transaction)
                    throws ObjectManagerException
    {
        addEntry(token, transaction);
        return true;
    }
960403
public static void addAuthorizationHeader(URLConnection urlConnection, String header) {
        if (header != null) {
            urlConnection.setRequestProperty(AUTHORIZATION_HEADER, header);
        }
    }