Package io.fathom.cloud.protobuf.IdentityModel

Examples of io.fathom.cloud.protobuf.IdentityModel.UserData


        }
        return user;
    }

    protected UserData getUser(long userId) throws CloudException {
        UserData user = findUser(userId);
        if (user == null) {
            log.info("User not found / authorized: {}", userId);
            throw new WebApplicationException(Status.NOT_FOUND);
        }
View Full Code Here


        return user;
    }

    protected UserData findUser(long id) throws CloudException {
        UserData user = getUser();
        if (user.getId() == id) {
            return user;
        }

        Auth.Domain domainAdmin = findDomainWithAdminRole();
        UserData otherUser = null;
        if (domainAdmin != null) {
            otherUser = identityService.findUser(id);

            if (otherUser != null) {
                if (otherUser.getDomainId() != domainAdmin.getId()) {
                    otherUser = null;
                }
            }
        }
View Full Code Here

    }

    @Override
    @Transactional
    public List<Long> resolveProjectName(Auth auth, String projectName) throws CloudException {
        UserData userData = authRepository.getUsers().find(auth.getUser().getId());
        if (userData == null) {
            log.warn("Unable to find user: {}", auth.getUser());
            return null;
        }

        List<Long> projectIds = Lists.newArrayList();

        for (ProjectRoles pr : userData.getProjectRolesList()) {
            long projectId = pr.getProject();

            ProjectData project = authRepository.getProjects().find(projectId);
            if (project == null) {
                log.warn("Unable to find project: {}", projectId);
View Full Code Here

        NamedItemCollection<CredentialData> credentials = repository.getUsernames(domain);

        for (CredentialData credential : credentials.list()) {
            long userId = credential.getUserId();

            UserData user = repository.getUsers().find(userId);
            if (user == null) {
                log.warn("Removing credential that references deleted user: {}", credential);

                credentials.delete(credential.getKey());
            }
View Full Code Here

        RoleData role = getRole();

        DomainData domain = identityService.getDefaultDomain();

        UserData grantee = getGrantee(domain);

        log.info("Doing project grant: {} {}", grantee.getName(), role.getName());
        identityService.grantRoleToUserOnProject(authenticatedProject, grantee.getId(), role.getId());
    }
View Full Code Here

        log.info("Doing project grant: {} {}", grantee.getName(), role.getName());
        identityService.grantRoleToUserOnProject(authenticatedProject, grantee.getId(), role.getId());
    }

    private UserData getGrantee(DomainData domain) throws CloudException {
        UserData user = identityService.findUserByName(domain.getId(), grantee);
        if (user == null) {
            throw new IllegalArgumentException("Cannot find user: " + grantee);
        }

        return user;
View Full Code Here

        UserData.Builder userBuilder = UserData.newBuilder();
        userBuilder.setName(username);
        // userBuilder.setEmail(username);
        userBuilder.setEnabled(true);

        UserData user = identityService.createUser(new UserCreationData(domain, userBuilder, password));

        Long projectId = null;

        AuthenticatedUser authenticatedUser = loginService.authenticate(projectId, username, password);
        if (authenticatedUser == null) {
View Full Code Here

        doDomainGrant();
        return null;
    }

    private UserData getGrantee(DomainData domain) throws CloudException {
        UserData user = identityService.findUserByName(domain.getId(), grantee);
        if (user == null) {
            throw new IllegalArgumentException("Cannot find user: " + grantee);
        }

        return user;
View Full Code Here

        // Domain grant
        DomainData domain = identityService.getDefaultDomain();

        RoleData role = getRole();

        UserData user = getGrantee(domain);

        log.info("Doing domain grant: {} {}", user.getName(), role.getName());
        identityService.grantDomainRoleToUser(domain.getId(), user.getId(), role.getId());
    }
View Full Code Here

    @DELETE
    @Path("{id}")
    @Transactional
    public Response deleteProject(@PathParam("id") long userId) throws CloudException {
        UserData user = getUser(userId);

        if (user.getId() == getAuth().getUser().getId()) {
            // Don't let people delete themselves
            // TODO: Only protect admin account??
            throw new IllegalArgumentException();
        }

        // TODO: Mark as deleted?
        // TODO: Deleted related things e.g. credentials?
        // TODO: Block delete if "in use"
        authRepository.getProjects().delete(user.getId());

        ResponseBuilder response = Response.noContent();
        return response.build();
    }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.protobuf.IdentityModel.UserData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.