Skip to content
Permalink
Browse files
Re-ordering initialization calls.
  • Loading branch information
mifosio-04-04-2018 committed Jun 8, 2017
1 parent d7b6cf9 commit d3679115b96aadb1627b20c31c367f3ec9ccff97
Showing 3 changed files with 25 additions and 13 deletions.
@@ -126,12 +126,7 @@ private void initializeSecurity(final TenantEntity tenantEntity,


applicationNameToUriPairs.forEach(x -> {
final ApplicationSignatureSet applicationSignatureSet = anubisInitializer.initializeAnubis(
tenantIdentifier,
x.name,
x.uri,
identityManagerSignatureSet.getTimestamp(),
identityManagerSignatureSet.getIdentityManagerSignature());
final ApplicationSignatureSet applicationSignatureSet = anubisInitializer.createSignatureSet(tenantIdentifier, x.name, x.uri, identityManagerSignatureSet.getTimestamp(), identityManagerSignatureSet.getIdentityManagerSignature());

identityServiceInitializer.postApplicationDetails(
tenantIdentifier,
@@ -140,6 +135,11 @@ private void initializeSecurity(final TenantEntity tenantEntity,
x.name,
x.uri,
applicationSignatureSet);

//InitializeResources on the service being added should occur last, for two reasons:
// 1.) When the initialization event is put on the queue for this app/tenant combo, the app is fully ready for business.
// 2.) If the app depeneds on the provisioning of identitypermissions in its initialization, those resources will be there.
anubisInitializer.initializeResources(tenantIdentifier, x.name, x.uri);
});
}

@@ -42,18 +42,27 @@ public AnubisInitializer(
this.logger = logger;
}

public ApplicationSignatureSet initializeAnubis(final @Nonnull String tenantIdentifier,
final @Nonnull String applicationName,
final @Nonnull String uri,
final @Nonnull String keyTimestamp,
final @Nonnull Signature signature) {
public void initializeResources(@Nonnull String tenantIdentifier, @Nonnull String applicationName, @Nonnull String uri) {
try (final AutoCloseable ignored
= this.applicationCallContextProvider.getApplicationCallContext(tenantIdentifier, applicationName))
= this.applicationCallContextProvider.getApplicationCallContext(tenantIdentifier, applicationName))
{
final Anubis anubis = this.applicationCallContextProvider.getApplication(Anubis.class, uri);
anubis.initializeResources();
logger.info("Anubis initializeResources for tenant '{}' and application '{}' succeeded.",
tenantIdentifier, applicationName);

} catch (final Exception e) {
throw new IllegalStateException(e);
}
}

public ApplicationSignatureSet createSignatureSet(@Nonnull String tenantIdentifier, @Nonnull String applicationName, @Nonnull String uri, @Nonnull String keyTimestamp, @Nonnull Signature signature) {
try (final AutoCloseable ignored
= this.applicationCallContextProvider.getApplicationCallContext(tenantIdentifier, applicationName))
{
final Anubis anubis = this.applicationCallContextProvider.getApplication(Anubis.class, uri);
final ApplicationSignatureSet applicationSignatureSet = anubis.createSignatureSet(keyTimestamp, signature);
logger.info("Anubis initialization for io.mifos.provisioner.tenant '{}' and application '{}' succeeded with signature set '{}'.",
logger.info("Anubis createSignatureSet for tenant '{}' and application '{}' succeeded with signature set '{}'.",
tenantIdentifier, applicationName, applicationSignatureSet);
return applicationSignatureSet;

@@ -170,6 +170,7 @@ public void postApplicationDetails(
final List<ApplicationPermission> applicationPermissionRequirements;
try (final AutoCloseable ignored = applicationCallContextProvider.getApplicationCallGuestContext(tenantIdentifier)) {
applicationPermissionRequirements = getApplicationPermissionRequirements(applicationName, applicationUri);
logger.info("Application permission requirements for {} contain {}.", applicationName, applicationPermissionRequirements);

} catch (final Exception e) {
throw new IllegalStateException(e);
@@ -286,6 +287,8 @@ private void createOrFindApplicationPermission(
final @Nonnull ApplicationPermission applicationPermission) {
try {
identityService.createApplicationPermission(applicationName, applicationPermission.getPermission());
logger.info("Application permission '{}.{}' created.",
applicationName, applicationPermission.getPermission().getPermittableEndpointGroupIdentifier());
}
catch (final ApplicationPermissionAlreadyExistsException alreadyExistsException)
{

0 comments on commit d367911

Please sign in to comment.