Package io.fathom.cloud.protobuf.IdentityModel

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


    @PUT
    @Path("{project_id}/users/{user_id}/roles/{role_id}")
    public Response grantRoleToUserOnProject(@PathParam("project_id") long projectId,
            @PathParam("user_id") long userId, @PathParam("role_id") long roleId) throws CloudException {
        AuthenticatedUser currentUser = getAuthenticatedUser();
        UserData grantee = getUser(userId);

        AuthenticatedProject authenticatedProject = identityService.authenticateToProject(currentUser, projectId);
        if (authenticatedProject == null) {
            // Forbidden?
            log.info("Cannot authenticate to project: {} as user: {}", projectId, currentUser);
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        identityService.grantRoleToUserOnProject(authenticatedProject, grantee.getId(), roleId);

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


    @GET
    @Path("{projectId}/users/{userId}/roles")
    public Roles getProjectDetails(@PathParam("projectId") long projectId, @PathParam("userId") long userId)
            throws CloudException {
        UserData user = getUser(userId);
        ProjectData project = getProject(projectId);

        Roles response = new Roles();
        response.roles = Lists.newArrayList();
View Full Code Here

    @Inject
    IdentityService identityService;

    @GET
    public DomainList listDomains() throws CloudException {
        UserData user = getUser();

        DomainList response = new DomainList();
        response.domains = Lists.newArrayList();

        for (DomainData data : identityService.listDomains(user)) {
View Full Code Here

    }

    @GET
    @Path("{id}")
    public DomainWrapper getDomain(@PathParam("id") String id) throws CloudException {
        UserData user = getUser();

        DomainData data = identityService.findDomain(user, id);
        notFoundIfNull(data);

        DomainWrapper response = new DomainWrapper();
View Full Code Here

    @GET
    public GetTenantsResponse doTenantsGet() throws CloudException {
        GetTenantsResponse response = new GetTenantsResponse();
        List<TenantDetails> tenants = response.tenants = Lists.newArrayList();

        UserData user = getUser();
        AuthenticatedUser authenticated = getAuthenticatedUser();

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

            ProjectData project = identityService.findProject(authenticated, projectId);
            if (project == null) {
                log.warn("Cannot find project {}", projectId);
View Full Code Here

        Token response = new Token();

        response.expires = TokenAuth.getExpiration(token);

        UserData user = authRepository.getUsers().find(token.getUserId());
        if (user == null) {
            throw new IllegalStateException();
        }

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

        response.user = toModel(domain, user);
View Full Code Here

    String userId;

    @GET
    @Produces({ JSON })
    public Credentials listEc2Credentials() throws CloudException {
        UserData user = getUser(Long.valueOf(userId));

        Credentials response = new Credentials();
        response.credentials = Lists.newArrayList();

        log.warn("TODO: EC2 credential enumeration is terrible");

        for (CredentialData data : authRepository.getEc2Credentials().list()) {
            if (data.getUserId() != user.getId()) {
                continue;
            }

            Credential c = toModel(data);
            response.credentials.add(c);
View Full Code Here

    static final SecureRandom secureRandom = new SecureRandom();

    @POST
    @Produces({ JSON })
    public WrappedCredential createEc2Credential() throws CloudException, DuplicateValueException {
        UserData forUser = getUser(Long.valueOf(userId));

        WrappedCredential response = new WrappedCredential();

        TokenInfo tokenInfo = findTokenInfo();
        if (tokenInfo == null) {
            throw new WebApplicationException(Status.UNAUTHORIZED);
        }
        long projectId = tokenInfo.getProjectId();
        if (projectId == 0) {
            throw new WebApplicationException(Status.UNAUTHORIZED);
        }

        String accessId;
        ByteString secret;

        {
            byte[] r = new byte[16];
            synchronized (secureRandom) {
                secureRandom.nextBytes(r);
            }
            secret = ByteString.copyFrom(r);
        }
        {
            AccessId.Builder b = AccessId.newBuilder();
            b.setUserId(forUser.getId());

            byte[] r = new byte[8];
            synchronized (secureRandom) {
                // We don't technically need secure random here, but we want it
                // later!
                secureRandom.nextBytes(r);
            }
            b.setPadding(ByteString.copyFrom(r));

            accessId = Hex.toHex(b.build().toByteArray());
        }

        CredentialData created;

        {
            CredentialData.Builder b = CredentialData.newBuilder();
            b.setUserId(forUser.getId());
            b.setProjectId(projectId);
            b.setKey(accessId);
            b.setDeprecatedSharedSecret(secret);

            created = authRepository.getEc2Credentials().create(b);
View Full Code Here

            throw new UnsupportedOperationException();
        }

        User req = wrapped.user;

        UserData updated;

        {
            UserData.Builder b = UserData.newBuilder(user.getUserData());

            if (!Strings.isNullOrEmpty(req.description)) {
View Full Code Here

            b.setDefaultProjectId(project.getId());
        }

        b.setEmail(req.email);

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

        WrappedUser response = new WrappedUser();
        response.user = toModel(user);
        return response;
    }
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.