Exemplo n.º 1
0
  /**
   * Sets data channel protection level (PROT).
   *
   * @param protection should be {@link GridFTPSession#PROTECTION_CLEAR CLEAR}, {@link
   *     GridFTPSession#PROTECTION_SAFE SAFE}, or {@link GridFTPSession#PROTECTION_PRIVATE PRIVATE},
   *     or {@link GridFTPSession#PROTECTION_CONFIDENTIAL CONFIDENTIAL}.
   */
  public void setDataChannelProtection(int protection) throws IOException, ServerException {

    String protectionStr = null;
    switch (protection) {
      case GridFTPSession.PROTECTION_CLEAR:
        protectionStr = "C";
        break;
      case GridFTPSession.PROTECTION_SAFE:
        protectionStr = "S";
        break;
      case GridFTPSession.PROTECTION_CONFIDENTIAL:
        protectionStr = "E";
        break;
      case GridFTPSession.PROTECTION_PRIVATE:
        protectionStr = "P";
        break;
      default:
        throw new IllegalArgumentException("Bad protection: " + protection);
    }

    Command cmd = new Command("PROT", protectionStr);
    try {
      controlChannel.execute(cmd);
    } catch (UnexpectedReplyCodeException urce) {
      throw ServerException.embedUnexpectedReplyCodeException(urce);
    } catch (FTPReplyParseException rpe) {
      throw ServerException.embedFTPReplyParseException(rpe);
    }

    this.gSession.dataChannelProtection = protection;

    gLocalServer.setDataChannelProtection(protection);
  }
Exemplo n.º 2
0
 /**
  * Starts local server in striped active mode. setStripedPassive() must be called before that.
  * This method takes no parameters. HostPortList of the remote server, known from the last call of
  * setStripedPassive(), is stored internally and the local server will connect to this address.
  */
 public void setLocalStripedActive() throws ClientException, IOException {
   if (gSession.serverAddressList == null) {
     throw new ClientException(ClientException.CALL_PASSIVE_FIRST);
   }
   try {
     gLocalServer.setStripedActive(gSession.serverAddressList);
   } catch (UnknownHostException e) {
     throw new ClientException(ClientException.UNKNOWN_HOST);
   }
 }
Exemplo n.º 3
0
  /**
   * Constructs client and connects it to the remote server.
   *
   * @param host remote server host
   * @param port remote server port
   */
  public GridFTPClient(String host, int port) throws IOException, ServerException {
    gSession = new GridFTPSession();
    session = gSession;

    expectedHostName = host;
    controlChannel = new FTPControlChannel(host, port);
    controlChannel.open();

    gLocalServer = new GridFTPServerFacade(controlChannel);
    localServer = gLocalServer;
    gLocalServer.authorize();
    this.useAllo = true;

    setUsageInformation("dCache", VERSION.getVersion());
  }
Exemplo n.º 4
0
  /**
   * Performs extended retrieve (partial retrieve mode).
   *
   * @param remoteFileName file to retrieve
   * @param offset the staring offset in the remote file
   * @param size number of bytes of remote file to transmit
   * @param sink data sink to store the file
   * @param mListener marker listener
   */
  public void extendedGet(
      String remoteFileName, long offset, long size, DataSink sink, MarkerListener mListener)
      throws IOException, ClientException, ServerException {

    // servers support GridFTP?
    checkGridFTPSupport();
    // all parameters set correctly (or still unset)?
    checkTransferParamsGet();

    gLocalServer.store(sink);

    controlChannel.write(new Command("ERET", "P " + offset + " " + size + " " + remoteFileName));

    transferRunSingleThread(localServer.getControlChannel(), mListener);
  }
Exemplo n.º 5
0
  /**
   * Sets data channel authentication mode (DCAU)
   *
   * @param type for 2-party transfer must be DataChannelAuthentication.SELF or
   *     DataChannelAuthentication.NONE
   */
  public void setDataChannelAuthentication(DataChannelAuthentication type)
      throws IOException, ServerException {

    Command cmd = new Command("DCAU", type.toFtpCmdArgument());
    try {

      controlChannel.execute(cmd);

    } catch (UnexpectedReplyCodeException urce) {
      if (!type.toFtpCmdArgument().equals("N")) {
        throw ServerException.embedUnexpectedReplyCodeException(urce);
      }
    } catch (FTPReplyParseException rpe) {
      throw ServerException.embedFTPReplyParseException(rpe);
    }

    this.gSession.dataChannelAuthentication = type;

    gLocalServer.setDataChannelAuthentication(type);
  }
Exemplo n.º 6
0
 /**
  * Sets compatibility mode with old GSIFTP server. Locally sets data channel authentication to
  * NONE but does not send the command to the remote server (the server wouldn't understand it)
  */
 public void setLocalNoDataChannelAuthentication() {
   gLocalServer.setDataChannelAuthentication(DataChannelAuthentication.NONE);
 }
Exemplo n.º 7
0
 /**
  * Behaves like setLocalStripedPassive(FTPServerFacade.ANY_PORT, FTPServerFacade.DEFAULT_QUEUE)
  */
 public HostPortList setLocalStripedPassive() throws IOException {
   return gLocalServer.setStripedPassive(portRange, FTPServerFacade.DEFAULT_QUEUE);
 }
Exemplo n.º 8
0
 /**
  * Starts local server in striped passive mode. Since the local server is not distributed, it will
  * only listen on one socket.
  *
  * @param range required server port
  * @param queue max size of queue of awaiting new data channel connection requests
  * @return the HostPortList of 1 element representing the socket where the local server is
  *     listening
  */
 public HostPortList setLocalStripedPassive(PortRange range, int queue) throws IOException {
   return gLocalServer.setStripedPassive(range, queue);
 }