update scope parsing

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/common-encryption@68948 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Roberto Cirillo 2013-02-07 09:40:18 +00:00
parent 7e206823de
commit 8588c2111b
3 changed files with 10 additions and 14 deletions

View File

@ -4,11 +4,11 @@ import java.security.Key;
/** /**
* *
* @author Manuele Simi (CNR) * @author Roberto Cirillo (CNR)
* *
* @param <T> the type of the object to encrypt/decrypt * @param <T> the type of the object to encrypt/decrypt
*/ */
public interface Encrypter<T> { public interface IEncrypter<T> {
/** /**
* Encrypts <T> with the given key or the default key * Encrypts <T> with the given key or the default key
@ -30,4 +30,4 @@ public interface Encrypter<T> {
public T decrypt(T t, Key ... key) throws Exception; public T decrypt(T t, Key ... key) throws Exception;
} }

View File

@ -1,9 +1,6 @@
package org.gcube.common.utils.encryption; package org.gcube.common.utils.encryption;
import javax.crypto.Cipher; import javax.crypto.Cipher;
//import org.apache.xml.security.utils.Base64;
//import org.apache.axis.encoding.Base64;
import java.security.Key; import java.security.Key;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
/** /**
@ -11,7 +8,7 @@ import javax.xml.bind.DatatypeConverter;
* @author Manuele Simi (CNR) * @author Manuele Simi (CNR)
* *
*/ */
public class StringEncrypter implements Encrypter<String>{ public class StringEncrypter implements IEncrypter<String>{
private static StringEncrypter singleton; private static StringEncrypter singleton;

View File

@ -72,8 +72,7 @@ final class SymmetricKey {
} }
protected static String getLocalKey() throws InvalidKeyException{ protected static String getLocalKey() throws InvalidKeyException{
// virtual organization String scopeReference=null;
String vo=null;
//file that contains the key //file that contains the key
String keyFile=null; String keyFile=null;
String scope=ScopeProvider.instance.get(); String scope=ScopeProvider.instance.get();
@ -82,14 +81,14 @@ final class SymmetricKey {
String[] vos=scope.split("/"); String[] vos=scope.split("/");
// if the scope is a VO or VRE scope // if the scope is a VO or VRE scope
if((vos != null) && (vos.length > 2)){ if((vos != null) && (vos.length > 2)){
System.out.println(" 0 "+vos[0]+" 1 "+vos[1]+" 2 "+vos[2]); scopeReference=vos[2];
vo=vos[2]; // if the scope is a infrastructure scope
if(vo !=null){ }else if((vos != null) && (vos.length == 2)){
keyFile=vo+".gcubekey"; scopeReference=vos[1];
}
}else{ }else{
throw new InvalidKeyException(" invalid key for scope: "+scope); throw new InvalidKeyException(" invalid key for scope: "+scope);
} }
keyFile=scopeReference+".gcubekey";
}else{ }else{
throw new InvalidKeyException(" invalid key for scope: "+scope); throw new InvalidKeyException(" invalid key for scope: "+scope);
} }