Skip to content

An implementation of Spring’s RestTemplate with pre-emptive Basic and Digest authentication

License

Notifications You must be signed in to change notification settings

kytkemo/preemptive-authentication-rest-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

preemptive-authentication-rest-template

An implementation of Spring’s RestTemplate with pre-emptive Basic and Digest authentication. Supports one authentication scheme per host.

Install

Install the dependency to your local Maven repository with mvn clean install.

Usage

Add the dependency to your project’s pom.xml.

<dependency>
    <groupId>com.kytkemo</groupId>
    <artifactId>preemptive-authentication-rest-template</artifactId>
    <version>1.1.6</version>
</dependency>

Create an instance of PreemptiveAuthenticationRestTemplate and set the required credentials. Apart from that, PreemptiveAuthenticationRestTemplate behaves same as the default implementation for RestTemplate.

HttpHost host = new HttpHost("domain.com", 443, "https");

PreemptiveAuthenticationRestTemplate restTemplate = new PreemptiveAuthenticationRestTemplate();
restTemplate.setCredentials(host, PreemptiveAuthenticationScheme.BASIC_AUTHENTICATION, "username", "password");

Secret secret = restTemplate.getForObject("https://domain.com/secret/", Secret.class);

About

An implementation of Spring’s RestTemplate with pre-emptive Basic and Digest authentication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages