aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2014-09-15 13:42:36 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2014-09-15 13:42:36 +0200
commit8074865580b5fa28817b37c9ad2e8c992ebef977 (patch)
tree475cd1ed9bc517dffbf023e7d9c7d16ce2bde8c5 /common
parent234f17d14f9f48655c27d54114df0aa2593cf6d8 (diff)
parent714a8cb32dd5585829dfc1926e56971425a2a692 (diff)
downloadmoa-id-spss-8074865580b5fa28817b37c9ad2e8c992ebef977.tar.gz
moa-id-spss-8074865580b5fa28817b37c9ad2e8c992ebef977.tar.bz2
moa-id-spss-8074865580b5fa28817b37c9ad2e8c992ebef977.zip
Merge branch 'moa-2.1-Snapshot'
Conflicts: id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java pom.xml
Diffstat (limited to 'common')
-rw-r--r--common/pom.xml15
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java36
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/util/Constants.java6
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java27
4 files changed, 60 insertions, 24 deletions
diff --git a/common/pom.xml b/common/pom.xml
index b2f7f652c..70d0dc13c 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -67,12 +67,12 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
- <version>2.3</version>
+ <version>2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.6</version>
+ <version>1.7.7</version>
</dependency>
<!-- <dependency>
<groupId>org.slf4j</groupId>
@@ -82,7 +82,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
- <version>1.7.6</version>
+ <version>1.7.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.7</version>
</dependency>
<!-- <dependency>
<groupId>org.slf4j</groupId>
@@ -92,12 +97,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.7.6</version>
+ <version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
- <version>1.7.6</version>
+ <version>1.7.7</version>
</dependency>
</dependencies>
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java b/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java
index 27f12ab0f..66bf50316 100644
--- a/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java
+++ b/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java
@@ -50,12 +50,12 @@ public class Base64Utils {
* @return byte[] The raw bytes contained in the <code>base64String</code>.
* @throws IOException Failed to read the Base64 data.
*/
- public static byte[] decode(String base64String, boolean ignoreInvalidChars)
+ public static byte[] decode(String base64String, boolean ignoreInvalidChars, String encoding)
throws IOException {
Base64InputStream in =
new Base64InputStream(
- new ByteArrayInputStream(base64String.getBytes("UTF-8")),
+ new ByteArrayInputStream(base64String.getBytes(encoding)),
ignoreInvalidChars);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] bytes = new byte[256];
@@ -64,10 +64,15 @@ public class Base64Utils {
while ((bytesRead = in.read(bytes)) > 0) {
out.write(bytes, 0, bytesRead);
}
-
+ in.close();
+
return out.toByteArray();
}
+ public static byte[] decode(String base64String, boolean ignoreInvalidChars) throws IOException {
+ return decode(base64String, ignoreInvalidChars, "UTF-8");
+ }
+
/**
* Read the bytes encoded in a Base64 encoded <code>String</code> and provide
* them via an <code>InputStream</code>.
@@ -80,11 +85,12 @@ public class Base64Utils {
*/
public static InputStream decodeToStream(
String base64String,
- boolean ignoreInvalidChars) {
+ boolean ignoreInvalidChars,
+ String encoding) {
try {
ByteArrayInputStream bin =
- new ByteArrayInputStream(base64String.getBytes("UTF-8"));
+ new ByteArrayInputStream(base64String.getBytes(encoding));
Base64InputStream in = new Base64InputStream(bin, ignoreInvalidChars);
return in;
@@ -94,6 +100,13 @@ public class Base64Utils {
}
}
+ public static InputStream decodeToStream(
+ String base64String,
+ boolean ignoreInvalidChars) {
+ return decodeToStream(base64String, ignoreInvalidChars, "UTF-8");
+
+ }
+
/**
* Convert a byte array to a Base64 encoded <code>String</code>.
*
@@ -102,9 +115,16 @@ public class Base64Utils {
* @throws IOException Failed to write the bytes as Base64 data.
*/
public static String encode(byte[] bytes) throws IOException {
- return encode(new ByteArrayInputStream(bytes));
+ return encode(new ByteArrayInputStream(bytes), "UTF-8");
}
+ public static String encode(byte[] bytes, String encoding) throws IOException {
+ return encode(new ByteArrayInputStream(bytes), encoding);
+ }
+
+ public static String encode(InputStream inputStream) throws IOException {
+ return encode(inputStream, "UTF-8");
+ }
/**
* Convert the data contained in the given stream to a Base64 encoded
* <code>String</code>.
@@ -114,7 +134,7 @@ public class Base64Utils {
* <code>String</code>.
* @throws IOException Failed to convert the data in the stream.
*/
- public static String encode(InputStream inputStream) throws IOException {
+ public static String encode(InputStream inputStream, String encoding) throws IOException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
Base64OutputStream base64Stream = new Base64OutputStream(byteStream, "\n".getBytes());
byte[] bytes = new byte[256];
@@ -127,7 +147,7 @@ public class Base64Utils {
base64Stream.close();
inputStream.close();
- return byteStream.toString("UTF-8");
+ return byteStream.toString(encoding);
}
}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/Constants.java b/common/src/main/java/at/gv/egovernment/moa/util/Constants.java
index ed75768ba..8d71f2e84 100644
--- a/common/src/main/java/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/main/java/at/gv/egovernment/moa/util/Constants.java
@@ -346,7 +346,7 @@ public interface Constants {
/** Local location of the TSL schema definition. */
public static final String TSL_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ts_102231v030102_xsd.xsd";
+ SCHEMA_ROOT + "ts_119612v010201_xsd.xsd";
/** URI of the TSL SIE namespace. */
public static final String TSL_SIE_NS_URI =
@@ -357,7 +357,7 @@ public interface Constants {
/** Local location of the TSL SIE schema definition. */
public static final String TSL_SIE_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ts_102231v030102_sie_xsd.xsd";
+ SCHEMA_ROOT + "ts_119612v010201_sie_xsd.xsd";
/** URI of the TSL additional types namespace. */
public static final String TSL_ADDTYPES_NS_URI =
@@ -368,7 +368,7 @@ public interface Constants {
/** Local location of the TSL additional types schema definition. */
public static final String TSL_ADDTYPES_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ts_102231v030102_additionaltypes_xsd.xsd";
+ SCHEMA_ROOT + "ts_ts_119612v010201_additionaltypes_xsd.xsd";
/** URI of the XML Encryption namespace. */
public static final String XENC_NS_URI =
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java
index 9db3ca6e3..3d28f4f2b 100644
--- a/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java
+++ b/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java
@@ -36,9 +36,7 @@ import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
/**
* Utility for creating and loading key stores.
@@ -187,16 +185,29 @@ public class KeyStoreUtils {
//InputStream is = new FileInputStream(keyStorePath);
URL keystoreURL = new URL(keyStorePath);
InputStream in = keystoreURL.openStream();
- InputStream isBuffered = new BufferedInputStream(in);
+ InputStream isBuffered = new BufferedInputStream(in);
+ return loadKeyStore(isBuffered, password);
- isBuffered.mark(1024*1024);
+ }
+
+ /**
+ * Loads a keyStore without knowing the keyStore type
+ * @param in input stream
+ * @param password Password protecting the keyStore
+ * @return keyStore loaded
+ * @throws KeyStoreException thrown if keyStore cannot be loaded
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+public static KeyStore loadKeyStore(InputStream is, String password) throws KeyStoreException, IOException{
+ is.mark(1024*1024);
KeyStore ks = null;
try {
try {
- ks = loadKeyStore(KEYSTORE_TYPE_PKCS12, isBuffered, password);
+ ks = loadKeyStore(KEYSTORE_TYPE_PKCS12, is, password);
} catch (IOException e2) {
- isBuffered.reset();
- ks = loadKeyStore(KEYSTORE_TYPE_JKS, isBuffered, password);
+ is.reset();
+ ks = loadKeyStore(KEYSTORE_TYPE_JKS, is, password);
}
} catch(Exception e) {
e.printStackTrace();
@@ -205,7 +216,7 @@ public class KeyStoreUtils {
return ks;
}
-
+