fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-provisioner] 14/50: Minor logging, constant introduction, cleanup.
Date Mon, 22 Jan 2018 15:16:12 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-provisioner.git

commit 7461179ab1700bf5e472920396f98dac99a5580b
Author: myrle-krantz <mkrantz@mifos.org>
AuthorDate: Thu Apr 13 11:53:46 2017 +0200

    Minor logging, constant introduction, cleanup.
---
 .../io/mifos/provisioner/config/ProvisionerServiceConfig.java  | 10 +++++++---
 .../service/applications/IdentityServiceInitializer.java       |  8 ++++++--
 .../java/io/mifos/provisioner/internal/util/TokenProvider.java |  2 +-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/service/src/main/java/io/mifos/provisioner/config/ProvisionerServiceConfig.java
b/service/src/main/java/io/mifos/provisioner/config/ProvisionerServiceConfig.java
index b2264aa..b9be547 100644
--- a/service/src/main/java/io/mifos/provisioner/config/ProvisionerServiceConfig.java
+++ b/service/src/main/java/io/mifos/provisioner/config/ProvisionerServiceConfig.java
@@ -15,6 +15,7 @@
  */
 package io.mifos.provisioner.config;
 
+import io.mifos.anubis.config.AnubisConstants;
 import io.mifos.anubis.config.EnableAnubis;
 import io.mifos.anubis.token.SystemAccessTokenSerializer;
 import io.mifos.core.api.util.ApiFactory;
@@ -64,9 +65,12 @@ public class ProvisionerServiceConfig {
 
   @Bean(name = "tokenProvider")
   public TokenProvider tokenProvider(final Environment environment,
-                                     @SuppressWarnings("SpringJavaAutowiringInspection")
final SystemAccessTokenSerializer tokenSerializer) {
-    return new TokenProvider(
-        environment.getProperty("system.publicKey.timestamp"),
+                                     @SuppressWarnings("SpringJavaAutowiringInspection")
final SystemAccessTokenSerializer tokenSerializer,
+                                     @Qualifier(ProvisionerConstants.LOGGER_NAME) final Logger
logger) {
+    final String timestamp = environment.getProperty(AnubisConstants.PUBLIC_KEY_TIMESTAMP_PROPERTY);
+    logger.info("Provisioner key timestamp: " + timestamp);
+
+    return new TokenProvider( timestamp,
         new BigInteger(environment.getProperty("system.privateKey.modulus")),
         new BigInteger(environment.getProperty("system.privateKey.exponent")), tokenSerializer);
   }
diff --git a/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
b/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
index 4ffb7d8..f251185 100644
--- a/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
+++ b/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
@@ -19,6 +19,8 @@ package io.mifos.provisioner.internal.service.applications;
 import io.mifos.anubis.api.v1.client.Anubis;
 import io.mifos.anubis.api.v1.domain.ApplicationSignatureSet;
 import io.mifos.anubis.api.v1.domain.PermittableEndpoint;
+import io.mifos.core.api.util.InvalidTokenException;
+import io.mifos.core.lang.ServiceException;
 import io.mifos.identity.api.v1.client.IdentityManager;
 import io.mifos.identity.api.v1.client.PermittableGroupAlreadyExistsException;
 import io.mifos.identity.api.v1.client.TenantAlreadyInitializedException;
@@ -89,8 +91,7 @@ public class IdentityServiceInitializer {
           final @Nonnull String applicationName,
           final @Nonnull String identityManagerUri) {
     try (final AutoCloseable ignored
-                 = applicationCallContextProvider.getApplicationCallContext(tenantIdentifier,
applicationName))
-    {
+                 = applicationCallContextProvider.getApplicationCallContext(tenantIdentifier,
applicationName)) {
       final IdentityManager identityService = applicationCallContextProvider.getApplication(IdentityManager.class,
identityManagerUri);
       try {
         final String randomPassword = RandomStringUtils.random(8, true, true);
@@ -115,6 +116,9 @@ public class IdentityServiceInitializer {
 
         return new IdentityServiceInitializationResult(signatureSet);
       }
+    } catch (final InvalidTokenException e) {
+      throw ServiceException.conflict("The given identity instance didn't recognize the system
token as valid.  " +
+              "Perhaps the system keys for the provisioner or for the identity manager are
misconfigured?");
     } catch (final Exception e) {
       throw new IllegalStateException(e);
     }
diff --git a/service/src/main/java/io/mifos/provisioner/internal/util/TokenProvider.java b/service/src/main/java/io/mifos/provisioner/internal/util/TokenProvider.java
index fc3d6ea..98c1980 100644
--- a/service/src/main/java/io/mifos/provisioner/internal/util/TokenProvider.java
+++ b/service/src/main/java/io/mifos/provisioner/internal/util/TokenProvider.java
@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
 
 public class TokenProvider {
   private final String keyTimestamp;
-  private PrivateKey privateKey;
+  private final PrivateKey privateKey;
   private final SystemAccessTokenSerializer tokenSerializer;
 
   public TokenProvider(

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message