com.intel.cosbench.client.keystone
Class KeystoneClient

java.lang.Object
  extended by com.intel.cosbench.client.keystone.KeystoneClient

public class KeystoneClient
extends java.lang.Object

A client for Openstack keystone authentication service.
The client can be used to obtain a valid keystone token in exchange of correct credentials. According to keystone, there are different ways to achieve this:

  1. Simple Authentication
  2. Supply the user name and password to get an authentication token. The token may or may not be scoped, depending on whether the user has a default tenant configured in keystone.

  3. Scoped Authentication
  4. Supply the user name and password along with a tenant info to get a token that will be scoped with the specified tenant. The tenant info can be either it's name or it's id.

  5. Token Authentication
  6. Supply an un-scoped keystone token obtained previously with a tenant info in order to get a new token that will be scoped with the specified tenant.

Author:
qzheng (qing.zheng@intel.com)

Constructor Summary
KeystoneClient(org.apache.http.client.HttpClient client, java.lang.String url, java.lang.String username, java.lang.String password, int timeout)
           
 
Method Summary
 void dispose()
           
 AuthHandler getHandler()
           
 java.lang.String getKeystoneTokenId()
          Retrieve the keystone token id associated with this client.
 java.lang.String getPassword()
           
 KeystoneResponse.AccessInfo.ServiceInfo getServiceInfo(java.lang.String serviceName)
          Retrieve the information regarding a cloud service identified by the given name.
 java.lang.String getServiceUrl(java.lang.String serviceName)
          Retrieve the public URL of a cloud service identified by the given name.
 java.lang.String getTenantId()
           
 java.lang.String getTenantName()
           
 KeystoneResponse.AccessInfo.Token getToken()
           
 KeystoneResponse.AccessInfo.User getUser()
           
 java.lang.String getUsername()
           
 java.lang.String getUserToken()
           
 boolean isAuthenticated()
           
 void login()
          Perform the authentication against a keystone service.
 void setHandler(AuthHandler handler)
           
 void setPassword(java.lang.String password)
           
 void setTenantId(java.lang.String tenantId)
           
 void setTenantName(java.lang.String tenantName)
           
 void setUsername(java.lang.String username)
           
 void setUserToken(java.lang.String userToken)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeystoneClient

public KeystoneClient(org.apache.http.client.HttpClient client,
                      java.lang.String url,
                      java.lang.String username,
                      java.lang.String password,
                      int timeout)
Method Detail

login

public void login()
Perform the authentication against a keystone service. Once the authentication is successfully completed, the results can be retrieved from the client instance.

See Also:
getKeystoneTokenId(), getServiceUrl(String)

isAuthenticated

public boolean isAuthenticated()

getUsername

public java.lang.String getUsername()

setUsername

public void setUsername(java.lang.String username)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getUserToken

public java.lang.String getUserToken()

setUserToken

public void setUserToken(java.lang.String userToken)

getTenantId

public java.lang.String getTenantId()

setTenantId

public void setTenantId(java.lang.String tenantId)

getTenantName

public java.lang.String getTenantName()

setTenantName

public void setTenantName(java.lang.String tenantName)

getHandler

public AuthHandler getHandler()

setHandler

public void setHandler(AuthHandler handler)

getKeystoneTokenId

public java.lang.String getKeystoneTokenId()
Retrieve the keystone token id associated with this client. A keystone token represents an authenticated user to keystone or other cloud services that rely on keystone for authentication. This method should only be called after the client has successfully performed an authentication against the keystone service, null will be returned otherwise.

Returns:
the keystone token id

getServiceUrl

public java.lang.String getServiceUrl(java.lang.String serviceName)
Retrieve the public URL of a cloud service identified by the given name. This method should only be called after the client has successfully performed an authentication against the keystone service, null will be returned otherwise.

Parameters:
serviceName - - the name identifying the service
Returns:
the public URL of a cloud service

getServiceInfo

public KeystoneResponse.AccessInfo.ServiceInfo getServiceInfo(java.lang.String serviceName)
Retrieve the information regarding a cloud service identified by the given name. This method should only be called after the client has successfully performed an authentication against the keystone service, null will be returned otherwise.

Parameters:
serviceName - - the name identifying the service
Returns:
the information regarding a cloud service

getUser

public KeystoneResponse.AccessInfo.User getUser()

getToken

public KeystoneResponse.AccessInfo.Token getToken()

dispose

public void dispose()