diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-08-19 15:03:42 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-08-19 15:03:42 +0200 |
commit | 1ab0f1d4d991464b906c34befefe2ecaf485d485 (patch) | |
tree | e84f4deb090dda11b5fb318019b6e0bce9efc86c /common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java | |
parent | 296ebbfb36ef207abe4611cb8d3727d2f86a692b (diff) | |
download | moa-id-spss-1ab0f1d4d991464b906c34befefe2ecaf485d485.tar.gz moa-id-spss-1ab0f1d4d991464b906c34befefe2ecaf485d485.tar.bz2 moa-id-spss-1ab0f1d4d991464b906c34befefe2ecaf485d485.zip |
add interfederation without attributequery request which use encrypted bPKs
(this functionality is required for federation with USP)
Diffstat (limited to 'common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java')
-rw-r--r-- | common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java | 27 |
1 files changed, 19 insertions, 8 deletions
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; } - + |