org.apache.sshd.common.util.buffer.Buffer.getString()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.apache.sshd.common.util.buffer.Buffer.getString()方法的一些代码示例,展示了Buffer.getString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.getString()方法的具体详情如下:
包路径:org.apache.sshd.common.util.buffer.Buffer
类名称:Buffer
方法名:getString

Buffer.getString介绍

暂无

代码示例

代码示例来源:origin: org.apache.sshd/sshd-osgi

/**
 * @return Reads a UTF-8 encoded string
 */
public String getString() {
  return getString(StandardCharsets.UTF_8);
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected RequestHandler.Result handleEnv(Buffer buffer, boolean wantReply) throws IOException {
  String name = buffer.getString();
  String value = buffer.getString();
  addEnvVariable(name, value);
  if (log.isDebugEnabled()) {
    log.debug("handleEnv({}): {} = {}", this, name, value);
  }
  return RequestHandler.Result.ReplySuccess;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public VendorId parse(Buffer buffer) {
    VendorId id = new VendorId();
    id.vendorName = buffer.getString();
    id.productName = buffer.getString();
    id.productVersion = buffer.getString();
    id.productBuildNumber = buffer.getLong();
    return id;
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
protected String processRequestValue(Channel channel, String request, Buffer buffer) throws Exception {
  return processRequestValue(channel, buffer.getString(), buffer.getBoolean(), buffer.getString(), buffer.getString());
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

protected RequestHandler.Result handleEnv(Buffer buffer, boolean wantReply) throws IOException {
  String name = buffer.getString();
  String value = buffer.getString();
  addEnvVariable(name, value);
  if (log.isDebugEnabled()) {
    log.debug("handleEnv({}): {} = {}", this, name, value);
  }
  return RequestHandler.Result.ReplySuccess;
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected void handleServiceRequest(Buffer buffer) throws Exception {
  String serviceName = buffer.getString();
  handleServiceRequest(serviceName, buffer);
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
public void handleDebugMessage(Session session, Buffer buffer) throws Exception {
  handleDebugMessage(session, buffer.getBoolean(), buffer.getString(), buffer.getString(), buffer);
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public static NavigableMap<String, byte[]> readExtensions(Buffer buffer) {
  int count = buffer.getInt();
  // NOTE
  NavigableMap<String, byte[]> extended = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
  for (int i = 0; i < count; i++) {
    String key = buffer.getString();
    byte[] val = buffer.getBytes();
    byte[] prev = extended.put(key, val);
    ValidateUtils.checkTrue(prev == null, "Duplicate values for extended key=%s", key);
  }
  return extended;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doOpenSSHHardLink(Buffer buffer, int id) throws IOException {
  String srcFile = buffer.getString();
  String dstFile = buffer.getString();
  try {
    doOpenSSHHardLink(id, srcFile, dstFile);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_EXTENDED, HardLinkExtensionParser.NAME, srcFile, dstFile);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
public Boolean doAuth(Buffer buffer, boolean init) throws Exception {
  ValidateUtils.checkTrue(init, "Instance not initialized");
  boolean newPassword = buffer.getBoolean();
  String password = buffer.getString();
  if (newPassword) {
    return handleClientPasswordChangeRequest(buffer, getServerSession(), getUsername(), password, buffer.getString());
  } else {
    return checkPassword(buffer, getServerSession(), getUsername(), password);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
public Boolean doAuth(Buffer buffer, boolean init) throws Exception {
  ValidateUtils.checkTrue(init, "Instance not initialized");
  boolean newPassword = buffer.getBoolean();
  String password = buffer.getString();
  if (newPassword) {
    return handleClientPasswordChangeRequest(buffer, getServerSession(), getUsername(), password, buffer.getString());
  } else {
    return checkPassword(buffer, getServerSession(), getUsername(), password);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doOpenSSHFsync(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  try {
    doOpenSSHFsync(id, handle);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_EXTENDED, FsyncExtensionParser.NAME, handle);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doClose(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  try {
    doClose(id, handle);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_CLOSE, handle);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "", "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doRemoveDirectory(Buffer buffer, int id) throws IOException {
  String path = buffer.getString();
  try {
    doRemoveDirectory(id, path, IoUtils.getLinkOptions(false));
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_RMDIR, path);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doSetStat(Buffer buffer, int id) throws IOException {
  String path = buffer.getString();
  Map<String, Object> attrs = readAttrs(buffer);
  try {
    doSetStat(id, path, attrs);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_SETSTAT, path);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doFSetStat(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  Map<String, Object> attrs = readAttrs(buffer);
  try {
    doFSetStat(id, handle, attrs);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_FSETSTAT, handle, attrs);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doTextSeek(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  long line = buffer.getLong();
  try {
    // TODO : implement text-seek - see https://tools.ietf.org/html/draft-ietf-secsh-filexfer-03#section-6.3
    doTextSeek(id, handle, line);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_EXTENDED, SftpConstants.EXT_TEXT_SEEK, handle, line);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doUnblock(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  long offset = buffer.getLong();
  long length = buffer.getLong();
  try {
    doUnblock(id, handle, offset, length);
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_UNBLOCK, handle, offset, length);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doMakeDirectory(Buffer buffer, int id) throws IOException {
  String path = buffer.getString();
  Map<String, ?> attrs = readAttrs(buffer);
  try {
    doMakeDirectory(id, path, attrs, IoUtils.getLinkOptions(false));
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_MKDIR, path, attrs);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doWrite(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  long offset = buffer.getLong();
  int length = buffer.getInt();
  try {
    doWrite(id, handle, offset, length, buffer.array(), buffer.rpos(), buffer.available());
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_WRITE, handle, offset, length);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

相关文章