Merge pull request #35 from simon3z/connectors

Code cleanup: quantum, client and command
examples: improve glance listing using ServiceCatalog

The GlanceListImages example is now using the ServiceCatalog returned
during the authentication to discover the glance endpoint.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
resteasy: use DefaultExecutor for ClientRequestFactory

Discover the ClientRequest DefaultExecutor instead of forcing the
ApacheHttpClient4Executor implementation.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
connectors: throw OpenStackNotAuthorized on auth failure

A new specific exception has been introduced to properly identify the
authorization errors with username/password and tokens.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
jersey2: support the empty server responses

Depending on whether we expect or not a responseType entity we should
use the appropriate method invocations.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
client: remove the unused guava dependency

The guava dependency is not used.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
access: remove specific tenants implementation

There's no need for a specific Tenant implementation inside the Access
model. The general entity can be used.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
access: move out the token implementation

Token shouldn't be a specific model inside Access. The code has been
moved to a separate class.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
client: move the OpenStackRequest token configuration

The OpenStackRequest configuration of enpoint and token has been
moved at the end of the process (just before the actual REST call).
The commands are now able to create their own OpenStackRequest
without depending on newOpenStackRequest (which has been removed).

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
command: rename execute to getCommandRequest

For consistency the method previously called "execute" has been renamed
to "getCommandRequest" since in fact it just returns the OpenStackRequest
to be executed.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
token: add the OpenStackTokenProvider mechanism

The interface OpenStackTokenProvider has been introduced to allow the
dynamic generation of tokens. Instead of defining a static token two
methods are provided (by the OpenStackTokenProvider interface):

- getToken(): to get the token to be used
- expireToken(): to signal the the token is unusable (wrong/expired)
  and it should be expunded

A basic implementation of the interface has been introduced to maintain
the ability to specify a static token: OpenStackSimpleTokenProvider.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
token: add the KeystoneTokenProvider

The KeystoneTokenProvider has been introduced as part of the new
OpenStackTokenProvider mechanism to provide dynamic tokens.
Once the KeystoneTokenProvider has been configured with endpoint,
username and password it's able to generate dynamic tokens (coping
with expiration) using the providers (per-tenant) generated by
getProviderByTenant.

Example of use:

  KeystoneTokenProvider keystone = new KeystoneTokenProvider(
          keystoneEndpoint, username, password);

  GlanceClient glance = new GlanceClient(glanceEndpoint);
  glance.setTokenProvider(keystone.getProviderByTenant(tenantName));

  Images images = glance.execute(new ListImages(false));

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>