}
private AuthenticatedUser toAuthenticationV2(DomainData domain, ProjectSpec projectSpec,
UserWithSecret userWithSecret) throws CloudException {
ProjectData project = null;
ProjectRoles projectRoles = null;
UserData user = userWithSecret.getUserData();
if (projectSpec.projectId != 0) {
return buildProjectToken(domain, projectSpec.projectId, userWithSecret);
} else if (!Strings.isNullOrEmpty(projectSpec.projectName)) {
for (ProjectRoles i : user.getProjectRolesList()) {
ProjectData p = authRepository.getProjects().find(i.getProject());
if (p == null) {
continue;
}
if (projectSpec.projectName.equals(p.getName())) {
projectRoles = i;
project = p;
break;
}
}