diff --git a/CHANGELOG.md b/CHANGELOG.md index 192f766d..11388987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ## [Unreleased](https://github.com/adobe/aio-lib-java/tree/HEAD) -[Full Changelog](https://github.com/adobe/aio-lib-java/compare/aio-lib-java-0.0.24...HEAD) +[Full Changelog](https://github.com/adobe/aio-lib-java/compare/aio-lib-java-0.0.26...HEAD) + +### 📁 Other pull requests + +- GH-55 doc update - Status simplified - JobResult revisited [\#87](https://github.com/adobe/aio-lib-java/pull/87) ([francoisledroff](https://github.com/francoisledroff)) + +## [aio-lib-java-0.0.26](https://github.com/adobe/aio-lib-java/tree/aio-lib-java-0.0.26) (2022-03-30) + +[Full Changelog](https://github.com/adobe/aio-lib-java/compare/aio-lib-java-0.0.24...aio-lib-java-0.0.26) ### 📁 Other pull requests diff --git a/aem/aio_aem_events/pom.xml b/aem/aio_aem_events/pom.xml index 8cd81f40..0a68415b 100644 --- a/aem/aio_aem_events/pom.xml +++ b/aem/aio_aem_events/pom.xml @@ -22,7 +22,7 @@ com.adobe.aio.aem aio-aem ../pom.xml - 0.0.26 + 0.0.28 aio-aem-events @@ -284,6 +284,6 @@ - aio-lib-java-0.0.26 + aio-lib-java-0.0.28 diff --git a/aem/core_aem/README.md b/aem/core_aem/README.md index c6f6017b..3917083c 100644 --- a/aem/core_aem/README.md +++ b/aem/core_aem/README.md @@ -3,6 +3,60 @@ `com.adobe.aio.aem.core` is a Java OSGI bundle hosting OSGI Components wrapping [`aio-lib-java-core`](../../core) and [`aio-lib-java-ims`](../../ims) +## Expected `Workspace` osgi configuration + +This bundle expects a [`Workspace Configuration`](src/main/java/com/adobe/aio/aem/workspace/ocd/WorkspaceConfig.java) +defined as an OSGI configuration. +* for more details about the `Worskspace` configuration: check our [`aio-lib-java-core` documentation](../../core/README.md). +* for more details about the `aio.encoded.pkcs8` private key configuration: check our [`aio-lib-java-ims` documentation](../../ims/README.md) + +Please [choose the appropriate OSGi configuration value types](https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/deploying/configuring-osgi.html%3Flang%3Den#how-to-choose-the-appropriate-osgi-configuration-value-type), +use environment variables for the following: +* `aio.consumer.org.id` +* `aio.ims.org.id` +* `aio.meta.scopes` +* `aio.project.id` +* `aio.workspace.id` +* `aio.api.key` +* `aio.credential.id` +* `aio.technical.account.id` + +Use secret environment variables for the following: +* `aio.client.secret` +* `aio.encoded.pkcs8` + +## Status Check + +This bundle comes with a status servlet: + from [/bin/aio/workspace.json](http://localhost:4502/bin/aio/workspace.json) +you can `GET` the status of your workspace configuration. + +If valid, the status json payload should like that : + + { + "status": "up", + "details": { + "workspace": { + "imsUrl": "https://ims-na1.adobelogin.com", + "imsOrgId": "...@AdobeOrg", + "apiKey": "...", + "credentialId": "...", + "technicalAccountId": "...@techacct.adobe.com", + "metascopes": [ + "...", + "/s/ent_adobeio_sdk" + ], + "consumerOrgId": "...", + "projectId": "...", + "workspaceId": "...", + "projectUrl": "https://developer.adobe.com/console/projects/.../.../overview", + "clientSecretDefined": true, + "privateKeyDefined": true + } + }, + "error": null + } + ## Builds This Library is build with [maven](https://maven.apache.org/) diff --git a/aem/core_aem/pom.xml b/aem/core_aem/pom.xml index 206a2b8e..1c06d9e8 100644 --- a/aem/core_aem/pom.xml +++ b/aem/core_aem/pom.xml @@ -19,7 +19,7 @@ com.adobe.aio.aem aio-aem ../pom.xml - 0.0.26 + 0.0.28 aio-aem-core @@ -173,6 +173,6 @@ - aio-lib-java-0.0.26 + aio-lib-java-0.0.28 diff --git a/aem/core_aem/src/main/java/com/adobe/aio/aem/status/Status.java b/aem/core_aem/src/main/java/com/adobe/aio/aem/status/Status.java index 3db4d384..049d1add 100644 --- a/aem/core_aem/src/main/java/com/adobe/aio/aem/status/Status.java +++ b/aem/core_aem/src/main/java/com/adobe/aio/aem/status/Status.java @@ -15,8 +15,6 @@ public class Status { - public static final String VALID_CONFIG = "valid_config"; - public static final String INVALID_CONFIG = "invalid_config"; public static final String UP = "up"; public static final String DOWN = "down"; diff --git a/aem/core_aem/src/main/java/com/adobe/aio/aem/workspace/internal/WorkspaceSupplierImpl.java b/aem/core_aem/src/main/java/com/adobe/aio/aem/workspace/internal/WorkspaceSupplierImpl.java index 068aa881..aeaf2b93 100644 --- a/aem/core_aem/src/main/java/com/adobe/aio/aem/workspace/internal/WorkspaceSupplierImpl.java +++ b/aem/core_aem/src/main/java/com/adobe/aio/aem/workspace/internal/WorkspaceSupplierImpl.java @@ -53,9 +53,9 @@ public Status getStatus() { Workspace workspace = getWorkspace(); details.put("workspace", workspace); workspace.validateAll(); - return new Status(Status.VALID_CONFIG, details); + return new Status(Status.UP, details); } catch (IllegalArgumentException e) { - return new Status(Status.INVALID_CONFIG, details, e); + return new Status(Status.DOWN, details, e); } } diff --git a/aem/events_ingress_aem/pom.xml b/aem/events_ingress_aem/pom.xml index 546aab61..ef02931c 100644 --- a/aem/events_ingress_aem/pom.xml +++ b/aem/events_ingress_aem/pom.xml @@ -19,7 +19,7 @@ com.adobe.aio.aem aio-aem ../pom.xml - 0.0.26 + 0.0.28 aio-event-publish @@ -173,6 +173,6 @@ - aio-lib-java-0.0.26 + aio-lib-java-0.0.28 diff --git a/aem/events_ingress_aem/src/main/java/com/adobe/aio/aem/event/publish/EventPublishJobConsumer.java b/aem/events_ingress_aem/src/main/java/com/adobe/aio/aem/event/publish/EventPublishJobConsumer.java index a13bb901..b73cce21 100644 --- a/aem/events_ingress_aem/src/main/java/com/adobe/aio/aem/event/publish/EventPublishJobConsumer.java +++ b/aem/events_ingress_aem/src/main/java/com/adobe/aio/aem/event/publish/EventPublishJobConsumer.java @@ -30,7 +30,6 @@ public class EventPublishJobConsumer implements JobConsumer { public static final String AIO_EVENT_CODE_PROPERTY = "event_code"; private final Logger log = LoggerFactory.getLogger(this.getClass()); - private String lastErrorMessage; @Reference private EventPublishService eventPublishService; @@ -71,25 +70,11 @@ public JobResult process(final Job job) { * > CANCEL: Processed unsuccessfully and do NOT reschedule * > ASYNC: Process through the JobConsumer.AsyncHandler interface */ - } catch (RuntimeException e) { + } catch (Exception e) { log.error("Adobe I/O Events Publish Job Consumer `{}` processing failed: `{}", job, e.getMessage(), e); - if (lastErrorMessage == null || !lastErrorMessage.equals(e.getMessage())) { - // to avoid flooding logs and job queues - // see https://jira.corp.adobe.com/browse/GRANITE-27455 - setLastErrorMessage(e.getMessage()); - return JobResult.FAILED; - } else { - log.warn( - "Adobe I/O Events Publish Job Consumer `{}` marked as `CANCEL`, as it looks like we are facing a non resolvable error: `{}`", - job, e.getMessage()); - setLastErrorMessage(e.getMessage()); - return JobResult.CANCEL; - } + return JobResult.FAILED; } } - private synchronized void setLastErrorMessage(String lastErrorMessage) { - this.lastErrorMessage = lastErrorMessage; - } } \ No newline at end of file diff --git a/aem/events_mgmt_aem/pom.xml b/aem/events_mgmt_aem/pom.xml index a6fb8221..416773cf 100644 --- a/aem/events_mgmt_aem/pom.xml +++ b/aem/events_mgmt_aem/pom.xml @@ -19,7 +19,7 @@ com.adobe.aio.aem aio-aem ../pom.xml - 0.0.26 + 0.0.28 aio-event-management @@ -161,6 +161,6 @@ - aio-lib-java-0.0.26 + aio-lib-java-0.0.28 diff --git a/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/EventMetadataRegistrationJobConsumer.java b/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/EventMetadataRegistrationJobConsumer.java index a69f438c..c5cfaf13 100644 --- a/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/EventMetadataRegistrationJobConsumer.java +++ b/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/EventMetadataRegistrationJobConsumer.java @@ -48,9 +48,9 @@ public JobResult process(final Job job) { String error = (String) job.getProperty(AIO_ERROR_PROPERTY); eventMetadataStatusSupplier.addStatus(eventCode, new EventMetadataStatus(null, null, error)); - log.error("Adobe I/O Events Metadata Registration Job Consumer cancelled:" + log.error("Adobe I/O Events Metadata Registration will not occur:" + " due to a event metadata configuration error`{}`", error); - return JobResult.CANCEL; + return JobResult.OK; } else { EventMetadata configuredEventMetadata = null; EventMetadata registeredEventMetadata = null; @@ -70,7 +70,7 @@ public JobResult process(final Job job) { e.getMessage(), e); eventMetadataStatusSupplier.addStatus(eventCode, new EventMetadataStatus(configuredEventMetadata, registeredEventMetadata, e)); - return JobResult.CANCEL; + return JobResult.FAILED; } } } else { diff --git a/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/internal/EventMetadataStatusSupplierImpl.java b/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/internal/EventMetadataStatusSupplierImpl.java index 61a298dd..9b1b2831 100644 --- a/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/internal/EventMetadataStatusSupplierImpl.java +++ b/aem/events_mgmt_aem/src/main/java/com/adobe/aio/aem/event/management/internal/EventMetadataStatusSupplierImpl.java @@ -48,7 +48,7 @@ public Status getStatus() { Map details = new HashMap<>(1); try { if (eventMetadataStatusByEventCode.isEmpty()) { - return new Status(Status.INVALID_CONFIG, null, "Missing event metadata configuration"); + return new Status(Status.DOWN, null, "Missing event metadata configuration"); } else { details.putAll(eventMetadataStatusByEventCode); boolean isUp = eventMetadataStatusByEventCode.values().stream() diff --git a/aem/events_osgi_mapping/pom.xml b/aem/events_osgi_mapping/pom.xml index 3e11d5cd..0b4f45ba 100644 --- a/aem/events_osgi_mapping/pom.xml +++ b/aem/events_osgi_mapping/pom.xml @@ -19,7 +19,7 @@ com.adobe.aio.aem aio-aem ../pom.xml - 0.0.26 + 0.0.28 aio-event-osgimapping @@ -180,6 +180,6 @@ - aio-lib-java-0.0.26 + aio-lib-java-0.0.28 diff --git a/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/EventHandlerRegistrationJobConsumer.java b/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/EventHandlerRegistrationJobConsumer.java index ca947700..99960db0 100644 --- a/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/EventHandlerRegistrationJobConsumer.java +++ b/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/EventHandlerRegistrationJobConsumer.java @@ -13,6 +13,7 @@ import com.adobe.aio.aem.event.management.EventMetadataRegistrationJobConsumer; import com.adobe.aio.aem.event.management.EventProviderConfigSupplier; +import com.adobe.aio.aem.event.management.EventProviderRegistrationService; import com.adobe.aio.aem.event.osgimapping.eventhandler.AdobeIOEventHandlerFactory; import com.adobe.aio.aem.event.osgimapping.eventhandler.AdobeIoEventHandler; import com.adobe.aio.aem.event.osgimapping.eventhandler.OsgiEventMapping; @@ -59,6 +60,9 @@ public class EventHandlerRegistrationJobConsumer implements JobConsumer { @Reference private EventProviderConfigSupplier eventProviderConfigSupplier; + @Reference + private EventProviderRegistrationService eventProviderRegistrationService; + @Reference private WorkspaceSupplier workspaceSupplier; @@ -79,8 +83,11 @@ public JobResult process(final Job job) { 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 + // we don't want to register sling event handlers if the config is invalid workspaceSupplier.getWorkspace().validateAll(); + // we don't want to register sling event handlers if the provider can't be registered + eventProviderRegistrationService.getRegisteredProvider(); + OsgiEventMapping osgiEventMapping = new ObjectMapper().readValue ((String) job.getProperty(AIO_OSGI_EVENT_MAPPING_PROPERTY), OsgiEventMapping.class); this.registerEventHandler(osgiEventMapping); @@ -91,7 +98,7 @@ public JobResult process(final Job job) { log.error("Adobe I/O Events Handler Registration Job Consumer `{}`" + " processing failed: `{}", job, e.getMessage(), e); osgiEventMappingStatusSupplier.addStatus(eventCode, new OsgiEventMappingStatus(null, e)); - return JobResult.CANCEL; + return JobResult.FAILED; } } else { log.error("Adobe I/O Events Handler Registration Job Consumer `{}` is missing a `{}", job, diff --git a/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/internal/OsgiEventMappingStatusSupplierImpl.java b/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/internal/OsgiEventMappingStatusSupplierImpl.java index d89efb52..454cc3f2 100644 --- a/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/internal/OsgiEventMappingStatusSupplierImpl.java +++ b/aem/events_osgi_mapping/src/main/java/com/adobe/aio/aem/event/osgimapping/internal/OsgiEventMappingStatusSupplierImpl.java @@ -43,7 +43,7 @@ public Status getStatus() { Map details = new HashMap<>(1); try { if (osgiEventMappingStatusByEventCode.isEmpty()) { - return new Status(Status.INVALID_CONFIG, null, "Missing Osgi Event Mapping configuration"); + return new Status(Status.DOWN, null, "Missing Osgi Event Mapping configuration"); } else { details.putAll(osgiEventMappingStatusByEventCode); boolean isUp = osgiEventMappingStatusByEventCode.values().stream() diff --git a/aem/lib_osgi/pom.xml b/aem/lib_osgi/pom.xml index 209588a5..946c1f67 100644 --- a/aem/lib_osgi/pom.xml +++ b/aem/lib_osgi/pom.xml @@ -17,7 +17,7 @@ com.adobe.aio.aem aio-aem ../pom.xml - 0.0.26 + 0.0.28 aio-lib-osgi @@ -150,6 +150,6 @@ - aio-lib-java-0.0.26 + aio-lib-java-0.0.28 diff --git a/aem/pom.xml b/aem/pom.xml index 84c8dabd..024fc383 100644 --- a/aem/pom.xml +++ b/aem/pom.xml @@ -19,7 +19,7 @@ com.adobe.aio aio-lib-java ../pom.xml - 0.0.26 + 0.0.28 com.adobe.aio.aem diff --git a/core/README.md b/core/README.md index e79b1c48..78293cd2 100644 --- a/core/README.md +++ b/core/README.md @@ -9,12 +9,26 @@ It also holds the core `Adobe Developer Console` Workspace Builder. This library holds a [`Workspace`](./src/main/java/com/adobe/aio/Workspace.java) POJO modeling your [Adobe Developer Console Project Workspace](https://www.adobe.io/apis/experienceplatform/console/docs.html#!AdobeDocs/adobeio-console/master/projects.md), -To get you started quickly you could use a `.properties` file, -see our [sample config file](./src/test/resources/workspace.properties) and our JUnit Test +To get you started quickly use a `.properties` file, +* see our [sample config file](./src/test/resources/workspace.properties) in our jUnit Test. +* download your `project` configurations file from your Adobe Developer Console Project overview page +* map your `project` configurations with this properties -For now, you have a bit of copy and paste to do, but we have a plan to streamline the process: +For now, you do have a bit of copy and paste to do, but we have a plan to streamline the process: * https://github.com/adobe/aio-lib-java/issues/5 +The `Workspace` POJO holds your Adobe Developer Console Project configurations + (download your `project` configurations file from your Adobe Developer Console Project overview page): +* `aio_project_id` your Adobe Developer Console project id (`project.id`) +* `aio_consumer_org_id` your Adobe Developer Console consumer orgnaization id (`project.org.id`) +* `aio_ims_org_id` your Adobe Developer Console IMS Organization ID (`project.org.ims_org_id`) +* `aio_workspace_id` your Adobe Developer Console workspace Id (`project.workspace.id`) +* `aio_credential_id` your Adobe Developer Console jwt credential id (`project.workspace.details.credentials[i].id`) +* `aio_client_secret` your Adobe Developer Console jwt credential client secret (`project.workspace.details.credentials[i].jwt.client_secret`) +* `aio_api_key` your Adobe Developer Console jwt credential API Key (or Client ID) (`project.workspace.details.credentials[i].jwt.client_id`) +* `aio_meta_scopes` a comma separated list of metascopes associated with your API, see your Adobe Developer Console jwt credential metascopes (`project.workspace.details.credentials[i].jwt.meta_scopes`) +* `aio_technical_account_id` your Adobe Developer Console jwt credential technical account id (`project.workspace.details.credentials[i].jwt.technical_account_id`) + ## Builds This Library is build with [maven](https://maven.apache.org/) (it also runs the unit tests): diff --git a/core/pom.xml b/core/pom.xml index 1520e790..9b61e747 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -17,7 +17,7 @@ com.adobe.aio aio-lib-java - 0.0.26 + 0.0.28 ../pom.xml 4.0.0 diff --git a/core/src/test/resources/workspace.properties b/core/src/test/resources/workspace.properties index 1a12fd98..2aae79da 100644 --- a/core/src/test/resources/workspace.properties +++ b/core/src/test/resources/workspace.properties @@ -10,24 +10,24 @@ # governing permissions and limitations under the License. # -# aio_meta_scopes : comma separated list of metascopes associated with your API -# sample aio_meta_scopes: /s/ent_user_sdk,/s/ent_marketing_sdk,/s/creative_sdk -aio_meta_scopes=aio_meta_scopes_changeMe -# aio_ims_org_id = your IMS Organization ID as shown in your Adobe Developer Console workspace -aio_ims_org_id=aio_ims_org_id_changeMe -# aio_consumer_org_id = your consumer Org Id as shown in your Adobe Developer Console workspace (project.org.id) -aio_consumer_org_id=aio_consumer_org_id_changeMe -# aio_project_id = your project Id as shown in your Adobe Developer Console workspace (project.id) +# aio_project_id = your Adobe Developer Console project id (project.id) aio_project_id=aio_project_id_changeMe -# aio_workspace_id = your workspace Id as shown in your Adobe Developer Console workspace (project.workspace.id) +# aio_consumer_org_id = your Adobe Developer Console consumer orgnaization id (project.org.id) +aio_consumer_org_id=aio_consumer_org_id_changeMe +# aio_ims_org_id = your Adobe Developer Console IMS Organization ID (project.org.ims_org_id) +aio_ims_org_id=aio_ims_org_id_changeMe +# aio_workspace_id = your Adobe Developer Console workspace Id (project.workspace.id) aio_workspace_id=aio_workspace_id_changeMe -# aio_api_key = your credential API Key (Client ID) as shown in in your Adobe Developer Console workspace -aio_api_key=aio_api_key_changeMe -# aio_credential_id = your credential id as shown in your Adobe Developer Console workspace +# aio_credential_id = your Adobe Developer Console jwt credential id (project.workspace.details.credentials[i].id) aio_credential_id=aio_credential_id_changeMe -# aio_client_secret = your credential Client secret as shown in in your Adobe Developer Console workspace +# aio_client_secret = your Adobe Developer Console jwt credential client secret (project.workspace.details.credentials[i].jwt.client_secret) aio_client_secret=aio_client_secret_changeMe -# aio_technical_account_id = your credential Technical account ID as shown in your Adobe Developer Console workspace +# aio_api_key = your Adobe Developer Console jwt credential API Key (or Client ID) (project.workspace.details.credentials[i].jwt.client_id +aio_api_key=aio_api_key_changeMe +# aio_meta_scopes : comma separated list of metascopes associated with your API, see your Adobe Developer Console jwt credential metascopes (project.workspace.details.credentials[i].jwt.meta_scopes) +# sample aio_meta_scopes: /s/ent_user_sdk,/s/ent_marketing_sdk,/s/creative_sdk (project.workspace.details.credentials[i].jwt.meta_scopes) +aio_meta_scopes=aio_meta_scopes_changeMe +# aio_technical_account_id = your Adobe Developer Console jwt credential technical account id (project.workspace.details.credentials[i].jwt.technical_account_id) aio_technical_account_id=aio_technical_account_id_changeMe diff --git a/events_ingress/pom.xml b/events_ingress/pom.xml index bc8df96b..b0f04821 100644 --- a/events_ingress/pom.xml +++ b/events_ingress/pom.xml @@ -17,7 +17,7 @@ com.adobe.aio aio-lib-java - 0.0.26 + 0.0.28 ../pom.xml 4.0.0 diff --git a/events_journal/pom.xml b/events_journal/pom.xml index d5ea03b1..bdd0b95d 100644 --- a/events_journal/pom.xml +++ b/events_journal/pom.xml @@ -17,7 +17,7 @@ com.adobe.aio aio-lib-java - 0.0.26 + 0.0.28 ../pom.xml 4.0.0 diff --git a/events_mgmt/pom.xml b/events_mgmt/pom.xml index 978fae75..b29817bf 100644 --- a/events_mgmt/pom.xml +++ b/events_mgmt/pom.xml @@ -17,7 +17,7 @@ com.adobe.aio aio-lib-java - 0.0.26 + 0.0.28 ../pom.xml 4.0.0 diff --git a/ims/README.md b/ims/README.md index 43e3d644..e0ceaeed 100644 --- a/ims/README.md +++ b/ims/README.md @@ -19,32 +19,11 @@ token and must be signed with the private key that is associated with a public k This Java library will help you implement this JWT exchange token flow, to get a valid access token and start interacting with the many Adobe I/O API that support such authentication. -### Test Drive - - PrivateKey privateKey = new PrivateKeyBuilder().systemEnv().build(); // [1] - Workspace workspace = Workspace.builder() - .systemEnv() - .privateKey(privateKey) - .build(); // [2] - ImsService imsService = ImsService.builder().workspace(workspace).build(); // [3] - - AccessToken accessToken = imsService.getJwtExchangeAccessToken(); // [4] - - // [1] Build your PrivateKey looking up the key indicated by you System Environment variables - // [2] build your `Workspace` (a Java POJO representation of your `Adobe Developer Console` Workspace) - // looking up other System Environment variables. - // Note that our fluent workspace and private Key builders offers many ways to have your workspace configured, - // we are showing here the most concise - // [3] build the Ims Service wrapper and have it use this workspace context - // [4] use this service to retrieve an access token using a jwt exchange token flow - - -Have a look at our [ImsService `main()` Test Drive](./src/test/java/com/adobe/aio/ims/ImsServiceTestDrive.java) - ### Configurations Browse our [Service Account Integration (JWT authentication flow) doc](https://www.adobe.io/authentication/auth-methods.html#!AdobeDocs/adobeio-auth/master/AuthenticationOverview/ServiceAccountIntegration.md), our fluent workspace builder offers many ways to have your `Workspace` (a Java POJO representation of your `Adobe Developer Console` Workspace) configured. + To get you started quickly you could use a `.properties` file, see our [sample config file](./src/test/resources/workspace.properties) @@ -82,6 +61,29 @@ It can be leverage to add the authentication headers expected by many Adobe APIs * renewing it only when expired (after 24 hours) or when not present in memory yet * a `x-api-key` header matching your JWT token +### Test Drive + + PrivateKey privateKey = new PrivateKeyBuilder().systemEnv().build(); // [1] + Workspace workspace = Workspace.builder() + .systemEnv() + .privateKey(privateKey) + .build(); // [2] + ImsService imsService = ImsService.builder().workspace(workspace).build(); // [3] + + AccessToken accessToken = imsService.getJwtExchangeAccessToken(); // [4] + + // [1] Build your PrivateKey looking up the key indicated by you System Environment variables + // [2] build your `Workspace` (a Java POJO representation of your `Adobe Developer Console` Workspace) + // looking up other System Environment variables. + // Note that our fluent workspace and private Key builders offers many ways to have your workspace configured, + // we are showing here the most concise + // [3] build the Ims Service wrapper and have it use this workspace context + // [4] use this service to retrieve an access token using a jwt exchange token flow + + +Have a look at our [ImsService `main()` Test Drive](./src/test/java/com/adobe/aio/ims/ImsServiceTestDrive.java) + + ## Builds This Library is build with [maven](https://maven.apache.org/) (it also runs the unit tests): diff --git a/ims/pom.xml b/ims/pom.xml index 2bbbd58e..3be3e91e 100644 --- a/ims/pom.xml +++ b/ims/pom.xml @@ -17,7 +17,7 @@ com.adobe.aio aio-lib-java - 0.0.26 + 0.0.28 ../pom.xml 4.0.0 diff --git a/ims/src/test/resources/workspace.properties b/ims/src/test/resources/workspace.properties index eee7361d..09b6c16a 100644 --- a/ims/src/test/resources/workspace.properties +++ b/ims/src/test/resources/workspace.properties @@ -10,21 +10,26 @@ # governing permissions and limitations under the License. # -# meta_scopes : comma separated list of metascopes associated with your API -# sample meta_scopes: /s/ent_user_sdk,/s/ent_marketing_sdk,/s/creative_sdk -aio_meta_scopes=aio_meta_scopes_changeMe -# ims_org_id = your IMS Organization ID as shown in your Adobe Developer Console workspace -aio_ims_org_id=aio_ims_org_id_changeMe -# consumer_org_id = your consumer Org Id as shown in your Adobe Developer Console workspace +# aio_project_id = your Adobe Developer Console project id (project.id) +aio_project_id=aio_project_id_changeMe +# aio_consumer_org_id = your Adobe Developer Console consumer orgnaization id (project.org.id) aio_consumer_org_id=aio_consumer_org_id_changeMe -# api_key = your credential API Key (Client ID) as shown in in your Adobe Developer Console workspace -aio_api_key=aio_api_key_changeMe -# credential_id = your credential id as shown in your Adobe Developer Console workspace +# aio_ims_org_id = your Adobe Developer Console IMS Organization ID (project.org.ims_org_id) +aio_ims_org_id=aio_ims_org_id_changeMe +# aio_workspace_id = your Adobe Developer Console workspace Id (project.workspace.id) +aio_workspace_id=aio_workspace_id_changeMe +# aio_credential_id = your Adobe Developer Console jwt credential id (project.workspace.details.credentials[i].id) aio_credential_id=aio_credential_id_changeMe -# client_secret = your credential Client secret as shown in in your Adobe Developer Console workspace +# aio_client_secret = your Adobe Developer Console jwt credential client secret (project.workspace.details.credentials[i].jwt.client_secret) aio_client_secret=aio_client_secret_changeMe -# technical_account_id = your credential Technical account ID as shown in your Adobe Developer Console workspace +# aio_api_key = your Adobe Developer Console jwt credential API Key (or Client ID) (project.workspace.details.credentials[i].jwt.client_id +aio_api_key=aio_api_key_changeMe +# aio_meta_scopes : comma separated list of metascopes associated with your API, see your Adobe Developer Console jwt credential metascopes (project.workspace.details.credentials[i].jwt.meta_scopes) +# sample aio_meta_scopes: /s/ent_user_sdk,/s/ent_marketing_sdk,/s/creative_sdk (project.workspace.details.credentials[i].jwt.meta_scopes) +aio_meta_scopes=aio_meta_scopes_changeMe +# aio_technical_account_id = your Adobe Developer Console jwt credential technical account id (project.workspace.details.credentials[i].jwt.technical_account_id) aio_technical_account_id=aio_technical_account_id_changeMe + # You then have 3 options to configure the privateKey (associated with the public key set in your Adobe Developer Console workspace): # * Option 1: use a pcks8 file (using the `aio_pkcs8_file_path` config) # * Option 2: use base 64 encoded pcks8 key (using the `aio_encoded_pkcs8` config) diff --git a/pom.xml b/pom.xml index 35d89232..51ac9581 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ com.adobe.aio aio-lib-java - 0.0.26 + 0.0.28 pom @@ -71,7 +71,7 @@ scm:git:https://github.com/adobe/aio-lib-java.git scm:git:https://github.com/adobe/aio-lib-java.git https://github.com/adobe/aio-lib-java/tree/master - aio-lib-java-0.0.26 + aio-lib-java-0.0.28