aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java83
1 files changed, 40 insertions, 43 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
index 933d058..5668a36 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/ExternalURIResolver.java
@@ -21,12 +21,8 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.invoke;
-import iaik.xml.crypto.utils.URI;
-import iaik.xml.crypto.utils.URIException;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -38,10 +34,12 @@ import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.server.transaction.TransactionContext;
import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager;
import at.gv.egovernment.moa.spss.util.ExternalURIVerifier;
+import iaik.xml.crypto.utils.URI;
+import iaik.xml.crypto.utils.URIException;
/**
* Resolve external URIs and provide them as a stream.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -52,14 +50,15 @@ public class ExternalURIResolver {
/**
* 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.
- *
+ *
+ * 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).
+ * the URI is syntactically incorrect or the
+ * stream could not be opened).
*/
public InputStream resolve(String uriStr) throws MOAApplicationException {
URI uri;
@@ -70,7 +69,7 @@ public class ExternalURIResolver {
// build the URI
try {
uri = new URI(uriStr);
- } catch (URIException e) {
+ } catch (final URIException e) {
throw new MOAApplicationException("2207", new Object[] { uriStr });
}
@@ -81,30 +80,30 @@ public class ExternalURIResolver {
// if we have local content (SOAP with attachments)
if ("formdata".equals(uri.getScheme())) {
- TransactionContext context = TransactionContextManager.getInstance().getTransactionContext();
- if (context==null) {
- //no transaction
+ final TransactionContext context = TransactionContextManager.getInstance().getTransactionContext();
+ if (context == null) {
+ // no transaction
throw new MOAApplicationException("2282", new Object[] { uri });
} else {
- InputStream attachmentIs = context.getAttachmentInputStream(uri);
+ final InputStream attachmentIs = context.getAttachmentInputStream(uri);
if (attachmentIs != null) {
setContentType(context.getAttachmentContentType(uri.getPath()));
return attachmentIs;
} else {
- //maybe attachments provided but no suiting attachment found
+ // maybe attachments provided but no suiting attachment found
throw new MOAApplicationException("2282", new Object[] { uri });
}
- }
- }
-
+ }
+ }
+
// convert URI to URL
try {
// create the URL
url = new URL(uriStr);
- //System.out.println("ExternalURIResolver: " + url);
+ // System.out.println("ExternalURIResolver: " + url);
ExternalURIVerifier.verify(url.getHost(), url.getPort());
-
- } catch (MalformedURLException e) {
+
+ } catch (final MalformedURLException e) {
throw new MOAApplicationException("2214", new Object[] { uriStr });
}
@@ -112,7 +111,7 @@ public class ExternalURIResolver {
try {
connection = url.openConnection();
if ("http".equals(url.getProtocol())) {
- HttpURLConnection httpConnection = (HttpURLConnection) connection;
+ final HttpURLConnection httpConnection = (HttpURLConnection) connection;
// disallow redirects
httpConnection.setInstanceFollowRedirects(false);
@@ -121,33 +120,31 @@ public class ExternalURIResolver {
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
+ /*
+ * 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 });
- }
- */
+ * 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) {
+ } catch (final IOException e) {
throw new MOAApplicationException("2208", new Object[] { uri }, e);
- } /*catch (GeneralSecurityException 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());
@@ -157,7 +154,7 @@ public class ExternalURIResolver {
/**
* Set the content type of the data at the URI.
- *
+ *
* @param contentType The content type to set.
*/
protected void setContentType(String contentType) {
@@ -167,7 +164,7 @@ public class ExternalURIResolver {
/**
* 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() {