From 282482d80de0abb5cec0d03ec3da97b424c86a56 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 11 Aug 2016 08:31:15 +0200 Subject: [PATCH 1/3] [Evo] ref #11 - Link boostrapped services and instances to the Ozwillo organization --- oasis-webapp/src/main/java/oasis/tools/Bootstrap.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java b/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java index 42b628fa..22de2865 100644 --- a/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java +++ b/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java @@ -308,6 +308,7 @@ private String createPortal(String oasisOrgId, String adminAccountId) { instance.setApplication_id(app.getId()); instance.setStatus(AppInstance.InstantiationStatus.RUNNING); instance.setInstantiator_id(adminAccountId); + instance.setProvider_id(oasisOrgId); for (String scopeId : new String[] { Scopes.OPENID, Scopes.PROFILE, Scopes.EMAIL, Scopes.ADDRESS, Scopes.PHONE, "datacore" }) { AppInstance.NeededScope neededScope = new AppInstance.NeededScope(); neededScope.setScope_id(scopeId); @@ -321,6 +322,7 @@ private String createPortal(String oasisOrgId, String adminAccountId) { Service service = new Service(); service.setLocal_id("front"); service.setInstance_id(instance.getId()); + service.setProvider_id(instance.getProvider_id()); service.setVisibility(Service.Visibility.HIDDEN); service.setAccess_control(Service.AccessControl.ANYONE); service.setStatus(Service.Status.AVAILABLE); @@ -345,6 +347,7 @@ private String createDatacore(String oasisOrgId, String adminAccountId) { instance.setApplication_id(app.getId()); instance.setStatus(AppInstance.InstantiationStatus.RUNNING); instance.setInstantiator_id(adminAccountId); + instance.setProvider_id(oasisOrgId); jongoProvider.get().getCollection(JongoAppInstanceRepository.COLLECTION_NAME).insert(instance); String clientSecret = passwordGeneratorProvider.get().generate(); From 5cda39fc4fe8479d8480adecf91edec9305dc8ac Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 11 Aug 2016 08:31:57 +0200 Subject: [PATCH 2/3] [Evo] ref #12 - Add DC Playground service to the bootstrapped data --- INSTALL.md | 9 ++++-- .../src/main/java/oasis/tools/Bootstrap.java | 29 +++++++++++++++++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 544fef99..e0e069af 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -159,15 +159,18 @@ Options are: * `-a` or `--admin`: **required**, the email address of the super administrator. * `-p` or `--password`: the administrator's password; one will be generated and printed to the standard output if not given. - * `-r` or `--redirect-uri`: **required**, the Ozwillo Portal's `redirect_uri`. - * `-plr` or `--post-logout-redirect-uri`: **required**, the Ozwillo Portal's `post_logout_redirect_uri`. + * `-pr` or `--portal-redirect-uri`: **required**, the Ozwillo Portal's `redirect_uri`. + * `-plr` or `--portal-post-logout-redirect-uri`: **required**, the Ozwillo Portal's `post_logout_redirect_uri`. + * `-dr` or `--datacore-redirect-uri`: **required**, the Ozwillo Datacore Playground's `redirect_uri`. + * `-ds` or `--datacore-service-uri`: **required**, the Ozwillo Datacore Playground's `service_uri`. + * `-di` or `--datacore-icon`: **required**, the Ozwillo Datacore Playground's icon. The tool will create: * the OpenID Connect 1.0 scopes, * a super administrator user, * an _“Ozwillo”_ organization, whose administrator will be the super administrator user, * the Ozwillo Portal application, instance, and service, - * the Ozwillo DataCore application and instance (note: it does **not** create the _playground_ service.) + * the Ozwillo DataCore application, instance, and its Playground service Periodic tasks -------------- diff --git a/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java b/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java index 22de2865..d8d68f10 100644 --- a/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java +++ b/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java @@ -75,14 +75,26 @@ public static void main(String[] args) throws Exception { usage = "Administrator's password") private String adminPassword; - @Option(name = "-r", aliases = "--redirect-uri", required = true, + @Option(name = "-pr", aliases = "--portal-redirect-uri", required = true, usage = "Portal's redirect_uri") private String portalRedirectUri; - @Option(name = "-plr", aliases = "--post-logout-redirect-uri", required = true, + @Option(name = "-plr", aliases = "--portal-post-logout-redirect-uri", required = true, usage = "Portal's post_logout_redirect_uri") private String portalPostLogoutRedirectUri; + @Option(name = "-dr", aliases = "--datacore-redirect-uri", required = true, + usage = "Datacore Playground's redirect_uri") + private String datacoreRedirectUri; + + @Option(name = "-ds", aliases = "--datacore-service-uri", required = true, + usage = "Datacore Playground's service_uri") + private String datacoreServiceUri; + + @Option(name = "-di", aliases = "--datacore-icon", required = true, + usage = "Datacore Playground's icon") + private String datacoreIcon; + @Inject JongoService jongoService; @Inject Provider jongoProvider; @Inject Provider scopeRepositoryProvider; @@ -362,7 +374,18 @@ private String createDatacore(String oasisOrgId, String adminAccountId) { scope.getName().set(ULocale.ROOT, "Datacore"); scopeRepositoryProvider.get().createOrUpdateScope(scope); - // XXX: do we need a service? + Service service = new Service(); + service.setLocal_id("playground"); + service.setInstance_id(instance.getId()); + service.setProvider_id(instance.getProvider_id()); + service.setVisibility(Service.Visibility.HIDDEN); + service.setAccess_control(Service.AccessControl.RESTRICTED); + service.setStatus(Service.Status.AVAILABLE); + service.getName().set(ULocale.ROOT, "Ozwillo Datacore Playground"); + service.getRedirect_uris().add(datacoreRedirectUri); + service.setService_uri(datacoreServiceUri); + service.getIcon().set(ULocale.ROOT, datacoreIcon); + serviceRepositoryProvider.get().createService(service); return clientSecret; } From 7d3133db616f8fb8cb9ed304431035c6fbac34d2 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Mon, 22 Aug 2016 15:00:47 +0200 Subject: [PATCH 3/3] [Evo] ref #14 - Add DC Exporter to bootstrapped data --- INSTALL.md | 5 +- .../java/oasis/model/bootstrap/ClientIds.java | 5 +- .../src/main/java/oasis/tools/Bootstrap.java | 52 +++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index e0e069af..1ed2ebec 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -164,13 +164,16 @@ Options are: * `-dr` or `--datacore-redirect-uri`: **required**, the Ozwillo Datacore Playground's `redirect_uri`. * `-ds` or `--datacore-service-uri`: **required**, the Ozwillo Datacore Playground's `service_uri`. * `-di` or `--datacore-icon`: **required**, the Ozwillo Datacore Playground's icon. + * `-der` or `--dcexporter-redirect-uri`: the Ozwillo Datacore Exporter's `redirect_uri`. + * `-des` or `--dcexporter-service-uri`: the Ozwillo Datacore Exporter's `service_uri`. The tool will create: * the OpenID Connect 1.0 scopes, * a super administrator user, * an _“Ozwillo”_ organization, whose administrator will be the super administrator user, * the Ozwillo Portal application, instance, and service, - * the Ozwillo DataCore application, instance, and its Playground service + * the Ozwillo DataCore application, instance, and its Playground service, + * the Ozwillo DataCore Exporter application, instance and service Periodic tasks -------------- diff --git a/oasis-model/src/main/java/oasis/model/bootstrap/ClientIds.java b/oasis-model/src/main/java/oasis/model/bootstrap/ClientIds.java index 87b636ca..7f99dab7 100644 --- a/oasis-model/src/main/java/oasis/model/bootstrap/ClientIds.java +++ b/oasis-model/src/main/java/oasis/model/bootstrap/ClientIds.java @@ -18,7 +18,8 @@ package oasis.model.bootstrap; public interface ClientIds { - static final String PORTAL = "portal"; - static final String DATACORE = "dc"; + String PORTAL = "portal"; + String DATACORE = "dc"; + String DCEXPORTER = "dcexporter"; // XXX: add a "www" for the CMS part of the portal? } diff --git a/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java b/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java index d8d68f10..9da3b1af 100644 --- a/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java +++ b/oasis-webapp/src/main/java/oasis/tools/Bootstrap.java @@ -95,6 +95,14 @@ public static void main(String[] args) throws Exception { usage = "Datacore Playground's icon") private String datacoreIcon; + @Option(name = "-der", aliases = "--dcexporter-redirect-uri", + usage = "Datacore Exporter's redirect_uri") + private String dcexporterRedirectUri; + + @Option(name = "-des", aliases = "--dcexporter-service-uri", + usage = "Datacore Exporter's service_uri") + private String dcexporterServiceUri; + @Inject JongoService jongoService; @Inject Provider jongoProvider; @Inject Provider scopeRepositoryProvider; @@ -148,6 +156,10 @@ protected void configure() { logger().info("Generated client_secret for {} instance: {}", ClientIds.PORTAL, portalSecret); String dcSecret = createDatacore(oasisOrgId, adminAccountId); logger().info("Generated client_secret for {} instance: {}", ClientIds.DATACORE, dcSecret); + if (!Strings.isNullOrEmpty(dcexporterRedirectUri) && !Strings.isNullOrEmpty(dcexporterServiceUri)) { + String dcExporterSecret = createDcExporter(oasisOrgId, adminAccountId); + logger().info("Generated client_secret for {} instance: {}", ClientIds.DCEXPORTER, dcExporterSecret); + } } finally { jongoService.stop(); } @@ -389,4 +401,44 @@ private String createDatacore(String oasisOrgId, String adminAccountId) { return clientSecret; } + + private String createDcExporter(String oasisOrgId, String adminAccountId) { + Application app = new Application(); + app.getName().set(ULocale.ROOT, "Ozwillo Datacore Exporter"); + app.setProvider_id(oasisOrgId); + app.setVisible(false); + app = applicationRepositoryProvider.get().createApplication(app); + + JongoAppInstance instance = new JongoAppInstance(); + instance.setId(ClientIds.DCEXPORTER); + instance.getName().set(ULocale.ROOT, "Ozwillo Datacore Exporter"); + instance.setApplication_id(app.getId()); + instance.setStatus(AppInstance.InstantiationStatus.RUNNING); + instance.setInstantiator_id(adminAccountId); + instance.setProvider_id(oasisOrgId); + for (String scopeId : new String[] { Scopes.OPENID, Scopes.PROFILE, Scopes.EMAIL, "datacore" }) { + AppInstance.NeededScope neededScope = new AppInstance.NeededScope(); + neededScope.setScope_id(scopeId); + instance.getNeeded_scopes().add(neededScope); + } + jongoProvider.get().getCollection(JongoAppInstanceRepository.COLLECTION_NAME).insert(instance); + + String clientSecret = passwordGeneratorProvider.get().generate(); + credentialsServiceProvider.get().setPassword(ClientType.PROVIDER, instance.getId(), clientSecret); + + Service service = new Service(); + service.setLocal_id("dcexporter"); + service.setInstance_id(instance.getId()); + service.setProvider_id(instance.getProvider_id()); + service.setVisibility(Service.Visibility.HIDDEN); + service.setAccess_control(Service.AccessControl.RESTRICTED); + service.setStatus(Service.Status.AVAILABLE); + service.getName().set(ULocale.ROOT, "Ozwillo Datacore Exporter"); + service.getRedirect_uris().add(dcexporterRedirectUri); + service.setService_uri(dcexporterServiceUri); + serviceRepositoryProvider.get().createService(service); + + return clientSecret; + + } }