Package org.platformlayer.auth

Examples of org.platformlayer.auth.UserDatabase


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


    super("join", "project");
  }

  @Override
  public Object runCommand() throws RepositoryException, IOException {
    UserDatabase userRepository = getContext().getUserRepository();

    UserEntity me = getContext().loginDirect();
    ProjectEntity project = userRepository.findProjectByKey(projectKey.getKey());
    if (project == null) {
      throw new CliException("Project not found: " + projectKey.getKey());
    }

    SecretStore secretStore = new SecretStore(project.secretData);
    CryptoKey projectSecret = secretStore.getSecretFromUser(me);
    if (projectSecret == null) {
      String msg = "Cannot retrieve project secret.";
      msg += " Is " + me.key + " a member of " + project.getName() + "?";
      throw new CliException(msg);
    }
    if (Strings.isNullOrEmpty(roleKey)) {
      throw new CliException("Role is required");
    }
    RoleId role = new RoleId(roleKey);
    userRepository.addUserToProject(username.getKey(), project.getName(), projectSecret,
        Collections.singletonList(role));

    return project;
  }
View Full Code Here

    super("list", "projects");
  }

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

    super("list", "serviceaccounts");
  }

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

    } else {
      System.out.println("Certificate chain has length " + certificateChain.length + ", assuming entry 2 is CA");
      cert = (X509Certificate) certificateChain[1];
    }

    UserDatabase userRepository = getContext().getUserRepository();

    ServiceAccount account = userRepository.createServiceAccount(cert);

    return account;
  }
View Full Code Here

    super("list", "users");
  }

  @Override
  public Object runCommand() throws RepositoryException {
    UserDatabase userRepository = getContext().getUserRepository();

    List<String> users = userRepository.listAllUserNames(prefix);
    return users;
  }
View Full Code Here

    super("create", "project");
  }

  @Override
  public Object runCommand() throws RepositoryException {
    UserDatabase userRepository = getContext().getUserRepository();

    // We need to login to unlock the user key so we can encrypt the project key!
    UserEntity me = getContext().loginDirect();

    if (projectKey.contains("@@")) {
      throw new CliException("Project names with @@ are reserved for system uses");
    }

    ProjectEntity project = userRepository.createProject(projectKey, me);

    return project;
  }
View Full Code Here

      // Let's avoid returning thousands of users
      return null;
    }

    KeystoneCliContext keystoneContext = (KeystoneCliContext) context;
    UserDatabase userRepository = keystoneContext.getUserRepository();
    List<String> userIds = userRepository.listAllUserNames(prefix);
    addSuffix(userIds, " ");

    return userIds;
  }
View Full Code Here

      // Let's avoid returning thousands of projects
      return null;
    }

    KeystoneCliContext keystoneContext = (KeystoneCliContext) context;
    UserDatabase userRepository = keystoneContext.getUserRepository();
    List<String> userIds = userRepository.listAllProjectNames(prefix);
    addSuffix(userIds, " ");

    return userIds;
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.auth.UserDatabase

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.