Package io.fathom.cloud.protobuf.IdentityModel

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


import io.fathom.cloud.protobuf.IdentityModel.ProjectRoles;
import io.fathom.cloud.protobuf.IdentityModel.UserData;

public class Users {
    public static ProjectRoles findProjectRoles(UserData user, long projectId) {
        ProjectRoles projectRoles = null;
        for (ProjectRoles i : user.getProjectRolesList()) {
            if (i.getProject() == projectId) {
                projectRoles = i;
                break;
            }
View Full Code Here


        ProjectData project = getProject(projectId);

        Roles response = new Roles();
        response.roles = Lists.newArrayList();

        ProjectRoles projectRoles = Users.findProjectRoles(user, project.getId());
        if (projectRoles != null) {
            for (long roleId : projectRoles.getRoleList()) {
                RoleData role = identityService.findRole(roleId);
                if (role == null) {
                    log.warn("Role not found: {}", roleId);
                } else {
                    response.roles.add(toModel(role));
View Full Code Here

    }

    private AuthenticatedUser toAuthenticationV2(DomainData domain, ProjectSpec projectSpec,
            UserWithSecret userWithSecret) throws CloudException {
        ProjectData project = null;
        ProjectRoles projectRoles = null;

        UserData user = userWithSecret.getUserData();

        if (projectSpec.projectId != 0) {
            return buildProjectToken(domain, projectSpec.projectId, userWithSecret);
View Full Code Here

    }

    private AuthenticatedUser buildDomainToken(DomainData domain, UserWithSecret userWithSecret) throws CloudException {
        TokenScope scope = null;
        ProjectData project = null;
        ProjectRoles projectRoles = null;

        scope = TokenScope.Domain;

        return new AuthenticatedUser(scope, userWithSecret, project, projectRoles, domain);
    }
View Full Code Here

        if (project == null) {
            throw new IllegalStateException();
        }

        TokenScope scope = TokenScope.Project;
        ProjectRoles projectRoles = null;

        UserData user = userWithSecret.getUserData();

        projectRoles = Users.findProjectRoles(user, project.getId());
        if (projectRoles == null) {
View Full Code Here

    private AuthenticatedUser buildProjectToken(DomainData domain, long projectId, UserWithSecret userWithSecret)
            throws CloudException {
        UserData user = userWithSecret.getUserData();

        ProjectRoles projectRoles = Users.findProjectRoles(user, projectId);
        if (projectRoles == null) {
            return null;
        }

        ProjectData project = authRepository.getProjects().find(projectRoles.getProject());
        if (project == null) {
            log.warn("Cannot find project {}", projectRoles.getProject());
            return null;
        }

        TokenScope scope = TokenScope.Project;
        return new AuthenticatedUser(scope, userWithSecret, project, projectRoles, domain);
View Full Code Here

        return new UserWithSecret(user, userSecretData, secretToken);
    }

    public AuthenticatedProject authenticate(ProjectData project, AuthenticatedUser user) {
        ProjectRoles projectRoles = Users.findProjectRoles(user.getUserData(), project.getId());
        if (projectRoles == null) {
            // TODO: We probably need another path for domain admins
            return null;
        }

        if (!projectRoles.hasSecretData()) {
            throw new IllegalStateException("Project role has no secret data");
        }

        ProjectRolesSecretData projectRolesSecretData;
        try {
            projectRolesSecretData = unlock(projectRoles.getSecretData(), user, ProjectRolesSecretData.newBuilder());
        } catch (IOException e) {
            throw new IllegalStateException("Error unlocking project", e);
        }

        int version = 0;
View Full Code Here

    @Inject
    AuthRepository authRepository;

    public List<RoleData> getProjectRoles(UserData user, long projectId) {
        ProjectRoles found = Users.findProjectRoles(user, projectId);
        if (found == null) {
            return Collections.emptyList();
        }

        List<RoleData> ret = Lists.newArrayList();
        for (long roleId : found.getRoleList()) {
            RoleData role = authRepository.getRoles().find(roleId);
            if (role == null) {
                continue;
            }
            ret.add(role);
View Full Code Here

    public ProjectData findProject(AuthenticatedUser user, long projectId) throws CloudException {
        ProjectData project = authRepository.getProjects().find(projectId);
        boolean authorized = false;

        if (project != null) {
            ProjectRoles projectRoles = Users.findProjectRoles(user.getUserData(), project.getId());
            if (projectRoles != null && projectRoles.getRoleCount() != 0) {
                authorized = true;
            }

            if (!authorized) {
                if (user.isDomainAdmin(project.getDomainId())) {
View Full Code Here

        if (project == null) {
            log.warn("Could not find project");
            return;
        }

        ProjectRoles projectRoles = Users.findProjectRoles(user.getUserData(), project.getId());
        if (projectRoles == null) {
            log.warn("Could not find role on project");
            // TODO: We probably need another path for domain admins
            return;
        }

        if (!projectRoles.hasSecretData()) {
            log.warn("Project role has no secret data");

            if (projectRoles.getRoleList().contains(WellKnownRoles.ROLE_ID_ADMIN)) {
                // TODO: Remove once we've migrated all the projects
                log.warn("Creating project key for project: {}", projectId);

                Migrations.report(project);
View Full Code Here

TOP

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

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.