Fixed method signature
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/common-encryption@177075 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
23448e6aca
commit
d25d02c801
|
@ -1,6 +1,8 @@
|
|||
package org.gcube.common.encryption;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.InvalidKeyException;
|
||||
|
@ -45,13 +47,13 @@ public final class SymmetricKey {
|
|||
return keyContextMap.get(ScopeProvider.instance.get());
|
||||
}
|
||||
|
||||
public static Key loadKeyFromFile(String keyFileName, String keyAlgorithm) throws InvalidKeyException {
|
||||
try(InputStream is = SymmetricKey.class.getResourceAsStream("/" + keyFileName)) {
|
||||
public static Key loadKeyFromFile(File keyFile, String keyAlgorithm) throws InvalidKeyException {
|
||||
try(InputStream is = new FileInputStream(keyFile)) {
|
||||
byte[] rawKey = getBytesFromStream(is);
|
||||
Key key = new SecretKeySpec(rawKey, 0, rawKey.length, keyAlgorithm);
|
||||
return key;
|
||||
} catch(Exception e) {
|
||||
throw new InvalidKeyException("Unable to load the Key " + keyFileName + " from the classpath");
|
||||
throw new InvalidKeyException("Unable to load the Key " + keyFile.getAbsolutePath() + " from the classpath");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue