@Override
protected UserData run0() throws CloudException {
log.info("Creating user: {}", username);
DomainData domain = identityService.getDefaultDomain();
if (domain == null) {
throw new UnsupportedOperationException();
}
UserData.Builder userBuilder = UserData.newBuilder();
userBuilder.setName(username);
// userBuilder.setEmail(username);
userBuilder.setEnabled(true);
UserData user = identityService.createUser(new UserCreationData(domain, userBuilder, password));
Long projectId = null;
AuthenticatedUser authenticatedUser = loginService.authenticate(projectId, username, password);
if (authenticatedUser == null) {
throw new IllegalStateException();
}
boolean CREATE_PROJECT = false;
if (CREATE_PROJECT) {
ProjectData.Builder projectBuilder = ProjectData.newBuilder();
projectBuilder.setName("default");
projectBuilder.setDomainId(domain.getId());
ProjectData project = identityService.createProject(projectBuilder, authenticatedUser,
WellKnownRoles.ROLE_ID_ADMIN);
if (project == null) {
throw new IllegalStateException();