use of org.broadinstitute.dsde.workbench.client.sam.model.UserStatus in project terra-cli by DataBiosphere.
the class TerraUser method getUser.
/**
* Get the registered user object.
*/
public static TerraUser getUser(String email) {
UserStatus userStatus = SamService.fromContext().getUserInfo(email);
if (userStatus == null) {
throw new UserActionableException("User not found: " + email);
}
logger.info("Found user in SAM: {}", userStatus);
// lowercase the email so there is a consistent way of looking up the email address
// the email address casing in SAM may not match the case of what is provided by the user
String emailFromSAM = userStatus.getUserInfo().getUserEmail().toLowerCase();
String subjectIdFromSAM = userStatus.getUserInfo().getUserSubjectId();
// user is in the all-users group, enabled, and is in their google proxy group
boolean isEnabledFromSAM = userStatus.getEnabled().getLdap();
boolean isRegisteredFromSAM = userStatus.getEnabled().getAllUsersGroup() && userStatus.getEnabled().getGoogle();
return new TerraUser(emailFromSAM, subjectIdFromSAM, isRegisteredFromSAM, isEnabledFromSAM);
}
use of org.broadinstitute.dsde.workbench.client.sam.model.UserStatus in project terra-cli by DataBiosphere.
the class SamService method registerUser.
/**
* Call the SAM "/register/user/v1" endpoint to register the user who is currently logged in. This
* is not the same as inviting a user.
*/
public void registerUser() {
callWithRetries(() -> {
UserStatus userStatus = new UsersApi(apiClient).createUserV2();
logger.info("User registered in SAM: {}, {}", userStatus.getUserInfo().getUserSubjectId(), userStatus.getUserInfo().getUserEmail());
}, "Error registering new user in SAM.");
}
Aggregations