Package org.platformlayer.ops.helpers

Source Code of org.platformlayer.ops.helpers.ServiceContext

package org.platformlayer.ops.helpers;

import javax.inject.Inject;
import javax.security.auth.x500.X500Principal;

import org.platformlayer.ids.ServiceType;
import org.platformlayer.ops.OpsContext;
import org.platformlayer.ops.OpsException;

public class ServiceContext {
  @Inject
  OpsContext opsContext;

  @Inject
  SshKeys sshKeys;

  public ServiceContext() {
  }

  public SshKey getSshKey() throws OpsException {
    String sshKeyName = getSshKeyName();
    return sshKeys.getOrCreate(sshKeyName, "root");
  }

  public String getSshKeyName() {
    return "service-" + getServiceKey();
  }

  private String getServiceKey() {
    return getServiceType().getKey().toLowerCase();
  }

  private ServiceType getServiceType() {
    return opsContext.getServiceConfiguration().getServiceType();
  }

  public String getSecurityGroupName() {
    return "service-" + getServiceKey();
  }

  public X500Principal getX500Principal() {
    return new X500Principal("CN=" + getServiceKey());
  }

}
TOP

Related Classes of org.platformlayer.ops.helpers.ServiceContext

TOP
Copyright © 2018 www.massapi.com. 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.