From 2f4f5750cf0d3fc83793a31017daee331410015a Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 11 Aug 2014 15:31:57 +0200 Subject: Update iaik-TSL library (ETSI TS119612 V1.2.1) * change Version to 2.0.2 --- common/src/main/java/at/gv/egovernment/moa/util/Constants.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common') 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 = -- cgit v1.2.3 From 1ab0f1d4d991464b906c34befefe2ecaf485d485 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 19 Aug 2014 15:03:42 +0200 Subject: add interfederation without attributequery request which use encrypted bPKs (this functionality is required for federation with USP) --- .../at/gv/egovernment/moa/util/Base64Utils.java | 36 +++++++++++++++++----- .../at/gv/egovernment/moa/util/KeyStoreUtils.java | 27 +++++++++++----- 2 files changed, 47 insertions(+), 16 deletions(-) (limited to 'common') 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 base64String. * @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 String and provide * them via an InputStream. @@ -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 String. * @@ -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 * String. @@ -114,7 +134,7 @@ public class Base64Utils { * String. * @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/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; } - + -- cgit v1.2.3 From 6f5319b465eb857e13ee562ccfd9a94f1e681501 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 12 Sep 2014 12:27:49 +0200 Subject: update dependency version > org.apache.struts:struts2-core 2.3.16.3 > org.apache.struts:struts2-json-plugin 2.3.16.3 > joda-time:joda-time 2.4 > org.slf4j:jcl-over-slf4j 1.7.7 > org.slf4j:jul-to-slf4j 1.7.7 > org.slf4j:slf4j-api 1.7.7 > org.slf4j:slf4j-log4j12 1.7.7 > mysql:mysql-connector-java 5.1.32 > org.hibernate:hibernate-core 4.3.6.Final > org.hibernate:hibernate-entitymanager 4.3.6.Final > org.hibernate:hibernate-c3p0 4.3.6.Final > com.google.http-client:google-http-client-jackson2 1.19.0 > com.google.oauth-client:google-oauth-client-jetty 1.19.0 > org.apache.commons:commons-lang3 3.3.2 > commons-codec:commons-codec 1.9 > commons-logging:commons-logging 1.2 > xerces:xercesImpl 2.11.0 > postgresql:postgresql 9.3-1102-jdbc41 > junit:junit 3.8.2 --- common/pom.xml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'common') 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 @@ joda-time joda-time - 2.3 + 2.4 org.slf4j slf4j-api - 1.7.6 + 1.7.7