From d25d02c801e0d6b58a48031b4336bf12f3da7de9 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 11 Feb 2019 15:28:32 +0000 Subject: [PATCH] Fixed method signature git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/common-encryption@177075 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../java/org/gcube/common/encryption/SymmetricKey.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/common/encryption/SymmetricKey.java b/src/main/java/org/gcube/common/encryption/SymmetricKey.java index b40a127..d9607bc 100644 --- a/src/main/java/org/gcube/common/encryption/SymmetricKey.java +++ b/src/main/java/org/gcube/common/encryption/SymmetricKey.java @@ -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"); } }