From 1bb7917efc9747d1dc05970513a5ea673835a8c9 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Wed, 15 Oct 2014 15:42:58 +0200 Subject: Implemented --importId command line option and adapted TODO.txt. --- .../java/org/openslx/satellitedaemon/Identity.java | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/openslx/satellitedaemon/Identity.java') diff --git a/src/main/java/org/openslx/satellitedaemon/Identity.java b/src/main/java/org/openslx/satellitedaemon/Identity.java index 6e5c877..ce6b753 100644 --- a/src/main/java/org/openslx/satellitedaemon/Identity.java +++ b/src/main/java/org/openslx/satellitedaemon/Identity.java @@ -147,6 +147,13 @@ public class Identity return isPassed; } + /** + * Generate new identity with given organization name and new key pair. + * Write new identity to "config/identity.properties". + * + * @param organizationName + * @return true, if successful. + */ public static boolean generateIdentity( String organizationName ) { Identity.organizationName = organizationName; @@ -163,6 +170,39 @@ public class Identity Identity.pubExponent ); } + /** + * Import given identity with organization name, modulus, private and public + * exponent and store this identity to "config/identity.properties". + * + * @param organizationName + * @param modulus + * @param privateExp + * @param publicExp + * @return true, if successful. + */ + public static boolean importIdentity( String organizationName, BigInteger modulus, BigInteger privateExp, BigInteger publicExp ) + { + Identity.organizationName = organizationName; + Identity.modulus = modulus; + Identity.privExponent = privateExp; + Identity.pubExponent = publicExp; + return writeIdToFile( + Identity.organizationName, + Identity.modulus, + Identity.privExponent, + Identity.pubExponent ); + } + + /** + * Write given organization name, modulus, public and private exponent to + * "config/identity.properties". + * + * @param organizationName + * @param modulus + * @param privateExp + * @param publicExp + * @return true, if successful. + */ private static boolean writeIdToFile( String organizationName, BigInteger modulus, BigInteger privateExp, BigInteger publicExp ) { File configFile = new File( "config/identity.properties" ); @@ -173,7 +213,7 @@ public class Identity log.error( "FileNotFoundException", e ); return false; } - + // create strings for writing to file. String orgNameString = "ORGANIZATION_NAME=" + organizationName + "\n"; String modString = "MODULUS=" + modulus.toString() + "\n"; -- cgit v1.2.3-55-g7522