use of io.hops.hopsworks.persistence.entity.user.BbcGroup in project hopsworks by logicalclocks.
the class AirflowManager method getUserRoles.
private String[] getUserRoles(Users p) {
Collection<BbcGroup> groupList = p.getBbcGroupCollection();
String[] roles = new String[groupList.size()];
int idx = 0;
for (BbcGroup g : groupList) {
roles[idx] = g.getGroupName();
idx++;
}
return roles;
}
use of io.hops.hopsworks.persistence.entity.user.BbcGroup in project hopsworks by logicalclocks.
the class ClusterController method checkUserPasswordAndStatus.
private void checkUserPasswordAndStatus(ClusterDTO cluster, Users clusterAgent, HttpServletRequest req) throws UserException {
authController.checkPasswordAndStatus(clusterAgent, cluster.getChosenPassword());
BbcGroup group = groupFacade.findByGroupName(CLUSTER_GROUP);
if (!clusterAgent.getBbcGroupCollection().contains(group)) {
throw new SecurityException("User not allowed to register clusters.");
}
}
use of io.hops.hopsworks.persistence.entity.user.BbcGroup in project hopsworks by logicalclocks.
the class ClusterController method isOnlyClusterAgent.
private boolean isOnlyClusterAgent(Users u) {
BbcGroup group = groupFacade.findByGroupName(CLUSTER_GROUP);
boolean isInClusterAgent = u.getBbcGroupCollection().contains(group);
return u.getBbcGroupCollection().size() == 1 && isInClusterAgent;
}
use of io.hops.hopsworks.persistence.entity.user.BbcGroup in project hopsworks by logicalclocks.
the class ClusterController method bbcGroups.
private List<BbcGroup> bbcGroups() {
BbcGroup group = groupFacade.findByGroupName(CLUSTER_GROUP);
Integer gid = groupFacade.lastGroupID() + 1;
if (group == null) {
// do this in chef?
group = new BbcGroup(gid, CLUSTER_GROUP);
group.setGroupDesc("Clusters outside the system");
groupFacade.save(group);
}
List<BbcGroup> groups = new ArrayList<>();
groups.add(group);
return groups;
}
use of io.hops.hopsworks.persistence.entity.user.BbcGroup in project hopsworks by logicalclocks.
the class UsersController method createNewUser.
/**
* Create a new user
*
* @param newUser
* @param accountStatus
* @param accountType
* @return
*/
public Users createNewUser(UserDTO newUser, UserAccountStatus accountStatus, UserAccountType accountType) {
String otpSecret = securityUtils.calculateSecretKey();
String activationKey = securityUtils.generateSecureRandomString();
String uname = generateUsername(newUser.getEmail());
List<BbcGroup> groups = new ArrayList<>();
Secret secret = securityUtils.generateSecret(newUser.getChosenPassword());
Timestamp now = new Timestamp(new Date().getTime());
int maxNumProjects = newUser.getMaxNumProjects() > 0 ? newUser.getMaxNumProjects() : settings.getMaxNumProjPerUser();
Users user = new Users(uname, secret.getSha256HexDigest(), newUser.getEmail(), newUser.getFirstName(), newUser.getLastName(), now, "-", "-", accountStatus, otpSecret, activationKey, now, ValidationKeyType.EMAIL, accountType, now, maxNumProjects, newUser.isTwoFactor(), secret.getSalt(), newUser.getToursState());
user.setBbcGroupCollection(groups);
return user;
}
Aggregations