jglobus / JGlobus

jGlobus is a collection of Java client libraries for Globus® Toolkit security, GRAM, and GridFTP.
http://www.globus.org/toolkit/jglobus/
Apache License 2.0
24 stars 44 forks source link

How can I authorize? #167

Open MJ-Youn opened 5 years ago

MJ-Youn commented 5 years ago

Hi, i use jglobus in my pc.

package kr.co.ymtech;

import java.io.IOException;
import java.util.Vector;

import org.globus.ftp.GridFTPClient;
import org.globus.ftp.exception.ClientException;
import org.globus.ftp.exception.ServerException;

public class Main {

    public static String message;

    public static void main(String[] args) {

        try {
            GridFTPClient gridFTPClient = new GridFTPClient("192.168.56.123", 2811);

            Vector<?> vector = gridFTPClient.list();
            System.out.println(vector);
        } catch (ServerException | IOException | ClientException e) {
            e.printStackTrace();
        }
    }

}

Error

org.globus.ftp.exception.ClientException: Server authorization has not been performed. Custom message: Need to perform authorization first (error code 1)
    at org.globus.ftp.Session.compareTransferParams(Session.java:116)
    at org.globus.ftp.GridFTPSession.matches(GridFTPSession.java:106)
    at org.globus.ftp.GridFTPClient.checkTransferParamsGet(GridFTPClient.java:173)
    at org.globus.ftp.FTPClient.performTransfer(FTPClient.java:751)
    at org.globus.ftp.FTPClient.list(FTPClient.java:516)
    at org.globus.ftp.FTPClient.list(FTPClient.java:450)
    at org.globus.ftp.GridFTPClient.list(GridFTPClient.java:123)
    at org.globus.ftp.FTPClient.list(FTPClient.java:419)
    at org.globus.ftp.FTPClient.list(FTPClient.java:394)
    at kr.co.ymtech.Main.main(Main.java:31)

but i fase this error. I think, because, this error have not authorization info. I don't know to run gridftpclient with authorization. please advice.

paulmillar commented 5 years ago

You authenticate using one of the authenticate methods. There are two: one that accepts a GSSCredential argument and uses a default username (:globus-mapping:) while the other accepts the username as an argument.

I suspect that the first version (just the GSSCredential argument) is the one you should use.

The GSSCredential is the X.509 credential that represents the identity you want to use when authenticating. Normally, this is created by the user with the voms-proxy-init, arc-proxy, or similar command and stored as the file /tmp/x509up_u$(id -u).

Alternatively, you could create this proxy credential as part of your application. For normal users that (usually) requires entering in a passphrase (robot certificates, however, don't require this). The proxy credential (normally) requires no such passphrase, so this is usually the preferred way to get a credential.

The ExtendedGSSManager (abstract) class may be used to load the credential as a GSSCredential object. See gridftp/src/main/java/org/globus/ftp/examples/LocalCredentialHelper.java for an example on how to do this.