Search in sources :

Example 1 with BbcGroup

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;
}
Also used : BbcGroup(io.hops.hopsworks.persistence.entity.user.BbcGroup)

Example 2 with BbcGroup

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.");
    }
}
Also used : BbcGroup(io.hops.hopsworks.persistence.entity.user.BbcGroup) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException)

Example 3 with BbcGroup

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;
}
Also used : BbcGroup(io.hops.hopsworks.persistence.entity.user.BbcGroup)

Example 4 with BbcGroup

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;
}
Also used : BbcGroup(io.hops.hopsworks.persistence.entity.user.BbcGroup) ArrayList(java.util.ArrayList)

Example 5 with BbcGroup

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;
}
Also used : Secret(io.hops.hopsworks.common.security.utils.Secret) BbcGroup(io.hops.hopsworks.persistence.entity.user.BbcGroup) ArrayList(java.util.ArrayList) Users(io.hops.hopsworks.persistence.entity.user.Users) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Aggregations

BbcGroup (io.hops.hopsworks.persistence.entity.user.BbcGroup)25 Users (io.hops.hopsworks.persistence.entity.user.Users)11 ArrayList (java.util.ArrayList)10 UserException (io.hops.hopsworks.exceptions.UserException)6 Date (java.util.Date)3 Secret (io.hops.hopsworks.common.security.utils.Secret)2 Timestamp (java.sql.Timestamp)2 PostConstruct (javax.annotation.PostConstruct)2 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)1 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)1 InvalidQueryException (io.hops.hopsworks.exceptions.InvalidQueryException)1 RemoteUserType (io.hops.hopsworks.persistence.entity.remote.user.RemoteUserType)1 UserAccountStatus (io.hops.hopsworks.persistence.entity.user.security.ua.UserAccountStatus)1 UserAccountType (io.hops.hopsworks.persistence.entity.user.security.ua.UserAccountType)1 ApiOperation (io.swagger.annotations.ApiOperation)1 URI (java.net.URI)1 SelectItem (javax.faces.model.SelectItem)1 MessagingException (javax.mail.MessagingException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1