Skip to content

Commit

Permalink
adobeGH-55 removing default workspace configuration leveraging enviro…
Browse files Browse the repository at this point in the history
…nment variables

This will come from the doc (and a sample) we want the customer to own/understand this step fully
  • Loading branch information
francoisledroff committed Mar 30, 2022
1 parent 6b46f75 commit 43493b2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 42 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.security.PrivateKey;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Modified;
Expand Down Expand Up @@ -66,7 +67,7 @@ public Status getStatus() {
*/
@Override
public Workspace getWorkspace() {
if (!workspaceConfig.aio_encoded_pkcs8().isEmpty()) {
if (!StringUtils.isEmpty(workspaceConfig.aio_encoded_pkcs8())) {
PrivateKey privateKey = new PrivateKeyBuilder()
.encodedPkcs8Key(workspaceConfig.aio_encoded_pkcs8()).build();
return Workspace.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
*/
package com.adobe.aio.aem.workspace.ocd;

import com.adobe.aio.ims.util.PrivateKeyBuilder;
import com.adobe.aio.workspace.Workspace;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

Expand All @@ -26,43 +24,42 @@

@AttributeDefinition(name = "Meta Scopes",
description = "Comma separated list of metascopes associated with your API (`/s/event_receiver_api,/s/ent_adobeio_sdk` for instance) (project.workspace.details.credentials.jwt.meta_scopes)")
String aio_meta_scopes() default "$[env:" + Workspace.META_SCOPES
+ ";default=/s/event_receiver_api,/s/ent_adobeio_sdk]";
String aio_meta_scopes() default "/s/ent_adobeio_sdk";

@AttributeDefinition(name = "IMS ORG ID",
description = "Adobe IMS Organization ID as shown in your Adobe Developer Console workspace (project.org.ims_org_id)")
String aio_ims_org_id() default "$[env:" + Workspace.IMS_ORG_ID + "]";
String aio_ims_org_id();

@AttributeDefinition(name = "Consumer ORG ID",
description = "Adobe I/O Consumer Organization ID as shown in your Adobe Developer Console workspace (project.org.id)")
String aio_consumer_org_id() default "$[env:" + Workspace.CONSUMER_ORG_ID + "]";
String aio_consumer_org_id();

@AttributeDefinition(name = "Project ID",
description = "Adobe I/O Project ID as shown in your Adobe Developer Console workspace (project.id)")
String aio_project_id() default "$[env:" + Workspace.PROJECT_ID + "]";
String aio_project_id();

@AttributeDefinition(name = "Project Workspace ID",
description = "Adobe I/O Workspace ID as shown in your Adobe Developer Console workspace (project.workspace.id)")
String aio_workspace_id() default "$[env:" + Workspace.WORKSPACE_ID + "]";
String aio_workspace_id();

@AttributeDefinition(name = "API Key (Client ID)",
description = "Adobe I/O API Key (Client ID) as shown in in your Adobe Developer Console workspace (project.workspace.details.credentials.jwt.client_id)")
String aio_api_key() default "$[env:" + Workspace.API_KEY + "]";
String aio_api_key();

@AttributeDefinition(name = "Credential ID",
description = "Adobe I/O Credential ID as shown in your Adobe Developer Console workspace (project.workspace.details.credentials.id)")
String aio_credential_id() default "$[env:" + Workspace.CREDENTIAL_ID + "]";
String aio_credential_id();

@AttributeDefinition(name = "Technical Account ID",
description = "Technical account ID as shown in your Adobe Developer Console workspace (project.workspace.details.credentials.jwt.technical_account_id)")
String aio_technical_account_id() default "$[env:" + Workspace.TECHNICAL_ACCOUNT_ID + "]";
String aio_technical_account_id();

@AttributeDefinition(name = "Client Secret",
description = "Adobe I/O Client Secret as shown in your Adobe Developer Console workspace (project.workspace.details.credentials.jwt.client_secret)")
String aio_client_secret() default "$[secret:" + Workspace.CLIENT_SECRET + "]";
String aio_client_secret();

@AttributeDefinition(name = "Private Key",
description = "Base64 encoded pkcs8 Private Key.")
String aio_encoded_pkcs8() default "$[secret:" + PrivateKeyBuilder.AIO_ENCODED_PKCS_8 + "]";
String aio_encoded_pkcs8();

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ protected void activate(BundleContext context, Map<String, Object> config) {
public JobResult process(final Job job) {
if (job.getProperty(AIO_EVENT_CODE_PROPERTY) != null) {
String eventCode = (String) job.getProperty(AIO_EVENT_CODE_PROPERTY);

if (job.getProperty(AIO_OSGI_EVENT_MAPPING_PROPERTY) != null) {
try {
// we don't want to register sling event handlers if the config is buggy
workspaceSupplier.getWorkspace().validateAll();
OsgiEventMapping osgiEventMapping = new ObjectMapper().readValue
((String) job.getProperty(AIO_OSGI_EVENT_MAPPING_PROPERTY), OsgiEventMapping.class);
this.registerEventHandler(osgiEventMapping);
Expand All @@ -104,16 +105,16 @@ public JobResult process(final Job job) {
}
}

public AdobeIoEventHandler getEventHanlder(OsgiEventMapping osgiEventMapping) {
private AdobeIoEventHandler getEventHandler(OsgiEventMapping osgiEventMapping) {
return AdobeIOEventHandlerFactory.getEventHandler(
jobManager, eventProviderConfigSupplier.getRootUrl(),
workspaceSupplier.getWorkspace().getImsOrgId(),
osgiEventMapping,
resourceResolverWrapperFactory.getWrapper());
}

public void registerEventHandler(OsgiEventMapping osgiEventMapping) {
AdobeIoEventHandler eventHandler = getEventHanlder(osgiEventMapping);
private void registerEventHandler(OsgiEventMapping osgiEventMapping) {
AdobeIoEventHandler eventHandler = getEventHandler(osgiEventMapping);
Dictionary props = new Hashtable();
String[] eventTopics = {osgiEventMapping.getOsgiTopic()};
props.put(EventConstants.EVENT_TOPIC, eventTopics);
Expand Down

0 comments on commit 43493b2

Please sign in to comment.