diff options
Diffstat (limited to 'juick-notifications/src/main/java')
-rw-r--r-- | juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java index c17587ac..c7747aa1 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java @@ -7,9 +7,14 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.InterceptingClientHttpRequestFactory; +import org.springframework.http.client.support.BasicAuthorizationInterceptor; import org.springframework.web.client.RestTemplate; import javax.inject.Inject; +import java.util.Collections; +import java.util.List; /** * Created by aalexeev on 11/12/16. @@ -23,7 +28,13 @@ public class NotificationsAppConfiguration { @Bean public RestTemplate rest() { - return new RestTemplate(); + RestTemplate rest = new RestTemplate(); + List<ClientHttpRequestInterceptor> interceptors = Collections + .singletonList( + new BasicAuthorizationInterceptor(env.getProperty("api_user", "juick"), + env.getProperty("api_password", "secret"))); + rest.setRequestFactory(new InterceptingClientHttpRequestFactory(rest.getRequestFactory(), interceptors)); + return rest; } @Bean |