Search in sources :

Example 6 with UserDatabase

use of org.platformlayer.auth.UserDatabase in project platformlayer by platformlayer.

the class ListServiceAccounts method runCommand.

@Override
public Object runCommand() throws RepositoryException {
    UserDatabase userRepository = getContext().getUserRepository();
    byte[] publicKeyBytes = null;
    if (publicKey != null) {
        publicKeyBytes = Hex.fromHex(publicKey);
    }
    List<ServiceAccountEntity> serviceAcccounts = userRepository.listAllServiceAccounts(publicKeyBytes);
    return serviceAcccounts;
}
Also used : UserDatabase(org.platformlayer.auth.UserDatabase) ServiceAccountEntity(org.platformlayer.auth.ServiceAccountEntity)

Example 7 with UserDatabase

use of org.platformlayer.auth.UserDatabase in project platformlayer by platformlayer.

the class CreateUser method runCommand.

@Override
public Object runCommand() throws RepositoryException, GeneralSecurityException, IOException, OpsException {
    if (password == null && keystore == null && certPath == null) {
        throw new CliException("Either key or password or cert is required");
    }
    UserDatabase userRepository = getContext().getUserRepository();
    Certificate[] certificateChain = null;
    if (keystore != null) {
        certificateChain = getContext().getCertificateChain(keystore, keystoreSecret, keyAlias);
    } else if (certPath != null) {
        certificateChain = getContext().loadCertificateChain(certPath);
    }
    OpsUser user = userRepository.createUser(username, password, certificateChain);
    return user;
}
Also used : CliException(com.fathomdb.cli.CliException) UserDatabase(org.platformlayer.auth.UserDatabase) OpsUser(org.platformlayer.auth.OpsUser) Certificate(java.security.cert.Certificate)

Example 8 with UserDatabase

use of org.platformlayer.auth.UserDatabase in project platformlayer by platformlayer.

the class ListProjects method runCommand.

@Override
public Object runCommand() throws RepositoryException {
    UserDatabase userRepository = getContext().getUserRepository();
    // if (username == null) {
    // return userRepository.listAllProjectNames(null);
    // } else {
    UserEntity user = (UserEntity) userRepository.findUser(username.getKey());
    if (user == null) {
        throw new IllegalArgumentException("User not found");
    }
    return userRepository.listProjectsByUserId(user.id);
// }
}
Also used : UserDatabase(org.platformlayer.auth.UserDatabase) UserEntity(org.platformlayer.auth.UserEntity)

Example 9 with UserDatabase

use of org.platformlayer.auth.UserDatabase in project platformlayer by platformlayer.

the class ListUsers method runCommand.

@Override
public Object runCommand() throws RepositoryException {
    UserDatabase userRepository = getContext().getUserRepository();
    List<String> users = userRepository.listAllUserNames(prefix);
    return users;
}
Also used : UserDatabase(org.platformlayer.auth.UserDatabase)

Aggregations

UserDatabase (org.platformlayer.auth.UserDatabase)9 CliException (com.fathomdb.cli.CliException)3 UserEntity (org.platformlayer.auth.UserEntity)3 Certificate (java.security.cert.Certificate)2 ProjectEntity (org.platformlayer.auth.ProjectEntity)2 KeystoneCliContext (org.platformlayer.keystone.cli.KeystoneCliContext)2 CryptoKey (com.fathomdb.crypto.CryptoKey)1 X509Certificate (java.security.cert.X509Certificate)1 OpsUser (org.platformlayer.auth.OpsUser)1 ServiceAccount (org.platformlayer.auth.ServiceAccount)1 ServiceAccountEntity (org.platformlayer.auth.ServiceAccountEntity)1 SecretStore (org.platformlayer.auth.crypto.SecretStore)1 RoleId (org.platformlayer.model.RoleId)1