@Inject
protected AuthService authService;
protected Auth getAuth(String project) throws CloudException {
Auth unscoped = getUnscopedAuth();
List<Long> projectIds = authService.resolveProjectName(unscoped, project);
if (projectIds.size() == 0) {
throw new IllegalArgumentException("Cannot find project");
}
if (projectIds.size() != 1) {
throw new IllegalArgumentException("The project name is ambiguous");
}
Long projectId = projectIds.get(0);
Auth auth = authService.authenticate(projectId, username, password);
if (auth == null) {
throw new IllegalArgumentException("Cannot authenticate to project");
}
return auth;
}