use of org.pmiops.workbench.db.model.User in project workbench by all-of-us.
the class ProfileController method submitIdVerification.
@Override
public ResponseEntity<Profile> submitIdVerification(IdVerificationRequest request) {
// TODO(dmohs): Prevent this if the user has already attempted verification?
Person person = blockscoreService.createPerson(request.getFirstName(), request.getLastName(), new Address().setStreet1(request.getStreetLine1()).setStreet2(request.getStreetLine2()).setCity(request.getCity()).setSubdivision(request.getState()).setPostalCode(request.getZip()).setCountryCode("US"), request.getDob(), request.getDocumentType(), request.getDocumentNumber());
User user = userService.setBlockscoreIdVerification(person.getId(), person.isValid());
return getProfileResponse(user);
}
use of org.pmiops.workbench.db.model.User in project workbench by all-of-us.
the class ProfileController method getIdVerificationsForReview.
@Override
@AuthorityRequired({ Authority.REVIEW_ID_VERIFICATION })
public ResponseEntity<IdVerificationListResponse> getIdVerificationsForReview() {
IdVerificationListResponse response = new IdVerificationListResponse();
List<Profile> responseList = new ArrayList<Profile>();
try {
for (User user : userService.getNonVerifiedUsers()) {
responseList.add(profileService.getProfile(user));
}
} catch (ApiException e) {
log.log(Level.INFO, "Error calling FireCloud", e);
return ResponseEntity.status(e.getCode()).build();
}
response.setProfileList(responseList);
return ResponseEntity.ok(response);
}
use of org.pmiops.workbench.db.model.User in project workbench by all-of-us.
the class WorkspacesController method createWorkspace.
@Override
public ResponseEntity<Workspace> createWorkspace(Workspace workspace) {
if (Strings.isNullOrEmpty(workspace.getNamespace())) {
throw new BadRequestException("missing required field 'namespace'");
} else if (Strings.isNullOrEmpty(workspace.getName())) {
throw new BadRequestException("missing required field 'name'");
} else if (workspace.getResearchPurpose() == null) {
throw new BadRequestException("missing required field 'researchPurpose'");
} else if (workspace.getDataAccessLevel() == null) {
throw new BadRequestException("missing required field 'dataAccessLevel'");
}
User user = userProvider.get();
org.pmiops.workbench.db.model.Workspace existingWorkspace = workspaceService.getByName(workspace.getNamespace(), workspace.getName());
if (existingWorkspace != null) {
throw new ConflictException(String.format("Workspace %s/%s already exists", workspace.getNamespace(), workspace.getName()));
}
// Note: please keep any initialization logic here in sync with CloneWorkspace().
FirecloudWorkspaceId workspaceId = generateFirecloudWorkspaceId(workspace.getNamespace(), workspace.getName());
FirecloudWorkspaceId fcWorkspaceId = workspaceId;
org.pmiops.workbench.firecloud.model.Workspace fcWorkspace = null;
for (int attemptValue = 0; attemptValue < MAX_FC_CREATION_ATTEMPT_VALUES; attemptValue++) {
try {
fcWorkspace = attemptFirecloudWorkspaceCreation(fcWorkspaceId);
break;
} catch (ConflictException e) {
if (attemptValue >= 5) {
throw e;
} else {
fcWorkspaceId = new FirecloudWorkspaceId(workspaceId.getWorkspaceNamespace(), workspaceId.getWorkspaceName() + Integer.toString(attemptValue));
}
}
}
Timestamp now = new Timestamp(clock.instant().toEpochMilli());
org.pmiops.workbench.db.model.Workspace dbWorkspace = new org.pmiops.workbench.db.model.Workspace();
dbWorkspace.setFirecloudName(fcWorkspaceId.getWorkspaceName());
dbWorkspace.setWorkspaceNamespace(fcWorkspaceId.getWorkspaceNamespace());
dbWorkspace.setCreator(user);
dbWorkspace.setCreationTime(now);
dbWorkspace.setLastModifiedTime(now);
dbWorkspace.setVersion(1);
setCdrVersionId(dbWorkspace, workspace.getCdrVersionId());
writeWorkspaceConfigFile(fcWorkspace, dbWorkspace.getCdrVersion());
org.pmiops.workbench.db.model.Workspace reqWorkspace = FROM_CLIENT_WORKSPACE.apply(workspace);
// TODO: enforce data access level authorization
dbWorkspace.setDataAccessLevel(reqWorkspace.getDataAccessLevel());
dbWorkspace.setName(reqWorkspace.getName());
dbWorkspace.setDescription(reqWorkspace.getDescription());
// Ignore incoming fields pertaining to review status; clients can only request a review.
setResearchPurposeDetails(dbWorkspace, workspace.getResearchPurpose());
if (reqWorkspace.getReviewRequested()) {
// Use a consistent timestamp.
dbWorkspace.setTimeRequested(now);
}
dbWorkspace.setReviewRequested(reqWorkspace.getReviewRequested());
org.pmiops.workbench.db.model.WorkspaceUserRole permissions = new org.pmiops.workbench.db.model.WorkspaceUserRole();
permissions.setRole(WorkspaceAccessLevel.OWNER);
permissions.setWorkspace(dbWorkspace);
permissions.setUser(user);
dbWorkspace.addWorkspaceUserRole(permissions);
dbWorkspace = workspaceService.getDao().save(dbWorkspace);
return ResponseEntity.ok(TO_SINGLE_CLIENT_WORKSPACE_FROM_FC_AND_DB.apply(dbWorkspace, fcWorkspace));
}
use of org.pmiops.workbench.db.model.User in project workbench by all-of-us.
the class AuthDomainController method addUserToAuthDomain.
@Override
@AuthorityRequired({ Authority.MANAGE_GROUP })
public ResponseEntity<Void> addUserToAuthDomain(String groupName, AuthDomainRequest request) {
User user = userDao.findUserByEmail(request.getEmail());
DataAccessLevel previousAccess = user.getDataAccessLevel();
try {
fireCloudService.addUserToGroup(request.getEmail(), groupName);
} catch (ApiException e) {
ExceptionUtils.convertFirecloudException(e);
}
// TODO(blrubenstein): Parameterize this.
user.setDataAccessLevel(DataAccessLevel.REGISTERED);
user.setDisabled(false);
userDao.save(user);
userService.logAdminUserAction(user.getUserId(), "user access to " + groupName + " domain", previousAccess, DataAccessLevel.REGISTERED);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
use of org.pmiops.workbench.db.model.User in project workbench by all-of-us.
the class ProfileControllerTest method assertUser.
private void assertUser(String primaryEmail, String contactEmail, String familyName, String givenName, DataAccessLevel dataAccessLevel, Timestamp firstSignInTime, String freeTierBillingProject) {
User user = userDao.findUserByEmail(primaryEmail);
assertThat(user).isNotNull();
assertThat(user.getContactEmail()).isEqualTo(contactEmail);
assertThat(user.getFamilyName()).isEqualTo(familyName);
assertThat(user.getGivenName()).isEqualTo(givenName);
assertThat(user.getDataAccessLevel()).isEqualTo(dataAccessLevel);
assertThat(user.getFirstSignInTime()).isEqualTo(firstSignInTime);
assertThat(user.getFreeTierBillingProjectName()).isEqualTo(freeTierBillingProject);
assertThat(user.getDataAccessLevel()).isEqualTo(dataAccessLevel);
}
Aggregations