aboutsummaryrefslogtreecommitdiff
path: root/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
diff options
context:
space:
mode:
author(no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-01-28 14:10:50 +0000
committer(no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-01-28 14:10:50 +0000
commit7916c117627db0411b35f202f88b2ab6e115361a (patch)
tree64d196008935d0c2913958edca0c4a8da62eec2f /spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
parentd9183e34404ab3431c94002b963985a4346cf60a (diff)
downloadmoa-id-spss-tags/MOA-ID-1_20d09.tar.gz
moa-id-spss-tags/MOA-ID-1_20d09.tar.bz2
moa-id-spss-tags/MOA-ID-1_20d09.zip
This commit was manufactured by cvs2svn to create tagtags/MOA-ID-1_20d09
'MOA-ID-1_20d09'. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/MOA-ID-1_20d09@264 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java')
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java127
1 files changed, 0 insertions, 127 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
deleted file mode 100644
index 806b76409..000000000
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package at.gv.egovernment.moa.spss.server.invoke;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import iaik.ixsil.exceptions.URIException;
-import iaik.ixsil.util.URI;
-
-import at.gv.egovernment.moa.spss.MOAApplicationException;
-
-/**
- * Resolve external URIs and provide them as a stream.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class ExternalURIResolver {
-
- /** The MIME type of the content currently resolved. */
- private String contentType;
-
- /**
- * Return a stream to data at the given URI.
- *
- * This method will try to open an <code>URLConnection</code> to the given
- * URI. Access to the file system is disallowed.
- *
- * @param uriStr The URI to resolve.
- * @return InputStream The data contained at the URI.
- * @throws MOAApplicationException An error occurred resolving the URI (e.g.,
- * the URI is syntactically incorrect or the stream could not be opened).
- */
- public InputStream resolve(String uriStr) throws MOAApplicationException {
- URI uri;
- URL url;
- URLConnection connection;
- InputStream is;
-
- // build the URI
- try {
- uri = new URI(uriStr);
- } catch (URIException e) {
- throw new MOAApplicationException("2207", new Object[] { uriStr });
- }
-
- // disallow access to local file system
- if ("".equals(uri.getScheme()) || "file".equals(uri.getScheme())) {
- throw new MOAApplicationException("2213", new Object[] { uriStr });
- }
-
- // convert URI to URL
- try {
- // create the URL
- url = new URL(uriStr);
- } catch (MalformedURLException e) {
- throw new MOAApplicationException("2214", new Object[] { uriStr });
- }
-
- // build the URLConnection
- try {
- connection = url.openConnection();
- if ("http".equals(url.getProtocol())) {
- HttpURLConnection httpConnection = (HttpURLConnection) connection;
-
- httpConnection.connect();
- if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_OK) {
- throw new MOAApplicationException("2208", new Object[] { uri });
- }
- } else if ("https".equals(url.getProtocol())) {
- /*
- * this doesn't work because of some interaction between the IAIK
- * JCE and Sun JSSE that results in an "Invalid AVA format" exception
- */
-
- /*
- HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
- InputStream trustStore =
- getClass().getResourceAsStream(DEFAULT_TRUST_STORE);
- SSLSocketFactory factory =
- SSLUtils.getSSLSocketFactory("jks", trustStore, "changeit");
- httpsConnection.setSSLSocketFactory(factory);
- httpsConnection.connect();
- if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_OK) {
- throw new MOAApplicationException("2208", new Object[] { uri });
- }
- */
- connection.connect();
- } else {
- connection.connect();
- }
- is = connection.getInputStream();
- } catch (IOException e) {
- throw new MOAApplicationException("2208", new Object[] { uri }, e);
- } /*catch (GeneralSecurityException e) {
- throw new MOAApplicationException("2208", new Object[] { uri }, e);
- }*/
-
- // set the content type
- setContentType(connection.getContentType());
-
- return is;
- }
-
- /**
- * Set the content type of the data at the URI.
- *
- * @param contentType The content type to set.
- */
- protected void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- /**
- * Return the content type of the data detected at the URI from the previous
- * call of <code>resolve()</code>.
- *
- * @return String The content type.
- */
- public String getContentType() {
- return contentType;
- }
-
-}