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

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

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

Buffer.putBoolean介绍

暂无

代码示例

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

/**
 * Appends the end-of-list indicator for {@code SSH_FXP_NAME} responses, provided the version
 * is at least 6, the feature is enabled and the indicator value is not {@code null}
 *
 * @param buffer         The {@link Buffer} to append the indicator
 * @param version        The SFTP version being used
 * @param resolver       The {@link PropertyResolver} to query whether to enable the feature
 * @param indicatorValue The indicator value - {@code null} means don't append the indicator
 * @return The actual indicator value used - {@code null} if none appended
 * @see <A HREF="https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.4">SFTP v6 - section 9.4</A>
 * @see #APPEND_END_OF_LIST_INDICATOR
 * @see #DEFAULT_APPEND_END_OF_LIST_INDICATOR
 */
public static Boolean indicateEndOfNamesList(Buffer buffer, int version, PropertyResolver resolver, boolean indicatorValue) {
  if (version < SftpConstants.SFTP_V6) {
    return null;
  }
  if (!resolver.getBooleanProperty(APPEND_END_OF_LIST_INDICATOR, DEFAULT_APPEND_END_OF_LIST_INDICATOR)) {
    return null;
  }
  buffer.putBoolean(indicatorValue);
  return indicatorValue;
}

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

@Override
public IoWriteFuture sendDebugMessage(boolean display, Object msg, String lang) throws IOException {
  String text = Objects.toString(msg, "");
  lang = (lang == null) ? "" : lang;
  Buffer buffer = createBuffer(SshConstants.SSH_MSG_DEBUG,
      text.length() + lang.length() + Integer.SIZE /* a few extras */);
  buffer.putBoolean(display);
  buffer.putString(text);
  buffer.putString(lang);
  return writePacket(buffer);
}

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

@Override
public IoWriteFuture sendDebugMessage(boolean display, Object msg, String lang) throws IOException {
  String text = Objects.toString(msg, "");
  lang = (lang == null) ? "" : lang;
  Buffer buffer = createBuffer(SshConstants.SSH_MSG_DEBUG,
    text.length() + lang.length() + Integer.SIZE /* a few extras */);
  buffer.putBoolean(display);
  buffer.putString(text);
  buffer.putString(lang);
  return writePacket(buffer);
}

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

public <B extends Buffer> B append(B buffer) {
  buffer.putString(getPrompt());
  buffer.putBoolean(isEcho());
  return buffer;
}

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

public <B extends Buffer> B append(B buffer) {
  buffer.putString(getPrompt());
  buffer.putBoolean(isEcho());
  return buffer;
}

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

/**
 * Sends a heartbeat message
 * @return The {@link IoWriteFuture} that can be used to wait for the
 * message write completion
 */
protected IoWriteFuture sendHeartBeat() {
  ClientSession session = getClientSession();
  String request = session.getStringProperty(ClientFactoryManager.HEARTBEAT_REQUEST, ClientFactoryManager.DEFAULT_KEEP_ALIVE_HEARTBEAT_STRING);
  try {
    Buffer buf = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, request.length() + Byte.SIZE);
    buf.putString(request);
    buf.putBoolean(false);
    IoWriteFuture future = session.writePacket(buf);
    future.addListener(this::futureDone);
    return future;
  } catch (IOException e) {
    getSession().exceptionCaught(e);
    if (log.isDebugEnabled()) {
      log.debug("Error (" + e.getClass().getSimpleName() + ") sending keepalive message=" + request + ": " + e.getMessage());
    }
    Throwable t = e;
    return new AbstractIoWriteFuture(request, null) {
      {
        setValue(t);
      }
    };
  }
}

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

protected void sendExitStatus(int v) throws IOException {
    if (exitStatusSent.getAndSet(true)) {
      if (log.isDebugEnabled()) {
        log.debug("sendExitStatus({}) exit-status={} - already sent", this, v);
      }
      notifyStateChanged("exit-status");   // just in case
      return;
    }

    if (log.isDebugEnabled()) {
      log.debug("sendExitStatus({}) SSH_MSG_CHANNEL_REQUEST exit-status={}", this, v);
    }

    Session session = getSession();
    Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE);
    buffer.putInt(getRecipient());
    buffer.putString("exit-status");
    buffer.putBoolean(false);   // want-reply - must be FALSE - see https://tools.ietf.org/html/rfc4254 section 6.10
    buffer.putInt(v);
    writePacket(buffer);
    notifyStateChanged("exit-status");
  }
}

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

protected void sendExitStatus(int v) throws IOException {
    if (exitStatusSent.getAndSet(true)) {
      if (log.isDebugEnabled()) {
        log.debug("sendExitStatus({}) exit-status={} - already sent", this, v);
      }
      notifyStateChanged("exit-status");   // just in case
      return;
    }

    if (log.isDebugEnabled()) {
      log.debug("sendExitStatus({}) SSH_MSG_CHANNEL_REQUEST exit-status={}", this, v);
    }

    Session session = getSession();
    Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE);
    buffer.putInt(getRecipient());
    buffer.putString("exit-status");
    buffer.putBoolean(false);   // want-reply - must be FALSE - see https://tools.ietf.org/html/rfc4254 section 6.10
    buffer.putInt(v);
    writePacket(buffer);
    notifyStateChanged("exit-status");
  }
}

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

@Override
public void link(String linkPath, String targetPath, boolean symbolic) throws IOException {
  if (!isOpen()) {
    throw new IOException("link(" + linkPath + " => " + targetPath + ")[symbolic=" + symbolic + "] client is closed");
  }
  if (log.isDebugEnabled()) {
    log.debug("link({})[symbolic={}] {} => {}", getClientSession(), symbolic, linkPath, targetPath);
  }
  Buffer buffer = new ByteArrayBuffer(linkPath.length() + targetPath.length() + Long.SIZE /* some extra fields */, false);
  int version = getVersion();
  if (version < SftpConstants.SFTP_V6) {
    if (!symbolic) {
      throw new UnsupportedOperationException("Hard links are not supported in sftp v" + version);
    }
    buffer = putReferencedName(SftpConstants.SSH_FXP_SYMLINK, buffer, targetPath, 0);
    buffer = putReferencedName(SftpConstants.SSH_FXP_SYMLINK, buffer, linkPath, 1);
    checkCommandStatus(SftpConstants.SSH_FXP_SYMLINK, buffer);
  } else {
    buffer = putReferencedName(SftpConstants.SSH_FXP_SYMLINK, buffer, targetPath, 0);
    buffer = putReferencedName(SftpConstants.SSH_FXP_SYMLINK, buffer, linkPath, 1);
    buffer.putBoolean(symbolic);
    checkCommandStatus(SftpConstants.SSH_FXP_LINK, buffer);
  }
}

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

@Override
protected void doOpen() throws IOException {
  String systemName = getSubsystem();
  if (log.isDebugEnabled()) {
    log.debug("doOpen({}) SSH_MSG_CHANNEL_REQUEST subsystem={}", this, systemName);
  }
  Session session = getSession();
  boolean wantReply = this.getBooleanProperty(REQUEST_SUBSYSTEM_REPLY, DEFAULT_REQUEST_SUBSYSTEM_REPLY);
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST,
      Channel.CHANNEL_SUBSYSTEM.length() + systemName.length() + Integer.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString(Channel.CHANNEL_SUBSYSTEM);
  buffer.putBoolean(wantReply);
  buffer.putString(systemName);
  addPendingRequest(Channel.CHANNEL_SUBSYSTEM, wantReply);
  writePacket(buffer);
  super.doOpen();
}

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

@Override
protected void doOpen() throws IOException {
  String systemName = getSubsystem();
  if (log.isDebugEnabled()) {
    log.debug("doOpen({}) SSH_MSG_CHANNEL_REQUEST subsystem={}", this, systemName);
  }
  Session session = getSession();
  boolean wantReply = this.getBooleanProperty(REQUEST_SUBSYSTEM_REPLY, DEFAULT_REQUEST_SUBSYSTEM_REPLY);
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST,
      Channel.CHANNEL_SUBSYSTEM.length() + systemName.length() + Integer.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString(Channel.CHANNEL_SUBSYSTEM);
  buffer.putBoolean(wantReply);
  buffer.putString(systemName);
  addPendingRequest(Channel.CHANNEL_SUBSYSTEM, wantReply);
  writePacket(buffer);
  super.doOpen();
}

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

@Override
protected void doOpen() throws IOException {
  doOpenPty();
  if (log.isDebugEnabled()) {
    log.debug("doOpen({}) send SSH_MSG_CHANNEL_REQUEST exec command={}", this, command);
  }
  Session session = getSession();
  boolean wantReply = this.getBooleanProperty(REQUEST_EXEC_REPLY, DEFAULT_REQUEST_EXEC_REPLY);
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, command.length() + Integer.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString(Channel.CHANNEL_EXEC);
  buffer.putBoolean(wantReply);
  buffer.putString(command);
  addPendingRequest(Channel.CHANNEL_EXEC, wantReply);
  writePacket(buffer);
  super.doOpen();
}

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

@Override
  public void copyFile(String src, String dst, boolean overwriteDestination) throws IOException {
    Buffer buffer = getCommandBuffer(Integer.BYTES + GenericUtils.length(src)
        + Integer.BYTES + GenericUtils.length(dst)
        + 1 /* override destination */);
    buffer.putString(src);
    buffer.putString(dst);
    buffer.putBoolean(overwriteDestination);
    sendAndCheckExtendedCommandStatus(buffer);
  }
}

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

@Override
protected void doOpen() throws IOException {
  doOpenPty();
  if (log.isDebugEnabled()) {
    log.debug("doOpen({}) send SSH_MSG_CHANNEL_REQUEST shell", this);
  }
  Session session = getSession();
  boolean wantReply = this.getBooleanProperty(REQUEST_SHELL_REPLY, DEFAULT_REQUEST_SHELL_REPLY);
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Integer.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString(Channel.CHANNEL_SHELL);
  buffer.putBoolean(wantReply);
  addPendingRequest(Channel.CHANNEL_SHELL, wantReply);
  writePacket(buffer);
  super.doOpen();
}

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

@Override
protected void doOpen() throws IOException {
  doOpenPty();
  if (log.isDebugEnabled()) {
    log.debug("doOpen({}) send SSH_MSG_CHANNEL_REQUEST exec command={}", this, command);
  }
  Session session = getSession();
  boolean wantReply = this.getBooleanProperty(REQUEST_EXEC_REPLY, DEFAULT_REQUEST_EXEC_REPLY);
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, command.length() + Integer.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString(Channel.CHANNEL_EXEC);
  buffer.putBoolean(wantReply);
  buffer.putString(command);
  addPendingRequest(Channel.CHANNEL_EXEC, wantReply);
  writePacket(buffer);
  super.doOpen();
}

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

@Override
protected void doOpen() throws IOException {
  doOpenPty();
  if (log.isDebugEnabled()) {
    log.debug("doOpen({}) send SSH_MSG_CHANNEL_REQUEST shell", this);
  }
  Session session = getSession();
  boolean wantReply = this.getBooleanProperty(REQUEST_SHELL_REPLY, DEFAULT_REQUEST_SHELL_REPLY);
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Integer.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString(Channel.CHANNEL_SHELL);
  buffer.putBoolean(wantReply);
  addPendingRequest(Channel.CHANNEL_SHELL, wantReply);
  writePacket(buffer);
  super.doOpen();
}

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

public void sendWindowChange(int columns, int lines, int height, int width) throws IOException {
  if (log.isDebugEnabled()) {
    log.debug("sendWindowChange({}) cols={}, lines={}, height={}, width={}",
         this, columns, lines, height, width);
  }
  ptyColumns = columns;
  ptyLines = lines;
  ptyHeight = height;
  ptyWidth = width;
  Session session = getSession();
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString("window-change");
  buffer.putBoolean(false);   // want-reply
  buffer.putInt(ptyColumns);
  buffer.putInt(ptyLines);
  buffer.putInt(ptyHeight);
  buffer.putInt(ptyWidth);
  writePacket(buffer);
}

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

public void sendWindowChange(int columns, int lines, int height, int width) throws IOException {
  if (log.isDebugEnabled()) {
    log.debug("sendWindowChange({}) cols={}, lines={}, height={}, width={}",
         this, columns, lines, height, width);
  }
  ptyColumns = columns;
  ptyLines = lines;
  ptyHeight = height;
  ptyWidth = width;
  Session session = getSession();
  Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE);
  buffer.putInt(getRecipient());
  buffer.putString("window-change");
  buffer.putBoolean(false);   // want-reply
  buffer.putInt(ptyColumns);
  buffer.putInt(ptyLines);
  buffer.putInt(ptyHeight);
  buffer.putInt(ptyWidth);
  writePacket(buffer);
}

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

protected boolean verifySignature(
    ServerSession session, String username, String alg, PublicKey key, Buffer buffer, Signature verifier, byte[] sig)
      throws Exception {
  byte[] id = session.getSessionId();
  String service = getService();
  String name = getName();
  Buffer buf = new ByteArrayBuffer(id.length + username.length() + service.length() + name.length()
    + alg.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE, false);
  buf.putBytes(id);
  buf.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
  buf.putString(username);
  buf.putString(service);
  buf.putString(name);
  buf.putBoolean(true);
  buf.putString(alg);
  buf.putBuffer(buffer);
  if (log.isTraceEnabled()) {
    log.trace("verifySignature({}@{})[{}][{}] key type={}, fingerprint={} - verification data={}",
       username, session, service, name, alg, KeyUtils.getFingerPrint(key), buf.toHex());
    log.trace("verifySignature({}@{})[{}][{}] key type={}, fingerprint={} - expected signature={}",
       username, session, service, name, alg, KeyUtils.getFingerPrint(key), BufferUtils.toHex(sig));
  }
  verifier.update(buf.array(), buf.rpos(), buf.available());
  return verifier.verify(sig);
}

代码示例来源:origin: com.alibaba.middleware/termd-core

buffer.putString(service);
buffer.putString(UserAuthMethodFactory.PASSWORD);
buffer.putBoolean(false);
buffer.putString(password);
session.writePacket(buffer);

相关文章