Search in sources :

Example 1 with Access

use of org.platformlayer.auth.model.Access in project platformlayer by platformlayer.

the class TokenHelpers method buildAccess.

public Access buildAccess(UserEntity user) {
    byte[] tokenSecret = authSecrets.buildToken(user.getUserSecret());
    TokenInfo token = buildToken("" + user.getId(), tokenSecret);
    Access access = new Access();
    // response.access.serviceCatalog = serviceMapper.getServices(userInfo,
    // project);
    access.token = new Token();
    access.token.expires = token.expiration;
    access.token.id = tokenService.encodeToken(token);
    access.projects = Lists.newArrayList();
    try {
        for (ProjectEntity project : userAuthenticator.listProjects(user)) {
            access.projects.add(project.getName());
        }
    } catch (RepositoryException e) {
        log.warn("Error while listing projects for user: " + user.key, e);
        throw new IllegalStateException("Error listing projects for user", e);
    }
    return access;
}
Also used : ProjectEntity(org.platformlayer.auth.ProjectEntity) Access(org.platformlayer.auth.model.Access) Token(org.platformlayer.auth.model.Token) RepositoryException(org.platformlayer.RepositoryException)

Aggregations

RepositoryException (org.platformlayer.RepositoryException)1 ProjectEntity (org.platformlayer.auth.ProjectEntity)1 Access (org.platformlayer.auth.model.Access)1 Token (org.platformlayer.auth.model.Token)1