mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user