Move RSA keys to their own file

RSA keys are sensitive information that should not be stored in git repositories.
This commit moves them to their own file, adds it to .gitignore and provides a template file.
This commit is contained in:
Cube
2016-03-04 14:55:04 +02:00
parent a02eceb436
commit 0eb8a6e7e6
4 changed files with 22 additions and 14 deletions
@@ -55,15 +55,6 @@ public final class NetworkConstants {
throw new IOException("Root node name is not 'net'.");
}
XmlNode rsa = net.getChild("rsa");
Preconditions.checkState(rsa != null, "Root node must have a child named 'rsa'.");
XmlNode modulus = rsa.getChild("modulus"), exponent = rsa.getChild("private-exponent");
Preconditions.checkState(modulus != null && exponent != null, "Rsa node must have two children: 'modulus' and 'private-exponent'.");
RSA_MODULUS = new BigInteger(modulus.getValue());
RSA_EXPONENT = new BigInteger(exponent.getValue());
XmlNode ports = net.getChild("ports");
Preconditions.checkState(ports != null, "Root node must have a child named 'ports'.");
@@ -76,6 +67,22 @@ public final class NetworkConstants {
} catch (Exception exception) {
throw new ExceptionInInitializerError(new IOException("Error parsing net.xml.", exception));
}
try (InputStream is = new FileInputStream("data/rsa.xml")) {
XmlNode rsa = new XmlParser().parse(is);
if (!rsa.getName().equals("rsa")) {
throw new IOException("Root node name is not 'rsa'.");
}
XmlNode modulus = rsa.getChild("modulus"), exponent = rsa.getChild("private-exponent");
Preconditions.checkState(modulus != null && exponent != null, "Rsa node must have two children: 'modulus' and 'private-exponent'.");
Preconditions.checkState(modulus.getValue() != null && exponent.getValue() != null, "Value missing for 'modulus' or 'private-exponent'");
RSA_MODULUS = new BigInteger(modulus.getValue());
RSA_EXPONENT = new BigInteger(exponent.getValue());
} catch (Exception exception) {
throw new ExceptionInInitializerError(new IOException("Error parsing rsa.xml", exception));
}
}
/**