Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
6fb1d1548b |
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
|||||||
<groupId>com.inteligr8</groupId>
|
<groupId>com.inteligr8</groupId>
|
||||||
<artifactId>github-api</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.1.1</version>
|
<version>1.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>GitHub API & Utilities</name>
|
<name>GitHub API & Utilities</name>
|
||||||
|
|
||||||
|
@ -15,8 +15,24 @@ import org.apache.http.impl.auth.BasicScheme;
|
|||||||
import org.apache.http.protocol.HttpContext;
|
import org.apache.http.protocol.HttpContext;
|
||||||
import org.apache.http.protocol.HttpCoreContext;
|
import org.apache.http.protocol.HttpCoreContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class allows the developer to force the sending of credentials on the
|
||||||
|
* first HTTP request. Without this interceptor, all requests will first try
|
||||||
|
* without credentials.
|
||||||
|
*
|
||||||
|
* A subsequent retry will happen only under certain HTTP status codes. Some
|
||||||
|
* services will return a 404 instead of an expected 401 or 403. This is for
|
||||||
|
* security reasons. As a side effect, it fools the Apache HTTP client into
|
||||||
|
* thinking that the resource does not exist, even if it were authorized. So
|
||||||
|
* it will not retry it with credentials.
|
||||||
|
*
|
||||||
|
* @author brian@inteligr8.com
|
||||||
|
*/
|
||||||
public class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
|
public class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see HttpRequestInterceptor#process(HttpRequest, HttpContext)
|
||||||
|
*/
|
||||||
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
|
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
|
||||||
AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
|
AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user