Search in sources :

Example 1 with VRSContext

use of nl.uva.vlet.vrs.VRSContext in project lobcder by skoulouzis.

the class VPDRI method initVFS.

private void initVFS() throws Exception {
    this.vfsClient = new VFSClient();
    VRSContext context = this.getVfsClient().getVRSContext();
    context.setProperty(GlobalConfig.TCP_CONNECTION_TIMEOUT, "20000");
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(vrl, true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        GridHelper.initGridProxy(username, password, context, destroyCert);
        context.setProperty(GlobalConfig.PROP_PASSIVE_MODE, false);
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    // if(getVrl().getScheme().equals(VRS.SFTP_SCHEME)){
    // patch for bug with ssh driver
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    // }
    context.setProperty("chunk.upload", doChunked);
    // info.setAttribute(new VAttribute("chunk.upload", true));
    info.store();
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) ServerInfo(nl.uva.vlet.vrs.ServerInfo)

Example 2 with VRSContext

use of nl.uva.vlet.vrs.VRSContext in project lobcder by skoulouzis.

the class RegisterSRMSites method initVFS.

private static void initVFS() throws VlException, MalformedURLException, NamingException, Exception {
    vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    BdiiService bdii = context.getBdiiService();
    srms = bdii.getSRMv22SAsforVO("biomed");
    // 
    debug("srms: " + context.getConfigManager().getBdiiHost());
    for (StorageArea inf : srms) {
        debug("srms: " + inf.getVOStorageLocation());
    }
    JDBCatalogue cat = new JDBCatalogue();
    String resourceURI = "";
    Credential credentials = new Credential();
// cat.registerStorageSite(resourceURI, credentials, -1, -1, -1, -1, null);
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VFSClient(nl.uva.vlet.vfs.VFSClient) Credential(nl.uva.cs.lobcder.resources.Credential) JDBCatalogue(nl.uva.cs.lobcder.catalogue.JDBCatalogue) StorageArea(nl.uva.vlet.util.bdii.StorageArea) BdiiService(nl.uva.vlet.util.bdii.BdiiService)

Example 3 with VRSContext

use of nl.uva.vlet.vrs.VRSContext in project lobcder by skoulouzis.

the class GetTask method getVFSClient.

private VFSClient getVFSClient(String vrl, String username, String password) throws VlException {
    VFSClient vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(new VRL(vrl), true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        // Use the username and password to get access to MyProxy
        GridProxy proxy = new GridProxy(context);
        String pr = context.getProxyAsString();
        context.setGridProxy(proxy);
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    info.store();
    return vfsClient;
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) ServerInfo(nl.uva.vlet.vrs.ServerInfo) GridProxy(nl.uva.vlet.util.cog.GridProxy)

Example 4 with VRSContext

use of nl.uva.vlet.vrs.VRSContext in project lobcder by skoulouzis.

the class TestWebWAVFS method getVFSClient.

private VFSClient getVFSClient(String vrl, String username, String password) throws VlException {
    VFSClient vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(new VRL(vrl), true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        // copyVomsAndCerts();
        GridProxy gridProxy = null;
        if (gridProxy == null) {
            // context.setProperty("grid.proxy.location", Constants.PROXY_FILE);
            // Default to $HOME/.globus
            context.setProperty("grid.certificate.location", Global.getUserHome() + "/.globus");
            String vo = username;
            context.setProperty("grid.proxy.voName", vo);
            context.setProperty("grid.proxy.lifetime", "200");
            // gridProxy = GridProxy.loadFrom(context, proxyFile);
            gridProxy = context.getGridProxy();
            if (gridProxy.isValid() == false) {
                gridProxy.setEnableVOMS(true);
                gridProxy.setDefaultVOName(vo);
                gridProxy.createWithPassword(password);
                if (gridProxy.isValid() == false) {
                    throw new VlException("Created Proxy is not Valid!");
                }
            // gridProxy.saveProxyTo(Constants.PROXY_FILE);
            }
        }
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    // if(getVrl().getScheme().equals(VRS.SFTP_SCHEME)){
    // patch for bug with ssh driver
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    // }
    // context.setProperty("chunk.upload", doChunked);
    // info.setAttribute(new VAttribute("chunk.upload", true));
    info.store();
    return vfsClient;
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) ServerInfo(nl.uva.vlet.vrs.ServerInfo) GridProxy(nl.uva.vlet.util.cog.GridProxy) VlException(nl.uva.vlet.exception.VlException)

Example 5 with VRSContext

use of nl.uva.vlet.vrs.VRSContext in project lobcder by skoulouzis.

the class WebDAVTest method getVFSClient.

private VFSClient getVFSClient(String vrl, String username, String password) throws VlException {
    VFSClient vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(new VRL(vrl), true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        // Use the username and password to get access to MyProxy
        GridProxy proxy = new GridProxy(context);
        String pr = context.getProxyAsString();
        context.setGridProxy(proxy);
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    // if(getVrl().getScheme().equals(VRS.SFTP_SCHEME)){
    // patch for bug with ssh driver
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    // }
    info.store();
    return vfsClient;
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) ServerInfo(nl.uva.vlet.vrs.ServerInfo) GridProxy(nl.uva.vlet.util.cog.GridProxy)

Aggregations

VRSContext (nl.uva.vlet.vrs.VRSContext)6 VFSClient (nl.uva.vlet.vfs.VFSClient)5 ServerInfo (nl.uva.vlet.vrs.ServerInfo)5 GridProxy (nl.uva.vlet.util.cog.GridProxy)3 VRL (nl.uva.vlet.vrl.VRL)3 JDBCatalogue (nl.uva.cs.lobcder.catalogue.JDBCatalogue)1 Credential (nl.uva.cs.lobcder.resources.Credential)1 VlException (nl.uva.vlet.exception.VlException)1 BdiiService (nl.uva.vlet.util.bdii.BdiiService)1 StorageArea (nl.uva.vlet.util.bdii.StorageArea)1