aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/config/CRLRetriever.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/config/CRLRetriever.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/config/CRLRetriever.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/config/CRLRetriever.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/config/CRLRetriever.java
new file mode 100644
index 0000000..981ea05
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/config/CRLRetriever.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+package at.gv.egovernment.moa.spss.server.iaik.config;
+
+import iaik.logging.TransactionId;
+import iaik.pki.revocation.RevocationSourceTypes;
+import iaik.pki.store.revocation.RevocationInfoRetriever;
+import iaik.pki.store.revocation.RevocationSource;
+import iaik.pki.store.revocation.RevocationStoreException;
+import iaik.pki.ldap.Handler;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.util.Collection;
+import java.util.Date;
+
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * A customized implementation of
+ * {@link iaik.pki.store.revocation.RevocationInfoRetriever}. Will be used
+ * instead of the default implementation
+ * {@link iaik.pki.store.revocation.CRLRetriever} to overcome a classloader
+ * problem in connection with the {@link java.net.URL} class in a Tomcat
+ * deployment environment.
+ *
+ * @author Gregor Karlinger
+ * @version $$
+ */
+public class CRLRetriever implements RevocationInfoRetriever {
+ public void update(RevocationSource source, Collection supplementalRequestData, TransactionId tid)
+ throws RevocationStoreException {
+ if (source == null) {
+ throw new NullPointerException("RevocationSource parameter mustn't be null.");
+ }
+ Logger.info("Downloading crl from " + source.getUri());
+ if (!source.getType().equals(RevocationSourceTypes.CRL)) {
+ throw new RevocationStoreException(source.getType() + " not supported", null, getClass().getName() + ":1");
+ }
+ try {
+ URL crlUrl;
+ try {
+ crlUrl = new URL(source.getUri());
+ } catch (MalformedURLException e) {
+ // Workaround for classloader problem with deployment in Tomcat
+ // 4.1
+ URLStreamHandler handler = new Handler();
+ crlUrl = new URL(null, source.getUri(), handler);
+ }
+
+ InputStream crlInputStream = crlUrl.openStream();
+ source.readFrom(crlInputStream, tid);
+ source.setDownloadTime(new Date());
+ crlInputStream.close();
+ } catch (Exception iox) {
+ Logger.warn("Cannot retrieve crl", iox);
+ throw new RevocationStoreException("Cannot retrieve CRL", iox, getClass().getName() + ":1");
+ }
+ }
+
+ @Override
+ public void setConnectTimeout(int arg0) {
+ // TODO AFITZEK TODO IMPLEMENT THIS METHOD
+ }
+
+ @Override
+ public void setReadTimeout(int arg0) {
+ // TODO AFITZEK TODO IMPLEMENT THIS METHOD
+ }
+}