summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 );
}
}