org.openstack4j.api.exceptions.AuthenticationException Java Examples

The following examples show how to use org.openstack4j.api.exceptions.AuthenticationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NovaV3Launcher.java    From karamel with Apache License 2.0 5 votes vote down vote up
public static NovaV3Context validateCredentials(NovaCredentials novaCredentials)
        throws InvalidNovaCredentialsException {
  try {
    NovaV3Context context = new NovaV3Context(novaCredentials);
    context.authenticate();
    //this.novaContext.getCmpute().servers().list();
    return context;
  } catch (AuthenticationException e) {
    throw new InvalidNovaCredentialsException("account-name:" + novaCredentials.getAccountName(), e);
  }
}
 
Example #2
Source File: NovaV3Context.java    From karamel with Apache License 2.0 5 votes vote down vote up
public void reauth()
    throws AuthenticationException {
    // Re auth if token expired
  if (this.token.getExpires().getTime() > new Date().getTime()) {
    this.authenticate(); 
  }
  this.os = OSFactory.clientFromToken(this.token);
}
 
Example #3
Source File: OpenStackClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private Access createAccess(KeystoneCredentialView osCredential) {
    try {
        return OSFactory.builderV2().withConfig(config).endpoint(osCredential.getEndpoint())
                .credentials(osCredential.getUserName(), osCredential.getPassword())
                .tenantName(osCredential.getTenantName())
                .authenticate()
                .getAccess();
    } catch (AuthenticationException | ClientResponseException e) {
        LOGGER.info("Openstack authentication failed", e);
        throw new CredentialVerificationException("Authentication failed to openstack, message: " + e.getMessage(), e);
    }
}
 
Example #4
Source File: NovaV3Context.java    From karamel with Apache License 2.0 4 votes vote down vote up
public void authenticate()
    throws AuthenticationException {
  this.os = this.builder.authenticate();
  this.token = this.os.getToken();
}