diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2013-09-26 07:19:58 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2013-09-26 07:19:58 +0200 |
commit | 0773942456e68cf5560655b1bd782ab792c66251 (patch) | |
tree | ae8f8d24e5af2d0c3669ad91b67e4d9a29b20636 | |
parent | cd1a5f3b69f38c1aa7bad2826f2be2df45f75346 (diff) | |
download | moa-id-spss-0773942456e68cf5560655b1bd782ab792c66251.tar.gz moa-id-spss-0773942456e68cf5560655b1bd782ab792c66251.tar.bz2 moa-id-spss-0773942456e68cf5560655b1bd782ab792c66251.zip |
BugFix:
-- MOAMetadataProvider.java: Destroy HTTPMetadataProvider and Timer manually if an Exception occurs
-- ConfigurationDBRead.java: select OA with OAIdentifier (PublicPrefix) has matched to more then one OA in some special case.
2 files changed, 44 insertions, 13 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java index 107ee22ee..443b960a0 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java @@ -107,6 +107,8 @@ public class MOAMetadataProvider implements MetadataProvider { Iterator<OnlineApplication> oaIt = oaList.iterator(); while (oaIt.hasNext()) { + HTTPMetadataProvider httpProvider = null; + try { OnlineApplication oa = oaIt.next(); OAPVP2 pvp2Config = oa.getAuthComponentOA().getOAPVP2(); @@ -124,7 +126,7 @@ public class MOAMetadataProvider implements MetadataProvider { !providersinuse.containsKey(metadataurl) ) { //PVP2 OA is new, add it to MOAMetadataProvider Logger.info("Loading metadata for: " + oa.getFriendlyName()); - HTTPMetadataProvider httpProvider = createNewHTTPMetaDataProvider( + httpProvider = createNewHTTPMetaDataProvider( pvp2Config.getMetadataURL(), pvp2Config.getCertificate(), oa.getFriendlyName()); @@ -138,6 +140,12 @@ public class MOAMetadataProvider implements MetadataProvider { Logger.error( "Failed to add Metadata (unhandled reason: " + e.getMessage(), e); + + if (httpProvider != null) { + Logger.debug("Destroy failed Metadata provider"); + httpProvider.destroy(); + } + } } @@ -213,6 +221,8 @@ public class MOAMetadataProvider implements MetadataProvider { .getAllActiveOnlineApplications(); Iterator<OnlineApplication> oaIt = oaList.iterator(); while (oaIt.hasNext()) { + HTTPMetadataProvider httpProvider = null; + try { OnlineApplication oa = oaIt.next(); Logger.info("Loading metadata for: " + oa.getFriendlyName()); @@ -222,7 +232,7 @@ public class MOAMetadataProvider implements MetadataProvider { if (!providersinuse.containsKey(metadataURL)) { - HTTPMetadataProvider httpProvider = createNewHTTPMetaDataProvider( + httpProvider = createNewHTTPMetaDataProvider( metadataURL, pvp2Config.getCertificate(), oa.getFriendlyName()); @@ -242,6 +252,11 @@ public class MOAMetadataProvider implements MetadataProvider { Logger.error( "Failed to add Metadata (unhandled reason: " + e.getMessage(), e); + + if (httpProvider != null) { + Logger.debug("Destroy failed Metadata provider"); + httpProvider.destroy(); + } } } @@ -260,8 +275,12 @@ public class MOAMetadataProvider implements MetadataProvider { } private HTTPMetadataProvider createNewHTTPMetaDataProvider(String metadataURL, byte[] certificate, String oaName) { - try { - HTTPMetadataProvider httpProvider = new HTTPMetadataProvider(new Timer(), new HttpClient(), + HTTPMetadataProvider httpProvider = null; + Timer timer= null; + + try { + timer = new Timer(); + httpProvider = new HTTPMetadataProvider(timer, new HttpClient(), metadataURL); httpProvider.setParserPool(new BasicParserPool()); httpProvider.setRequireValidMetadata(true); @@ -279,16 +298,23 @@ public class MOAMetadataProvider implements MetadataProvider { return httpProvider; - } catch (MetadataProviderException e) { - Logger.error( - "Failed to add Metadata file for " - + oaName + "[ " - + e.getMessage() + " ]", e); - } catch (CertificateException e) { + } catch (Throwable e) { Logger.error( "Failed to add Metadata file for " + oaName + "[ " + e.getMessage() + " ]", e); + + if (httpProvider != null) { + Logger.debug("Destroy failed Metadata provider"); + httpProvider.destroy(); + } + + if (timer != null) { + Logger.debug("Destroy Timer."); + timer.cancel(); + } + + } return null; diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java index 47136d162..038dcb6cf 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java @@ -20,8 +20,8 @@ public class ConfigurationDBRead { private static Map<String, String> QUERIES = new HashMap<String, String>(); static { - QUERIES.put("getActiveOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix like SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'"); - QUERIES.put("getOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix like SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix))"); + QUERIES.put("getActiveOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'"); + QUERIES.put("getOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix))"); QUERIES.put("getOnlineApplicationWithDBID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id"); QUERIES.put("getAllOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication"); QUERIES.put("getAllActiveOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '1'"); @@ -52,7 +52,12 @@ public class ConfigurationDBRead { Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { - Logger.trace("No entries found."); + Logger.debug("No entries found."); + return null; + } + + if (result.size() > 1) { + Logger.warn("OAIdentifier match to more then one DB-entry!"); return null; } |