summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-10-22 14:06:33 +0200
committerBjörn Hagemeister2014-10-22 14:06:33 +0200
commitfffaa68a16df723fb7ce058874078b8fed60fbce (patch)
treed7ede670071a8c64db29d6d2cec4270396f2162c /src
parentImplemented updateAddress - method. (diff)
downloadmasterserver-fffaa68a16df723fb7ce058874078b8fed60fbce.tar.gz
masterserver-fffaa68a16df723fb7ce058874078b8fed60fbce.tar.xz
masterserver-fffaa68a16df723fb7ce058874078b8fed60fbce.zip
Store publickey in DbSatellite with prefix mod: and exp: for better indicating of the two numbers.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openslx/imagemaster/db/DbSatellite.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java
index 7a6ef2f..4f2576e 100644
--- a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java
+++ b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java
@@ -114,11 +114,27 @@ public class DbSatellite
{
if ( publickey == null && publickeyString != null ) {
String parts[] = publickeyString.split( " " );
- if ( parts.length != 2 )
+ BigInteger mod = null;
+ BigInteger exp = null;
+ for ( int i = 0; i < parts.length; ++i ) {
+ if ( parts[i].startsWith( "mod:" ) ) {
+ // modulus found.
+ mod = new BigInteger( parts[i].substring( 4 ) );
+ }
+ if ( parts[i].startsWith( "exp:" ) ) {
+ // exponent found.
+ exp = new BigInteger( parts[i].substring( 4 ) );
+ }
+ }
+ if ( mod == null ) {
+ LOG.error( "No modulus for building public key was found." );
+ return null;
+ }
+ if ( exp == null ) {
+ LOG.error( "No public exponent for building public key was found." );
return null;
+ }
try {
- BigInteger mod = new BigInteger( parts[0] );
- BigInteger exp = new BigInteger( parts[1] );
publickey = new AsymKeyHolder( null, exp, mod ).getPublicKey();
} catch ( InvalidKeySpecException | NoSuchAlgorithmException e ) {
LOG.info( "PubKey of " + this.name + " is not valid.", e );
@@ -133,7 +149,7 @@ public class DbSatellite
{
this.address = address;
this.organizationId = organization;
- MySQL.update( "UPDATE satellite SET address = ? WHERE organizationid = ?", address, organization);
+ MySQL.update( "UPDATE satellite SET address = ? WHERE organizationid = ?", address, organization );
}
}