本文整理汇总了Java中org.springframework.http.client.support.BasicAuthorizationInterceptor类的典型用法代码示例。如果您正苦于以下问题:Java BasicAuthorizationInterceptor类的具体用法?Java BasicAuthorizationInterceptor怎么用?Java BasicAuthorizationInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicAuthorizationInterceptor类属于org.springframework.http.client.support包,在下文中一共展示了BasicAuthorizationInterceptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: createRestTemplateBasicAuth
import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
/**
* register specific RestTemplate in Spring Application Context if needed
*/
private Consumer<Application> createRestTemplateBasicAuth(ConfigurableListableBeanFactory registry) {
return app -> {
// Create rest template instance
RestTemplate restTemplateBasicAuth = defaultRestTemplateConfig.restTemplate(requestFactory, Arrays.asList(defaultRestTemplateConfig.getDefaultAcceptHeader(), MediaType.ALL));
// Configure it with BASIC auth
restTemplateBasicAuth.getInterceptors().add(new BasicAuthorizationInterceptor(app.getActuatorUsername(), app.getActuatorPassword()));
LOGGER.info("Registered RestTemplate with BASIC auth for application with id {}", app.getId());
// Add bean in Spring application context
registry.registerSingleton(getRestTemplateBeanName(app), restTemplateBasicAuth);
};
}
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:19,代码来源:RestTemplateFactory.java
示例17: RestTemplateBuilder
import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
private RestTemplateBuilder(boolean detectRequestFactory, String rootUri,
Set<HttpMessageConverter<?>> messageConverters,
ClientHttpRequestFactory requestFactory,
UriTemplateHandler uriTemplateHandler, ResponseErrorHandler errorHandler,
BasicAuthorizationInterceptor basicAuthorization,
Set<RestTemplateCustomizer> restTemplateCustomizers,
Set<RequestFactoryCustomizer> requestFactoryCustomizers) {
super();
this.detectRequestFactory = detectRequestFactory;
this.rootUri = rootUri;
this.messageConverters = messageConverters;
this.requestFactory = requestFactory;
this.uriTemplateHandler = uriTemplateHandler;
this.errorHandler = errorHandler;
this.basicAuthorization = basicAuthorization;
this.restTemplateCustomizers = restTemplateCustomizers;
this.requestFactoryCustomizers = requestFactoryCustomizers;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:RestTemplateBuilder.java
示例18: run
import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Bean
public CommandLineRunner run(RestTemplate restTemplate) {
return args -> {
restTemplate.getInterceptors().add(
new BasicAuthorizationInterceptor(alfredUsername, alfredPassword));
// oldSchool(restTemplate);
newSchool(restTemplate);
};
}
开发者ID:avdyk,项目名称:be.liege.cti.ged,代码行数:10,代码来源:SearchCategories.java
示例19: AlfredServiceImpl
import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
AlfredServiceImpl(final RestTemplateBuilder restTemplateBuilder,
final NodeReferenceBuilder nodeReferenceBuilder,
final String url,
final String username,
final String password) {
this.nodeReferenceBuilder = nodeReferenceBuilder;
this.url = url;
restTemplate = restTemplateBuilder.build();
// restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
restTemplate.getInterceptors().add(
new BasicAuthorizationInterceptor(username, password != null ? password : ""));
logger.debug("Creation of AlfredServiceImpl for URL {}", url);
}
开发者ID:avdyk,项目名称:be.liege.cti.ged,代码行数:15,代码来源:AlfredServiceImpl.java
示例20: save
import org.springframework.http.client.support.BasicAuthorizationInterceptor; //导入依赖的package包/类
@Override
public EngineConfig save(BotConfig botConfig, EngineConfig engineConfig) {
try {
LOG.info(() -> "About to save EngineConfig: " + engineConfig);
restTemplate.getInterceptors().clear();
restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(
botConfig.getUsername(), botConfig.getPassword()));
final String endpointUrl = botConfig.getBaseUrl() + ENGINE_RESOURCE_PATH;
LOG.info(() -> "Sending EngineConfig to: " + endpointUrl);
final HttpEntity<EngineConfig> requestUpdate = new HttpEntity<>(engineConfig);
final ResponseEntity<EngineConfig> savedConfig = restTemplate.exchange(
endpointUrl, HttpMethod.PUT, requestUpdate, EngineConfig.class);
LOG.info(() -> REMOTE_RESPONSE_RECEIVED_LOG_MSG + savedConfig);
final EngineConfig 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,代码来源:EngineConfigRepositoryRestClient.java
注:本文中的org.springframework.http.client.support.BasicAuthorizationInterceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论