com.google.api.client.http
Class BasicAuthentication

java.lang.Object
  extended by com.google.api.client.http.BasicAuthentication
All Implemented Interfaces:
HttpExecuteInterceptor, HttpRequestInitializer

public final class BasicAuthentication
extends Object
implements HttpRequestInitializer, HttpExecuteInterceptor

Basic authentication HTTP request initializer as specified in Basic Authentication Scheme

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).

Warning: for backwards-compatibility initialize(com.google.api.client.http.HttpRequest) also calls intercept(HttpRequest), but this call will be removed in version 1.8.

Since:
1.7
Author:
Yaniv Inbar

Constructor Summary
BasicAuthentication(String username, String password)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAuthentication

public BasicAuthentication(String username,
                           String password)
Method Detail

initialize

public void initialize(HttpRequest request)
                throws IOException
Description copied from interface: HttpRequestInitializer
Initializes a request.

Specified by:
initialize in interface HttpRequestInitializer
Parameters:
request - HTTP request
Throws:
IOException

intercept

public void intercept(HttpRequest request)
               throws IOException
Description copied from interface: HttpExecuteInterceptor
Invoked at the start of HttpRequest.execute() before executing the HTTP request.

Specified by:
intercept in interface HttpExecuteInterceptor
Throws:
IOException

getUsername

public String getUsername()
Returns the username.


getPassword

public String getPassword()
Returns the password.



Copyright © 2011-2012 Google. All Rights Reserved.