org.apache.wink.client.handlers
Class BasicAuthSecurityHandler

java.lang.Object
  extended by org.apache.wink.client.handlers.BasicAuthSecurityHandler
All Implemented Interfaces:
ClientHandler

public class BasicAuthSecurityHandler
extends java.lang.Object
implements ClientHandler

SecurityHandler for a client to perform http basic auth:

Usage:
ClientConfig config = new ClientConfig();
BasicAuthSecurityHandler basicAuth = new BasicAuthSecurityHandler();
basicAuth.setUserName("user1");
basicAuth.setPassword("password2");
config.handlers(basicAuth);
// create the rest client instance
RestClient client = new RestClient(config);
// create the resource instance to interact with Resource
resource = client.resource("https://localhost:8080/path/to/resource");


Constructor Summary
BasicAuthSecurityHandler()
           
 
Method Summary
 ClientResponse handle(ClientRequest request, HandlerContext context)
          Performs basic HTTP authentication.
 void setPassword(java.lang.String aPassword)
          Sets the password to use.
 void setUserName(java.lang.String aUserName)
          Sets the username to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAuthSecurityHandler

public BasicAuthSecurityHandler()
Method Detail

setUserName

public void setUserName(java.lang.String aUserName)
Sets the username to use.

Parameters:
aUserName - the user name

setPassword

public void setPassword(java.lang.String aPassword)
Sets the password to use.

Parameters:
aPassword - the password to use

handle

public ClientResponse handle(ClientRequest request,
                             HandlerContext context)
                      throws java.lang.Exception
Performs basic HTTP authentication.

Specified by:
handle in interface ClientHandler
Parameters:
client - request object
handler - context object
Returns:
a client response object that may contain an HTTP Authorization header
Throws:
java.lang.Exception - any exception can be thrown by a handler and it will be caught by the underlying client implementation and wrapped in a ClientRuntimeException


Copyright © 2009-2010 The Apache Software Foundation. All Rights Reserved.