agave-systems/systems-core/src/main/java/org/iplantc/service/transfer/gridftp/GridFTP.java
/**
	 * Performs authentication with user credentials from the RemoteSystem.
	 * 
	 * @throws IOException
	 *             on i/o error
	 * @throws RemoteDataException
	 *             on server refusal or faulty server behavior
	 */
Performs authentication with user credentials from the RemoteSystem.

@throws IOException
on i/o error
@throws RemoteDataException
on server refusal or faulty server behavior
Performs authentication with user credentials from the RemoteSystem . @throws IOException on i / o error @throws RemoteDataException on server refusal or faulty server behavior
public void authenticate() throws IOException, RemoteDataException
	{	
		if (gSession == null || !gSession.authorized)
		{
			try
			{
				synchronized(this) {
					System.setProperty("jsse.enableCBCProtection", "false");
				}
				if (credential instanceof AgaveGSSCredentialImpl) {
					AgaveGSSCredentialImpl c = (AgaveGSSCredentialImpl) credential;
					this.trustedCAPath = ((AgaveX509Credential)c.getX509Credential()).getTrustedCALocation().getCaPath();
				}
				gSession = new GridFTPSession();
		        session = gSession;
		        session.maxWait = 30000;
		        controlChannel = new GridFTPControlChannel(host, port);
		        controlChannel.open();
		        gLocalServer = new GridFTPServerFacade((GridFTPControlChannel)controlChannel) {
		            /**
	                 * Start the local server
	                 * @param port required server port; can be set to ANY_PORT
	                 * @param queue max size of queue of awaiting new connection requests 
	                 * @return the server address
	                 **/
	                @Override
	                public HostPort setPassive(int port, int queue) throws IOException 
	                {
	                    socketPool.flush();
	                    if (serverSocket == null) {
	                        ServerSocketFactory factory = ServerSocketFactory.getDefault();
	                        serverSocket = factory.createServerSocket(port, queue);
	                        serverSocket.setSoTimeout(10000);
    	                 }
    	                 session.serverMode = Session.SERVER_PASSIVE;
    	                 String address = org.iplantc.service.common.Settings.getIpLocalAddress();
    	                 int localPort = serverSocket.getLocalPort();
    	                 if (remoteControlChannel.isIPv6()) {
    	                     String version = HostPort6.getIPAddressVersion(address);
    	                     session.serverAddress = new HostPort6(version, address, localPort);
    	                 } else {
    	                     session.serverAddress = new HostPort(address, localPort);
    	                 }
    	                 log.debug("started passive server at port " +
    	                              session.serverAddress.getPort());
    	                 return session.serverAddress;
	                }
	                public HostPortList setStripedPassive(int port, int queue) throws IOException 
	                {
                        socketPool.flush();
                        if (serverSocket == null) {
                            ServerSocketFactory factory =
                                ServerSocketFactory.getDefault();
                            serverSocket = factory.createServerSocket(port, queue);
                        }
                        gSession.serverMode = GridFTPSession.SERVER_EPAS;
                        gSession.serverAddressList = new HostPortList();
                        String address = org.iplantc.service.common.Settings.getIpLocalAddress();
                        int localPort = serverSocket.getLocalPort();
                        HostPort hp = null;
                        if (remoteControlChannel.isIPv6()) {
                            String version = HostPort6.getIPAddressVersion(address);
                            hp = new HostPort6(version, address, localPort);
                        } else {
                            hp = new HostPort(address, localPort);
                        }
                        gSession.serverAddressList.add(hp);
                        log.debug("started single striped passive server at port " +
                                     gSession.serverAddressList.get(0).getPort());
                        return gSession.serverAddressList;
                    }
	                public void setTCPBufferSize(final int size) throws ClientException {
	                    log.debug("Changing local TCP buffer setting to " + size);
	                    gSession.TCPBufferSize = size;
	                    SocketOperator op = new SocketOperator() {
	                            public void operate(SocketBox s) throws Exception {
	                                synchronized (s) {
	                                    log.debug(
	                                                 "Changing local socket's TCP buffer to " + size);
	                                    Socket mySocket = s.getSocket();
	                                    if (mySocket != null) {
	                                        mySocket.setReceiveBufferSize(size);
	                                        mySocket.setSendBufferSize(size);
	                                        mySocket.setSoLinger(true, 5000);
	                                        mySocket.setReuseAddress(true);
	                                    } else {
	                                        log.debug(
	                                                     "the socket is null. probably being initialized");
	                                    }
	                                }
	                            }
	                    };
	                    try {
	                        socketPool.applyToAll(op);
	                    } catch (Exception e) {
	                        ClientException ce =
	                            new ClientException(ClientException.SOCKET_OP_FAILED);
	                        ce.setRootCause(e);
	                        throw ce;
	                    }
	                }
	            };
		        localServer = gLocalServer;
		        gLocalServer.setTCPBufferSize(Session.SERVER_DEFAULT);
		        gLocalServer.authorize();
		        this.useAllo = true;
		        ((GridFTPControlChannel)controlChannel).authenticate(credential);
		        gLocalServer.setCredential(credential);
				gSession.authorized = true;
				setOptions(new RetrieveOptions(parallelism));				
			}
			catch (Exception e)
			{
				throw new RemoteDataException(
						"Failed to authenticated to gridftp server " + host, e);
			}
		}
	}
public void authenticate ( ) throws IOException , RemoteDataException { if ( gSession == null || ! gSession . authorized ) { try { synchronized ( this ) { System . setProperty ( "jsse.enableCBCProtection" , "false" ) ; } if ( credential instanceof AgaveGSSCredentialImpl ) { AgaveGSSCredentialImpl c = ( AgaveGSSCredentialImpl ) credential ; this . trustedCAPath = ( ( AgaveX509Credential ) c . getX509Credential ( ) ) . getTrustedCALocation ( ) . getCaPath ( ) ; } gSession = new GridFTPSession ( ) ; session = gSession ; session . maxWait = 30000 ; controlChannel = new GridFTPControlChannel ( host , port ) ; controlChannel . open ( ) ; gLocalServer = new GridFTPServerFacade ( ( GridFTPControlChannel ) controlChannel ) { /**
	                 * Start the local server
	                 * @param port required server port; can be set to ANY_PORT
	                 * @param queue max size of queue of awaiting new connection requests 
	                 * @return the server address
	                 **/ @ Override public HostPort setPassive ( int port , int queue ) throws IOException { socketPool . flush ( ) ; if ( serverSocket == null ) { ServerSocketFactory factory = ServerSocketFactory . getDefault ( ) ; serverSocket = factory . createServerSocket ( port , queue ) ; serverSocket . setSoTimeout ( 10000 ) ; } session . serverMode = Session . SERVER_PASSIVE ; String address = org . iplantc . service . common . Settings . getIpLocalAddress ( ) ; int localPort = serverSocket . getLocalPort ( ) ; if ( remoteControlChannel . isIPv6 ( ) ) { String version = HostPort6 . getIPAddressVersion ( address ) ; session . serverAddress = new HostPort6 ( version , address , localPort ) ; } else { session . serverAddress = new HostPort ( address , localPort ) ; } log . debug ( "started passive server at port " + session . serverAddress . getPort ( ) ) ; return session . serverAddress ; } public HostPortList setStripedPassive ( int port , int queue ) throws IOException { socketPool . flush ( ) ; if ( serverSocket == null ) { ServerSocketFactory factory = ServerSocketFactory . getDefault ( ) ; serverSocket = factory . createServerSocket ( port , queue ) ; } gSession . serverMode = GridFTPSession . SERVER_EPAS ; gSession . serverAddressList = new HostPortList ( ) ; String address = org . iplantc . service . common . Settings . getIpLocalAddress ( ) ; int localPort = serverSocket . getLocalPort ( ) ; HostPort hp = null ; if ( remoteControlChannel . isIPv6 ( ) ) { String version = HostPort6 . getIPAddressVersion ( address ) ; hp = new HostPort6 ( version , address , localPort ) ; } else { hp = new HostPort ( address , localPort ) ; } gSession . serverAddressList . add ( hp ) ; log . debug ( "started single striped passive server at port " + gSession . serverAddressList . get ( 0 ) . getPort ( ) ) ; return gSession . serverAddressList ; } public void setTCPBufferSize ( final int size ) throws ClientException { log . debug ( "Changing local TCP buffer setting to " + size ) ; gSession . TCPBufferSize = size ; SocketOperator op = new SocketOperator ( ) { public void operate ( SocketBox s ) throws Exception { synchronized ( s ) { log . debug ( "Changing local socket's TCP buffer to " + size ) ; Socket mySocket = s . getSocket ( ) ; if ( mySocket != null ) { mySocket . setReceiveBufferSize ( size ) ; mySocket . setSendBufferSize ( size ) ; mySocket . setSoLinger ( true , 5000 ) ; mySocket . setReuseAddress ( true ) ; } else { log . debug ( "the socket is null. probably being initialized" ) ; } } } } ; try { socketPool . applyToAll ( op ) ; } catch ( Exception e ) { ClientException ce = new ClientException ( ClientException . SOCKET_OP_FAILED ) ; ce . setRootCause ( e ) ; throw ce ; } } } ; localServer = gLocalServer ; gLocalServer . setTCPBufferSize ( Session . SERVER_DEFAULT ) ; gLocalServer . authorize ( ) ; this . useAllo = true ; ( ( GridFTPControlChannel ) controlChannel ) . authenticate ( credential ) ; gLocalServer . setCredential ( credential ) ; gSession . authorized = true ; setOptions ( new RetrieveOptions ( parallelism ) ) ; } catch ( Exception e ) { throw new RemoteDataException ( "Failed to authenticated to gridftp server " + host , e ) ; } } }
Performs authentication with user credentials from the RemoteSystem.
Performs authentication with user credentials from the RemoteSystem .
//					System.setProperty("org.globus.gsi.gssapi.provider",  //							"org.iplantc.service.common.auth.AgaveGSSManagerImpl"); //				CoGProperties cogProperties = new CoGProperties(); //				File cogFile = new File(System.getProperty("user.home") +"/.globus/cog.properties"); //				if (cogFile.exists()) { //					cogProperties.load(cogFile.getAbsolutePath()); //				}  //				CoGProperties.setDefault(cogProperties); // remove existing sockets, if any // remove existing sockets, if any // synchronize to prevent race condition against // the socket initialization code that also sets // TCP buffer (GridFTPActiveConnectTask)