public final class BasicAuthentication extends Object implements HttpRequestInitializer, HttpExecuteInterceptor
Implementation is immutable and thread-safe. It can be used as either an HTTP request
initializer or an HTTP request execute interceptor. initialize(HttpRequest)
only sets
itself as the interceptor. Authentication is actually done in intercept(HttpRequest)
,
which is implemented using HttpHeaders.setBasicAuthentication(String, String)
.
Constructor and Description |
---|
BasicAuthentication(String username,
String password) |
Modifier and Type | Method and Description |
---|---|
String |
getPassword()
Returns the password.
|
String |
getUsername()
Returns the username.
|
void |
initialize(HttpRequest request)
Initializes a request.
|
void |
intercept(HttpRequest request)
Invoked at the start of
HttpRequest.execute() before executing the HTTP request. |
public void initialize(HttpRequest request) throws IOException
HttpRequestInitializer
initialize
in interface HttpRequestInitializer
request
- HTTP requestIOException
public void intercept(HttpRequest request) throws IOException
HttpExecuteInterceptor
HttpRequest.execute()
before executing the HTTP request.intercept
in interface HttpExecuteInterceptor
IOException
public String getUsername()
public String getPassword()
Copyright © 2011–2023 Google. All rights reserved.