本文整理汇总了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")
));
}
示例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;
}
}
示例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<>();
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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<>();
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}