当前位置: 首页>>代码示例>>Java>>正文


Java BasicAuthorizationInterceptor类代码示例

本文整理汇总了Java中org.springframework.http.client.support.BasicAuthorizationInterceptor的典型用法代码示例。如果您正苦于以下问题:Java BasicAuthorizationInterceptor类的具体用法?Java BasicAuthorizationInterceptor怎么用?Java BasicAuthorizationInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BasicAuthorizationInterceptor类属于org.springframework.http.client.support包,在下文中一共展示了BasicAuthorizationInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EmailServiceImpl

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
EmailServiceImpl(Environment env,
                 TextService text) {

    this.env     = requireNonNull(env);
    this.text    = requireNonNull(text);
    this.mailgun = new RestTemplate();

    this.mailgun.setMessageConverters(asList(
        new FormHttpMessageConverter(),
        new StringHttpMessageConverter(),
        new MappingJackson2HttpMessageConverter()
    ));

    this.mailgun.getInterceptors().add(new BasicAuthorizationInterceptor(
        "api", env.getProperty("mailgun.apiKey")
    ));
}
 
开发者ID:membaza,项目名称:users-service,代码行数:18,代码来源:EmailServiceImpl.java

示例2: getBotStatus

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public BotStatus getBotStatus(BotConfig botConfig) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + STATUS_RESOURCE_PATH;
        LOG.info(() -> "Fetching BotStatus from: " + endpointUrl);

        final BotStatus botStatus = restTemplate.getForObject(endpointUrl, BotStatus.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + botStatus);
        return botStatus;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:BotStatusRepositoryRestClient.java

示例3: findAll

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public List<StrategyConfig> findAll(BotConfig botConfig) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + STRATEGY_RESOURCE_PATH;
        LOG.info(() -> "Fetching all StrategyConfig from: " + endpointUrl);

        @SuppressWarnings("unchecked") final List<StrategyConfig> allTheStrategyConfig = restTemplate.getForObject(endpointUrl, List.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + allTheStrategyConfig);
        return allTheStrategyConfig;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return new ArrayList<>();
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:StrategyConfigRepositoryRestClient.java

示例4: findById

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public StrategyConfig findById(BotConfig botConfig, String strategyId) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + STRATEGY_RESOURCE_PATH + '/' + strategyId;
        LOG.info(() -> "Fetching StrategyConfig from: " + endpointUrl);

        @SuppressWarnings("unchecked") final StrategyConfig strategyConfig = restTemplate.getForObject(endpointUrl, StrategyConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + strategyConfig);
        return strategyConfig;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:StrategyConfigRepositoryRestClient.java

示例5: save

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public StrategyConfig save(BotConfig botConfig, StrategyConfig strategyConfig) {

    LOG.info(() -> "Saving StrategyConfig: " + strategyConfig + " for botId: " + botConfig.getId());

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + STRATEGY_RESOURCE_PATH;
        LOG.info(() -> "Sending StrategyConfig to: " + endpointUrl);

        final HttpEntity<StrategyConfig> requestUpdate = new HttpEntity<>(strategyConfig);
        final ResponseEntity<StrategyConfig> savedConfig = restTemplate.exchange(
                endpointUrl, HttpMethod.PUT, requestUpdate, StrategyConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + savedConfig.getBody());
        return savedConfig.getBody();

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:26,代码来源:StrategyConfigRepositoryRestClient.java

示例6: delete

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public boolean delete(BotConfig botConfig, String strategyId) {

    LOG.info(() -> "Deleting StrategyConfig for strategyId: " + strategyId + " for botId: " + botConfig.getId());

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + STRATEGY_RESOURCE_PATH + '/' + strategyId;
        LOG.info(() -> "Deleting StrategyConfig from: " + endpointUrl);

        restTemplate.delete(endpointUrl);
        return true;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return false;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:StrategyConfigRepositoryRestClient.java

示例7: findAll

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public List<MarketConfig> findAll(BotConfig botConfig) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + MARKET_RESOURCE_PATH;
        LOG.info(() -> "Fetching all MarketConfig from: " + endpointUrl);

        @SuppressWarnings("unchecked") final List<MarketConfig> allTheMarketConfig = restTemplate.getForObject(endpointUrl, List.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + allTheMarketConfig);
        return allTheMarketConfig;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return new ArrayList<>();
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:MarketConfigRepositoryRestClient.java

示例8: findById

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public MarketConfig findById(BotConfig botConfig, String marketId) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + MARKET_RESOURCE_PATH + '/' + marketId;
        LOG.info(() -> "Fetching MarketConfig from: " + endpointUrl);

        @SuppressWarnings("unchecked") final MarketConfig marketConfig = restTemplate.getForObject(endpointUrl, MarketConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + marketConfig);
        return marketConfig;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:MarketConfigRepositoryRestClient.java

示例9: save

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public MarketConfig save(BotConfig botConfig, MarketConfig marketConfig) {

    LOG.info(() -> "Saving MarketConfig: " + marketConfig + " for botId: " + botConfig.getId());

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + MARKET_RESOURCE_PATH;
        LOG.info(() -> "Sending MarketConfig to: " + endpointUrl);

        final HttpEntity<MarketConfig> requestUpdate = new HttpEntity<>(marketConfig);
        final ResponseEntity<MarketConfig> savedConfig = restTemplate.exchange(
                endpointUrl, HttpMethod.PUT, requestUpdate, MarketConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + savedConfig.getBody());
        return savedConfig.getBody();

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:26,代码来源:MarketConfigRepositoryRestClient.java

示例10: delete

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public boolean delete(BotConfig botConfig, String marketId) {

    LOG.info(() -> "Deleting MarketConfig for marketId: " + marketId + " for botId: " + botConfig.getId());

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + MARKET_RESOURCE_PATH + '/' + marketId;
        LOG.info(() -> "Deleting MarketConfig from: " + endpointUrl);

        restTemplate.delete(endpointUrl);
        return true;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return false;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:MarketConfigRepositoryRestClient.java

示例11: get

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public ExchangeConfig get(BotConfig botConfig) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + EXCHANGE_RESOURCE_PATH;
        LOG.info(() -> "Fetching ExchangeConfig from: " + endpointUrl);

        final ExchangeConfig config = restTemplate.getForObject(endpointUrl, ExchangeConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + config);
        return config;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:22,代码来源:ExchangeConfigRepositoryRestClient.java

示例12: save

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public ExchangeConfig save(BotConfig botConfig, ExchangeConfig exchangeConfig) {

    try {
        LOG.info(() -> "About to save ExchangeConfig: " + exchangeConfig);

        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + EXCHANGE_RESOURCE_PATH;
        LOG.info(() -> "Sending ExchangeConfig to: " + endpointUrl);

        final HttpEntity<ExchangeConfig> requestUpdate = new HttpEntity<>(exchangeConfig);
        final ResponseEntity<ExchangeConfig> savedConfig = restTemplate.exchange(
                endpointUrl, HttpMethod.PUT, requestUpdate, ExchangeConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + savedConfig);
        return savedConfig.getBody();

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:26,代码来源:ExchangeConfigRepositoryRestClient.java

示例13: get

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public EmailAlertsConfig get(BotConfig botConfig) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + EMAIL_ALERTS_RESOURCE_PATH;
        LOG.info(() -> "Fetching EmailAlertsConfig from: " + endpointUrl);

        final EmailAlertsConfig config = restTemplate.getForObject(endpointUrl, EmailAlertsConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + config);
        config.setId(botConfig.getId());
        return config;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:23,代码来源:EmailAlertsConfigRepositoryRestClient.java

示例14: save

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public EmailAlertsConfig save(BotConfig botConfig, EmailAlertsConfig emailAlertsConfig) {

    try {
        LOG.info(() -> "About to save EmailAlertsConfig: " + emailAlertsConfig);

        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + EMAIL_ALERTS_RESOURCE_PATH;
        LOG.info(() -> "Sending EmailAlertsConfig to: " + endpointUrl);

        final HttpEntity<EmailAlertsConfig> requestUpdate = new HttpEntity<>(emailAlertsConfig);
        final ResponseEntity<EmailAlertsConfig> savedConfig = restTemplate.exchange(
                endpointUrl, HttpMethod.PUT, requestUpdate, EmailAlertsConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + savedConfig);
        final EmailAlertsConfig savedConfigBody = savedConfig.getBody();
        savedConfigBody.setId(botConfig.getId());
        return savedConfigBody;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:28,代码来源:EmailAlertsConfigRepositoryRestClient.java

示例15: get

import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public EngineConfig get(BotConfig botConfig) {

    try {
        restTemplate.getInterceptors().clear();
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
                botConfig.getUsername(), botConfig.getPassword()));

        final String endpointUrl = botConfig.getBaseUrl() + ENGINE_RESOURCE_PATH;
        LOG.info(() -> "Fetching EngineConfig from: " + endpointUrl);

        final EngineConfig config = restTemplate.getForObject(endpointUrl, EngineConfig.class);

        LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + config);
        config.setId(botConfig.getId());
        return config;

    } catch (RestClientException e) {
        LOG.error(FAILED_TO_INVOKE_REMOTE_BOT_LOG_MSG + e.getMessage(), e);
        return null;
    }
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:23,代码来源:EngineConfigRepositoryRestClient.java


注:本文中的org.springframework.http.client.support.BasicAuthorizationInterceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。