added feature for retrieving a generic credential from a backend that is
not mongodb
This commit is contained in:
parent
a6c9be2eaf
commit
bd082de4f2
|
@ -101,22 +101,11 @@ public class Configuration {
|
||||||
*/
|
*/
|
||||||
public void getConfiguration(){
|
public void getConfiguration(){
|
||||||
String[] newServer=null;
|
String[] newServer=null;
|
||||||
// ISClientConnector isclient=getISClient();
|
|
||||||
String currentScope=ScopeProvider.instance.get();
|
String currentScope=ScopeProvider.instance.get();
|
||||||
logger.debug("Scope found on ScopeProvider instance is "+currentScope);
|
logger.debug("Scope found on ScopeProvider instance is "+currentScope);
|
||||||
|
|
||||||
/*COMMENTED THE FOLLOWING LINES 20181214*/
|
|
||||||
|
|
||||||
if(RRScope == null){
|
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;
|
RRScope=currentScope;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
/*END*/
|
|
||||||
logger.debug("RuntimeResource scope "+RRScope);
|
logger.debug("RuntimeResource scope "+RRScope);
|
||||||
ServiceEndpoint resource=getISClient().getStorageEndpoint(RRScope);
|
ServiceEndpoint resource=getISClient().getStorageEndpoint(RRScope);
|
||||||
if(resource ==null )
|
if(resource ==null )
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.gcube.common.encryption.StringEncrypter;
|
import org.gcube.common.encryption.StringEncrypter;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
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;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -92,17 +93,15 @@ public class ISClientConnector {
|
||||||
server[i] = ap.address();
|
server[i] = ap.address();
|
||||||
// if presents, try to get user and password
|
// if presents, try to get user and password
|
||||||
setUsername(ap.username());
|
setUsername(ap.username());
|
||||||
// set password default value to empty string
|
decryptPwd(ap);
|
||||||
setPassword("");
|
|
||||||
if(getUsername() != null && getUsername().length() > 0){
|
|
||||||
try {
|
|
||||||
setPassword(StringEncrypter.getEncrypter().decrypt(ap.password()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
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"));
|
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) {
|
private ServiceEndpoint getPriorityResource(List<ServiceEndpoint> resources) {
|
||||||
ServiceEndpoint defaultResource=null;
|
ServiceEndpoint defaultResource=null;
|
||||||
logger.info("search RR with priority ");
|
logger.info("search RR with priority ");
|
||||||
|
|
Loading…
Reference in New Issue