diff options
author | Vitaly Takmazov | 2016-11-15 16:43:30 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-15 16:43:30 +0300 |
commit | 4a1adf3e21e52a70799ebfa1b43f532d5696860e (patch) | |
tree | 32dbf4cb58cac5e4d4dc268b9e87ef582d097a1e /juick-notifications/src/main/java/com | |
parent | 2cfabeab2e64a1b8b6db32a0135a2fce06bc87ab (diff) |
juick-notifications: using http auth
Diffstat (limited to 'juick-notifications/src/main/java/com')
-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 |