From 8588c2111bab7e56fe3a51034321d746e834344a Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Thu, 7 Feb 2013 09:40:18 +0000 Subject: [PATCH] update scope parsing git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/common-encryption@68948 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../encryption/{Encrypter.java => IEncrypter.java} | 6 +++--- .../common/utils/encryption/StringEncrypter.java | 5 +---- .../gcube/common/utils/encryption/SymmetricKey.java | 13 ++++++------- 3 files changed, 10 insertions(+), 14 deletions(-) rename src/main/java/org/gcube/common/utils/encryption/{Encrypter.java => IEncrypter.java} (91%) diff --git a/src/main/java/org/gcube/common/utils/encryption/Encrypter.java b/src/main/java/org/gcube/common/utils/encryption/IEncrypter.java similarity index 91% rename from src/main/java/org/gcube/common/utils/encryption/Encrypter.java rename to src/main/java/org/gcube/common/utils/encryption/IEncrypter.java index 3f95269..4a9357c 100644 --- a/src/main/java/org/gcube/common/utils/encryption/Encrypter.java +++ b/src/main/java/org/gcube/common/utils/encryption/IEncrypter.java @@ -4,11 +4,11 @@ import java.security.Key; /** * - * @author Manuele Simi (CNR) + * @author Roberto Cirillo (CNR) * * @param the type of the object to encrypt/decrypt */ -public interface Encrypter { +public interface IEncrypter { /** * Encrypts with the given key or the default key @@ -30,4 +30,4 @@ public interface Encrypter { public T decrypt(T t, Key ... key) throws Exception; -} +} \ No newline at end of file diff --git a/src/main/java/org/gcube/common/utils/encryption/StringEncrypter.java b/src/main/java/org/gcube/common/utils/encryption/StringEncrypter.java index fc32af9..af82a20 100644 --- a/src/main/java/org/gcube/common/utils/encryption/StringEncrypter.java +++ b/src/main/java/org/gcube/common/utils/encryption/StringEncrypter.java @@ -1,9 +1,6 @@ package org.gcube.common.utils.encryption; import javax.crypto.Cipher; - -//import org.apache.xml.security.utils.Base64; -//import org.apache.axis.encoding.Base64; import java.security.Key; import javax.xml.bind.DatatypeConverter; /** @@ -11,7 +8,7 @@ import javax.xml.bind.DatatypeConverter; * @author Manuele Simi (CNR) * */ -public class StringEncrypter implements Encrypter{ +public class StringEncrypter implements IEncrypter{ private static StringEncrypter singleton; diff --git a/src/main/java/org/gcube/common/utils/encryption/SymmetricKey.java b/src/main/java/org/gcube/common/utils/encryption/SymmetricKey.java index 2c8059b..fe1dee1 100644 --- a/src/main/java/org/gcube/common/utils/encryption/SymmetricKey.java +++ b/src/main/java/org/gcube/common/utils/encryption/SymmetricKey.java @@ -72,8 +72,7 @@ final class SymmetricKey { } protected static String getLocalKey() throws InvalidKeyException{ - // virtual organization - String vo=null; + String scopeReference=null; //file that contains the key String keyFile=null; String scope=ScopeProvider.instance.get(); @@ -82,14 +81,14 @@ final class SymmetricKey { String[] vos=scope.split("/"); // if the scope is a VO or VRE scope if((vos != null) && (vos.length > 2)){ - System.out.println(" 0 "+vos[0]+" 1 "+vos[1]+" 2 "+vos[2]); - vo=vos[2]; - if(vo !=null){ - keyFile=vo+".gcubekey"; - } + scopeReference=vos[2]; + // if the scope is a infrastructure scope + }else if((vos != null) && (vos.length == 2)){ + scopeReference=vos[1]; }else{ throw new InvalidKeyException(" invalid key for scope: "+scope); } + keyFile=scopeReference+".gcubekey"; }else{ throw new InvalidKeyException(" invalid key for scope: "+scope); }