use of org.platformlayer.ids.ProjectId in project platformlayer by platformlayer.
the class PersistentJobRegistry method enqueueOperation.
@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);
}
JobData jobData = new JobData();
jobData.action = action;
jobData.targetId = targetItem;
try {
String jobId = repository.insertJob(projectId, jobData);
jobData.key = JobData.buildKey(projectId, new ManagedItemId(jobId));
} catch (RepositoryException e) {
throw new OpsException("Error inserting job", e);
}
operationQueue.submit(auth, jobData);
return jobData;
}
use of org.platformlayer.ids.ProjectId in project platformlayer by platformlayer.
the class OpsContextBuilder method getRunAsProjectId.
public ProjectId getRunAsProjectId(ProjectAuthorization project) throws OpsException {
// authentication.getProject();
ProjectAuthorization runAsProject = project;
MultitenantConfiguration multitenant = opsSystem.getMultitenantConfiguration();
if (multitenant != null) {
runAsProject = multitenant.getMasterProject();
}
ProjectId runAsProjectId = new ProjectId(runAsProject.getName());
return runAsProjectId;
}
use of org.platformlayer.ids.ProjectId in project platformlayer by platformlayer.
the class ProjectContext method getProjectCredentials.
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);
}
return new SimpleCertificateAndKey(chain, keyPair.getPrivate());
}
use of org.platformlayer.ids.ProjectId in project platformlayer by platformlayer.
the class FederationMap method addDefault.
public void addDefault(TypedPlatformLayerClient defaultClient) {
FederationKey host = FederationKey.LOCAL;
ProjectId project = defaultClient.getProject();
FederationMapping mapKey = new FederationMapping(host, project);
MappedTarget target = new MappedTarget();
target.client = defaultClient;
addMapping(mapKey, target);
}
use of org.platformlayer.ids.ProjectId in project platformlayer by platformlayer.
the class FederationMap method buildRules.
private void buildRules(FederationConfiguration config) {
for (FederationRule federationRule : config.rules) {
Rule rule = new Rule();
rule.mappedItems = PlatformLayerKey.fromServiceAndItem(federationRule.serviceType, null);
for (PlatformLayerConnectionConfiguration system : config.systems) {
if (Objects.equal(system.key, federationRule.target)) {
if (rule.targetKey != null) {
throw new IllegalStateException();
}
FederationKey host = FederationKey.build(system.authenticationEndpoint);
ProjectId project = new ProjectId(system.tenant);
rule.targetKey = new FederationMapping(host, project);
}
}
if (rule.targetKey == null) {
throw new IllegalStateException();
}
addRule(rule);
}
}
Aggregations