Adding timestamp support for keys as a prerequisite for key rotation.
diff --git a/src/main/java/io/mifos/core/test/env/TestEnvironment.java b/src/main/java/io/mifos/core/test/env/TestEnvironment.java
index 0d4e079..de00558 100644
--- a/src/main/java/io/mifos/core/test/env/TestEnvironment.java
+++ b/src/main/java/io/mifos/core/test/env/TestEnvironment.java
@@ -35,6 +35,7 @@
public static final String SERVER_CONTEXT_PATH_PROPERTY = "server.contextPath";
+ public static final String SYSTEM_PUBLIC_KEY_TIMESTAMP_PROPERTY = "system.publicKey.timestamp";
public static final String SYSTEM_PUBLIC_KEY_MODULUS_PROPERTY = "system.publicKey.modulus";
public static final String SYSTEM_PUBLIC_KEY_EXPONENT_PROPERTY = "system.publicKey.exponent";
public static final String SYSTEM_PRIVATE_KEY_MODULUS_PROPERTY = "system.privateKey.modulus";
@@ -137,6 +138,10 @@
this.properties.getProperty(TestEnvironment.SERVER_CONTEXT_PATH_PROPERTY);
}
+ public String getSystemKeyTimestamp() {
+ return keyPairHolder.getTimestamp();
+ }
+
public RSAPublicKey getSystemPublicKey() {
return keyPairHolder.publicKey();
}
@@ -145,9 +150,9 @@
return keyPairHolder.privateKey();
}
- public void setKeyPair(final RSAPublicKey publicKey, final RSAPrivateKey privateKey)
+ public void setKeyPair(final String timestamp, final RSAPublicKey publicKey, final RSAPrivateKey privateKey)
{
- this.keyPairHolder = new RsaKeyPairFactory.KeyPairHolder(publicKey, privateKey);
+ this.keyPairHolder = new RsaKeyPairFactory.KeyPairHolder(timestamp, publicKey, privateKey);
this.properties.setProperty(SYSTEM_PUBLIC_KEY_MODULUS_PROPERTY, publicKey.getModulus().toString());
this.properties.setProperty(SYSTEM_PUBLIC_KEY_EXPONENT_PROPERTY, publicKey.getPublicExponent().toString());
@@ -205,6 +210,7 @@
this.keyPairHolder = RsaKeyPairFactory.createKeyPair();
+ this.properties.setProperty(SYSTEM_PUBLIC_KEY_TIMESTAMP_PROPERTY, this.keyPairHolder.getTimestamp());
this.properties.setProperty(SYSTEM_PUBLIC_KEY_MODULUS_PROPERTY, this.keyPairHolder.publicKey().getModulus().toString());
this.properties.setProperty(SYSTEM_PUBLIC_KEY_EXPONENT_PROPERTY, this.keyPairHolder.publicKey().getPublicExponent().toString());
}