From 1b653f8f1210254ad71949ebc52ed7500951e92a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 15 Oct 2014 20:39:03 +0200 Subject: Implement suffixList for getOrganizations, added stub for updateSatelliteAddress --- .../org/openslx/imagemaster/db/DbSatellite.java | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/openslx/imagemaster/db/DbSatellite.java') diff --git a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java index 4d70bef..f882977 100644 --- a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java +++ b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java @@ -4,6 +4,7 @@ import java.math.BigInteger; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; +import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -18,10 +19,11 @@ public class DbSatellite { private static final Logger LOG = Logger.getLogger( DbSatellite.class ); - private String organizationId, address, name, publickeyString; + private String organizationId, address, name, publickeyString, authMethod; private PublicKey publickey = null; + private List suffixList = null; - public DbSatellite( String organizationId, String address, String name, String publickeyString ) + public DbSatellite( String organizationId, String address, String name, String authMethod, String publickeyString ) { this.organizationId = organizationId; this.address = address; @@ -34,7 +36,7 @@ public class DbSatellite return MySQL .findUniqueOrNull( DbSatellite.class, - "SELECT satellite.organizationid, satellite.address, satellite.name, satellite.publickey FROM satellite WHERE satellite.organizationid = ? LIMIT 1", + "SELECT satellite.organizationid, satellite.address, satellite.name, satellite.authmethod, satellite.publickey FROM satellite WHERE satellite.organizationid = ? LIMIT 1", organizationId ); } @@ -43,7 +45,7 @@ public class DbSatellite return MySQL .findUniqueOrNull( DbSatellite.class, - "SELECT satellite.organizationid, satellite.address, satellite.name, satellite.publickey FROM satellite" + "SELECT satellite.organizationid, satellite.address, satellite.name, satellite.authmethod, satellite.publickey FROM satellite" + " INNER JOIN satellite_suffix USING (organizationid)" + " WHERE satellite_suffix.suffix = ? LIMIT 1", suffix ); @@ -57,7 +59,14 @@ public class DbSatellite */ public static List asOrganizationDataList() { - return MySQL.findAll( OrganizationData.class, "SELECT satellite.organizationid, satellite.name, satellite.authmethod FROM satellite" ); + List sats = MySQL.findAll( + DbSatellite.class, + "SELECT satellite.organizationid, satellite.address, satellite.name, satellite.authmethod, satellite.publickey FROM satellite" ); + List orgData = new ArrayList<>(); + for ( DbSatellite sat : sats ) { + orgData.add( new OrganizationData( sat.getOrganizationId(), sat.getName(), sat.getAuthenticationMethod(), sat.getSuffixList() ) ); + } + return orgData; } public static DbSatellite fromPrefix( String prefix ) @@ -84,6 +93,18 @@ public class DbSatellite return organizationId; } + public String getAuthenticationMethod() + { + return authMethod; + } + + public List getSuffixList() + { + if ( this.suffixList == null ) + this.suffixList = DbSatelliteSuffix.forSatellite( this ); + return this.suffixList; + } + /** * Get the public key of this organization, if known and valid. * -- cgit v1.2.3-55-g7522