Search in sources :

Example 6 with ProjectEntity

use of org.platformlayer.auth.ProjectEntity 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

ProjectEntity (org.platformlayer.auth.ProjectEntity)6 UserEntity (org.platformlayer.auth.UserEntity)4 AuthenticatorException (org.platformlayer.auth.AuthenticatorException)3 CliException (com.fathomdb.cli.CliException)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 UserDatabase (org.platformlayer.auth.UserDatabase)2 UserProjectEntity (org.platformlayer.auth.UserProjectEntity)2 Token (org.platformlayer.auth.model.Token)2 ValidateAccess (org.platformlayer.auth.model.ValidateAccess)2 ValidateTokenResponse (org.platformlayer.auth.model.ValidateTokenResponse)2 CryptoKey (com.fathomdb.crypto.CryptoKey)1 X509Certificate (java.security.cert.X509Certificate)1 GET (javax.ws.rs.GET)1 RepositoryException (org.platformlayer.RepositoryException)1 SecretStore (org.platformlayer.auth.crypto.SecretStore)1 Access (org.platformlayer.auth.model.Access)1 SignCertificateResponse (org.platformlayer.auth.model.SignCertificateResponse)1 TokenInfo (org.platformlayer.auth.services.TokenInfo)1 RoleId (org.platformlayer.model.RoleId)1