public Client getClientFor()

in providers/src/main/java/com/microsoft/alm/provider/JaxrsClientProvider.java [158:196]


    public Client getClientFor(final URI uri, final PromptBehavior promptBehavior, final Options options) {
        Debug.Assert(uri != null, "uri cannot be null");
        Debug.Assert(promptBehavior != null, "promptBehavior cannot be null");
        Debug.Assert(options != null, "options cannot be null");

        Client client = null;
        logger.info("Getting a jaxrs client for uri: {}.", uri);

        if (authenticator.isCredentialSupported()) {

            logger.debug("Getting a jaxrs client backed by basic auth.");
            final Credential credential = authenticator.getCredential(uri, promptBehavior);
            if (credential != null) {
                client = getClientWithUsernamePassword(credential.Username, credential.Password);
            }

        } else if (authenticator.isOAuth2TokenSupported()) {
            logger.debug("Getting a jaxrs client backed by OAuth2 token.");

            final TokenPair tokenPair = authenticator.getOAuth2TokenPair(uri, promptBehavior);
            client = getClientWithOAuth2RequestFilter(tokenPair);

        } else if (authenticator.isPersonalAccessTokenSupported()) {
            logger.debug("Getting a jaxrs client backed by PersonalAccessToken.");

            final Token token = authenticator.getPersonalAccessToken(
                    uri,
                    options.patGenerationOptions.tokenScope,
                    options.patGenerationOptions.displayName,
                    promptBehavior);

            if (token != null) {
                client = getClientWithUsernamePassword(authenticator.getAuthType(), token.Value);
            }
        }

        logger.debug("Successfully created an authenticated client for uri: {}? {}", uri, client != null);
        return client;
    }