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:
parent
7e206823de
commit
8588c2111b
|
@ -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
|
||||
*/
|
||||
public interface Encrypter<T> {
|
||||
public interface IEncrypter<T> {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -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<String>{
|
||||
public class StringEncrypter implements IEncrypter<String>{
|
||||
|
||||
private static StringEncrypter singleton;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue