added feature for retrieving a generic credential from a backend that is

not mongodb
This commit is contained in:
roberto cirillo 2020-11-19 15:12:56 +01:00
parent a6c9be2eaf
commit bd082de4f2
2 changed files with 22 additions and 21 deletions

View File

@ -101,22 +101,11 @@ public class Configuration {
*/
public void getConfiguration(){
String[] newServer=null;
// ISClientConnector isclient=getISClient();
String currentScope=ScopeProvider.instance.get();
logger.debug("Scope found on ScopeProvider instance is "+currentScope);
/*COMMENTED THE FOLLOWING LINES 20181214*/
if(RRScope == null){
// if(new ScopeBean(currentScope).is(Type.VRE)){
// logger.debug("If ScopeProvider scope is VRE scope RR scope became VO scope");
// RRScope=new ScopeBean(currentScope).enclosingScope().toString();
// }else{
// logger.debug("If ScopeProvider scope is not a VRE scope RR scope is ScopeProvider scope");
RRScope=currentScope;
// }
}
/*END*/
logger.debug("RuntimeResource scope "+RRScope);
ServiceEndpoint resource=getISClient().getStorageEndpoint(RRScope);
if(resource ==null )

View File

@ -10,6 +10,7 @@ import java.util.List;
import java.util.Map;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
import org.gcube.common.scope.api.ScopeProvider;
@ -92,17 +93,15 @@ public class ISClientConnector {
server[i] = ap.address();
// if presents, try to get user and password
setUsername(ap.username());
// set password default value to empty string
setPassword("");
if(getUsername() != null && getUsername().length() > 0){
try {
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
decryptPwd(ap);
i++;
}else if((!getBackendType().equals(BackendType.MongoDB) && (ap.name().equals(getBackendType())))){
// in this case, the backend type has been set in the constructor hence we want to use this one
// if presents, try to get user and password
setUsername(ap.username());
decryptPwd(ap);
//in v1.6.0 we are considering only one accessPoint for a backend except for mongodb.
break;
}
}
setBackendType(retrievePropertyValue(resource, "type"));
@ -117,6 +116,19 @@ public class ISClientConnector {
}
}
private void decryptPwd(AccessPoint ap) {
// set password default value to empty string
setPassword("");
if(getUsername() != null && getUsername().length() > 0){
try {
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private ServiceEndpoint getPriorityResource(List<ServiceEndpoint> resources) {
ServiceEndpoint defaultResource=null;
logger.info("search RR with priority ");