Package org.platformlayer.ids

Examples of org.platformlayer.ids.ProjectId


  OperationQueue operationQueue;

  @Override
  public JobData enqueueOperation(Action action, ProjectAuthorization auth, PlatformLayerKey targetItem)
      throws OpsException {
    ProjectId projectId;
    try {
      projectId = opsContextBuilder.getRunAsProjectId(auth);
    } catch (OpsException e) {
      throw new OpsException("Error getting projectId", e);
    }
View Full Code Here


  }

  private static PlatformLayerEndpointInfo rehydrateEndpoint(final EndpointRecord in) {
    final Authenticator authenticator;
    final String platformlayerBaseUrl = in.url;
    final ProjectId projectId = new ProjectId(in.project);
    final List<String> trustKeys;

    if (Strings.isNullOrEmpty(in.trustKeys)) {
      trustKeys = Collections.emptyList();
    } else {
View Full Code Here

  @Override
  @JdbcTransaction
  public List<JobExecutionData> listExecutions(PlatformLayerKey jobKey) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
      ProjectId projectId = jobKey.getProject();
      String jobId = jobKey.getItemIdString();

      List<JobExecutionEntity> executions = db.queries.listExecutions(db.mapToValue(projectId), jobId);
      List<JobExecutionData> ret = Lists.newArrayList();
      for (JobExecutionEntity execution : executions) {
View Full Code Here

  @Override
  @JdbcTransaction
  public List<JobData> listRecentJobs(JobQuery jobQuery) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
      ProjectId projectId = jobQuery.project;
      Preconditions.checkNotNull(projectId);
      int project = db.mapToValue(projectId);

      Long maxAge = null;
      if (jobQuery.maxAge != null) {
View Full Code Here

  @Override
  @JdbcTransaction
  public JobExecutionData findExecution(PlatformLayerKey jobKey, String executionId) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
      ProjectId projectId = jobKey.getProject();
      String jobId = jobKey.getItemIdString();

      JobExecutionEntity execution = db.queries.findExecution(db.mapToValue(projectId), jobId, executionId);

      if (execution == null) {
View Full Code Here

  @Override
  @JdbcTransaction
  public JobData findJob(PlatformLayerKey jobKey) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
      ProjectId projectId = jobKey.getProject();
      String jobId = jobKey.getItemIdString();

      JobEntity execution = db.queries.findJob(db.mapToValue(projectId), jobId);

      if (execution == null) {
View Full Code Here

  public void recordJobEnd(PlatformLayerKey jobKey, String executionId, Date endedAt, JobState state, String logCookie)
      throws RepositoryException {

    DbHelper db = new DbHelper();
    try {
      ProjectId project = jobKey.getProject();
      String jobId = jobKey.getItemIdString();

      int projectId = db.mapToValue(project);
      int updateCount = db.queries.updateExecution(logCookie, endedAt, state, projectId, jobId, executionId);
      if (updateCount != 1) {
View Full Code Here

  @Override
  @JdbcTransaction
  public String insertExecution(PlatformLayerKey jobKey, Date startedAt) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
      ProjectId projectId = jobKey.getProject();
      String jobId = jobKey.getItemIdString();

      String executionId = UUID.randomUUID().toString();

      JobExecutionEntity execution = new JobExecutionEntity();
View Full Code Here

  public ProjectContext() {
  }

  public ProjectId getProjectId() {
    ServiceConfiguration serviceConfiguration = OpsContext.get().getServiceConfiguration();
    ProjectId project = serviceConfiguration.getProject();

    PlatformLayerKey targetItemKey = opsContext.getJobRecord().getTargetItemKey();
    if (targetItemKey != null) {
      ProjectId project2 = targetItemKey.getProject();
      if (!project.equals(project2)) {
        // Not sure yet which one we should be using if these differ!
        throw new IllegalStateException();
      }
    }
View Full Code Here

  public CertificateAndKey getProjectCredentials() throws OpsException {
    // OK... this is weird... we sign the project cert with the project cert.
    // It sort of makes sense, in that we don't want to share the project signing cert outside the auth server

    ProjectId projectId = getProjectId();

    KeyPair keyPair = privateData.findKeyPair(projectId, null, METADATA_PROJECT_KEY);
    List<X509Certificate> chain = privateData.findCertificate(projectId, null, METADATA_PROJECT_CERT);

    if (keyPair == null) {
      keyPair = RsaUtils.generateRsaKeyPair();
      privateData.putKeyPair(projectId, null, METADATA_PROJECT_KEY, keyPair);
    }

    if (chain == null) {
      AuthenticationTokenValidator authenticationTokenValidator = OpsContext.get().getInjector()
          .getInstance(AuthenticationTokenValidator.class);

      ProjectAuthorization projectAuthorization = Scope.get().get(ProjectAuthorization.class);
      String projectKey = projectAuthorization.getName();

      if (!projectKey.equals(projectId.getKey())) {
        throw new IllegalStateException();
      }

      PlatformLayerAuthAdminClient adminClient = PlatformLayerAuthAdminClient.find(authenticationTokenValidator);
      Csr csr = Csr.buildCsr(keyPair, getX500Principal());
      chain = adminClient.signCsr(projectId.getKey(), projectAuthorization.getProjectSecret(), csr.getEncoded());

      privateData.putCertificate(projectId, null, METADATA_PROJECT_CERT, chain);
    }

    // privateData.getOrCreate(projectId, null, sshKeyName, user)
View Full Code Here

TOP

Related Classes of org.platformlayer.ids.ProjectId

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.