Example usage for org.springframework.http.client.support BasicAuthenticationInterceptor BasicAuthenticationInterceptor

List of usage examples for org.springframework.http.client.support BasicAuthenticationInterceptor BasicAuthenticationInterceptor

Introduction

In this page you can find the example usage for org.springframework.http.client.support BasicAuthenticationInterceptor BasicAuthenticationInterceptor.

Prototype

public BasicAuthenticationInterceptor(String username, String password) 

Source Link

Document

Create a new interceptor which adds Basic Authentication for the given username and password.

Usage

From source file:com.bbva.arq.devops.ae.mirrorgate.collectors.jira.config.Config.java

@Bean(MIRRORGATE_REST_TEMPLATE)
public RestTemplate getRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    MappingJackson2HttpMessageConverter jsonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
    restTemplate.getMessageConverters().add(jsonHttpMessageConverter);
    if (!StringUtils.isBlank(mirrorGateUserName) && !StringUtils.isBlank(mirrorGatePassword)) {
        restTemplate.getInterceptors()//from w w w  .  j  a  v a 2  s. co  m
                .add(new BasicAuthenticationInterceptor(mirrorGateUserName, mirrorGatePassword));
    }

    return restTemplate;
}

From source file:com.bbva.arq.devops.ae.mirrorgate.collectors.jira.config.Config.java

@Bean(JIRA_REST_TEMPLATE)
public RestTemplate getJiraRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    MappingJackson2HttpMessageConverter jsonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
    restTemplate.getMessageConverters().add(jsonHttpMessageConverter);
    restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor(jiraUserName, jiraPassword));
    return restTemplate;
}