Package io.fathom.cloud.protobuf.IdentityModel

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


            break;
        }

        case Project: {
            // Project scoped
            ProjectData scope = authRepository.getProjects().find(token.getProjectId());
            if (scope == null) {
                throw new IllegalStateException();
            }

            DomainData projectDomain = authRepository.getDomains().find(scope.getDomainId());
            if (projectDomain == null) {
                throw new IllegalStateException();
            }

            response.projectScope = toModel(projectDomain, scope);
            response.serviceCatalog = loginService.buildServiceMap(getBaseUrl(), scope);

            roles = tokenUtils.getProjectRoles(user, scope.getId());
            break;
        }

        default:
            break;
View Full Code Here


        V2AuthResponse response = new V2AuthResponse();

        Access access = response.access = new Access();
        V2Token token = access.token = new V2Token();

        ProjectData project = authentication.getProject();

        // We never pass domain; we can't build a domain token with V2
        TokenInfo tokenInfo = loginService.buildTokenInfo(authentication);

        token.expires = TokenAuth.getExpiration(tokenInfo);
        token.id = tokenService.encodeToken(tokenInfo);
        if (project != null) {
            Tenant tenant = new Tenant();
            tenant.id = "" + project.getId();
            tenant.name = project.getName();
            token.tenant = tenant;
        }

        if (project != null) {
            List<Service> v3Services = loginService.buildServiceMap(getBaseUrl(), project);
View Full Code Here

                throw new UnsupportedOperationException();
            }
            // domain = getDomain(Long.valueOf(req.domainId));
        }

        ProjectData project = getProject(Long.valueOf(req.defaultProjectId));

        UserData.Builder b = UserData.newBuilder();

        if (!Strings.isNullOrEmpty(req.description)) {
            b.setDescription(req.description);
        }

        b.setName(req.name);

        b.setDomainId(domain.getId());

        if (req.enabled != null) {
            b.setEnabled(req.enabled);
        } else {
            b.setEnabled(true);
        }

        if (project != null) {
            b.setDefaultProjectId(project.getId());
        }

        b.setEmail(req.email);

        UserData user = identityService.createUser(new UserCreationData(domainData, b, req.password));
View Full Code Here

        response.projects = Lists.newArrayList();

        for (ProjectRoles projectRole : user.getProjectRolesList()) {
            long projectId = projectRole.getProject();

            ProjectData project = authRepository.getProjects().find(projectId);
            if (project == null) {
                log.warn("Cannot find project {}", projectId);
                continue;
            }
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);
        } else if (!Strings.isNullOrEmpty(projectSpec.projectName)) {
            for (ProjectRoles i : user.getProjectRolesList()) {
                ProjectData p = authRepository.getProjects().find(i.getProject());
                if (p == null) {
                    continue;
                }

                if (projectSpec.projectName.equals(p.getName())) {
                    projectRoles = i;
                    project = p;
                    break;
                }
            }
View Full Code Here

        // (and size matters, because this token gets passed as a cookie))
        token.setExpiration(expiration.getTime() / 1000L);

        token.setTokenScope(tokenScope);

        ProjectData project = authentication.getProject();
        if (project != null) {
            token.setProjectId(project.getId());
            if (authentication.getProjectRoleIds() != null) {
                for (long projectRoleId : authentication.getProjectRoleIds()) {
                    token.addRoles(projectRoleId);
                }
            }
View Full Code Here

        return BaseEncoding.base16().encode(publicKeySha1.toByteArray());
    }

    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

        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;
        }
View Full Code Here

        // Auth.Domain domain = findDomainWithAdminRole();
        // if (domain == null) {
        // throw new WebApplicationException(Status.FORBIDDEN);
        // }

        ProjectData created = authRepository.getProjects().create(b);

        SecretToken secretToken = SecretToken.create(SecretTokenType.PROJECT_SECRET);

        AuthenticatedProject authenticatedProject = new AuthenticatedProject(created, secretToken);
View Full Code Here

        }
    }

    @Override
    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())) {
                    authorized = true;
                }
            }
        }
View Full Code Here

TOP

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

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.