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

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

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

Buffer.putBytes介绍

暂无

代码示例

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

public void putAndWipeBytes(byte[] b, int off, int len) {
  putBytes(b, off, len);
  for (int pos = off, index = 0; index < len; pos++, index++) {
    b[pos] = (byte) 0;
  }
}

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

public void putAndWipeBytes(byte[] b, int off, int len) {
  putBytes(b, off, len);
  for (int pos = off, index = 0; index < len; pos++, index++) {
    b[pos] = (byte) 0;
  }
}

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

public void putString(String string, Charset charset) {
  if (GenericUtils.isEmpty(string)) {
    putBytes(GenericUtils.EMPTY_BYTE_ARRAY);
  } else {
    putBytes(string.getBytes(charset));
  }
}

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

public void putString(String string, Charset charset) {
  if (GenericUtils.isEmpty(string)) {
    putBytes(GenericUtils.EMPTY_BYTE_ARRAY);
  } else {
    byte[] bytes = string.getBytes(charset);
    putBytes(bytes);
  }
}

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

public synchronized void write(byte[] buf, int off, int len) {
  if (len == 1) {
    write(buf[off] & 0xFF);
  } else {
    buffer.putBytes(buf, off, len);
  }
}

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

public void putChars(char[] chars, int offset, int len, Charset charset) {
  if (len <= 0) {
    putBytes(GenericUtils.EMPTY_BYTE_ARRAY);
  } else {
    putBuffer(charset.encode(CharBuffer.wrap(chars, offset, len)));
  }
}

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

public synchronized void write(byte[] buf, int off, int len) {
  if (len == 1) {
    write(buf[off] & 0xFF);
  } else {
    buffer.putBytes(buf, off, len);
  }
}

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

public void putChars(char[] chars, int offset, int len, Charset charset) {
  if (len <= 0) {
    putBytes(GenericUtils.EMPTY_BYTE_ARRAY);
  } else {
    CharBuffer charBuf = CharBuffer.wrap(chars, offset, len);
    ByteBuffer byteBuf = charset.encode(charBuf);
    putBuffer(byteBuf);
  }
}

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

public void putBytes(byte[] b) {
  putBytes(b, 0, NumberUtils.length(b));
}

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

public void putBytes(byte[] b) {
  putBytes(b, 0, NumberUtils.length(b));
}

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

@Override
public IoWriteFuture sendIgnoreMessage(byte... data) throws IOException {
  data = (data == null) ? GenericUtils.EMPTY_BYTE_ARRAY : data;
  Buffer buffer = createBuffer(SshConstants.SSH_MSG_IGNORE, data.length + Byte.SIZE);
  buffer.putBytes(data);
  return writePacket(buffer);
}

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

@Override
public IoWriteFuture sendIgnoreMessage(byte... data) throws IOException {
  data = (data == null) ? GenericUtils.EMPTY_BYTE_ARRAY : data;
  Buffer buffer = createBuffer(SshConstants.SSH_MSG_IGNORE, data.length + Byte.SIZE);
  buffer.putBytes(data);
  return writePacket(buffer);
}

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

@Override
public void close(Handle handle) throws IOException {
  if (!isOpen()) {
    throw new IOException("close(" + handle + ") client is closed");
  }
  if (log.isTraceEnabled()) {
    log.trace("close({}) {}", getClientSession(), handle);
  }
  byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
  Buffer buffer = new ByteArrayBuffer(id.length + Long.SIZE /* some extra fields */, false);
  buffer.putBytes(id);
  checkCommandStatus(SftpConstants.SSH_FXP_CLOSE, buffer);
}

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

@Override
public void setStat(Handle handle, Attributes attributes) throws IOException {
  if (!isOpen()) {
    throw new IOException("setStat(" + handle + ")[" + attributes + "] client is closed");
  }
  if (log.isDebugEnabled()) {
    log.debug("setStat({})[{}]: {}", getClientSession(), handle, attributes);
  }
  byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
  Buffer buffer = new ByteArrayBuffer(id.length + (2 * Long.SIZE) /* some extras */, false);
  buffer.putBytes(id);
  buffer = writeAttributes(SftpConstants.SSH_FXP_FSETSTAT, buffer, attributes);
  checkCommandStatus(SftpConstants.SSH_FXP_FSETSTAT, buffer);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit.ssh.apache

private void sendToken(ClientSession session, byte[] receivedToken)
    throws IOException, GSSException {
  state = ProtocolState.TOKENS;
  byte[] token = context.initSecContext(receivedToken, 0,
      receivedToken.length);
  if (token != null) {
    Buffer buffer = session.createBuffer(SSH_MSG_USERAUTH_GSSAPI_TOKEN);
    buffer.putBytes(token);
    session.writePacket(buffer);
  }
}

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

@Override
public void lock(Handle handle, long offset, long length, int mask) throws IOException {
  if (!isOpen()) {
    throw new IOException("lock(" + handle + ")[offset=" + offset + ", length=" + length + ", mask=0x" + Integer.toHexString(mask) + "] client is closed");
  }
  if (log.isDebugEnabled()) {
    log.debug("lock({})[{}] offset={}, length={}, mask=0x{}",
         getClientSession(), handle, offset, length, Integer.toHexString(mask));
  }
  byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
  Buffer buffer = new ByteArrayBuffer(id.length + Long.SIZE /* a bit extra */, false);
  buffer.putBytes(id);
  buffer.putLong(offset);
  buffer.putLong(length);
  buffer.putInt(mask);
  checkCommandStatus(SftpConstants.SSH_FXP_BLOCK, buffer);
}

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

@Override
public Attributes stat(Handle handle) throws IOException {
  if (!isOpen()) {
    throw new IOException("stat(" + handle + ") client is closed");
  }
  byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
  Buffer buffer = new ByteArrayBuffer(id.length + Byte.SIZE /* a bit extra */, false);
  buffer.putBytes(id);
  int version = getVersion();
  if (version >= SftpConstants.SFTP_V4) {
    buffer.putInt(SftpConstants.SSH_FILEXFER_ATTR_ALL);
  }
  return checkAttributes(SftpConstants.SSH_FXP_FSTAT, buffer);
}

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

@Override
  public void fsync(Handle fileHandle) throws IOException {
    byte[] handle = fileHandle.getIdentifier();
    Buffer buffer = getCommandBuffer(Integer.BYTES + NumberUtils.length(handle));
    buffer.putBytes(handle);
    sendAndCheckExtendedCommandStatus(buffer);
  }
}

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

public static <B extends Buffer> B putRawEDDSAPublicKey(B buffer, PublicKey key) {
  ValidateUtils.checkTrue(SecurityUtils.isEDDSACurveSupported(), SecurityUtils.EDDSA + " not supported");
  EdDSAPublicKey edKey = ValidateUtils.checkInstanceOf(key, EdDSAPublicKey.class, "Not an EDDSA public key: %s", key);
  byte[] seed = Ed25519PublicKeyDecoder.getSeedValue(edKey);
  ValidateUtils.checkNotNull(seed, "No seed extracted from key: %s", edKey.getA());
  buffer.putString(KeyPairProvider.SSH_ED25519);
  buffer.putBytes(seed);
  return buffer;
}

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

public static <B extends Buffer> B putRawEDDSAPublicKey(B buffer, PublicKey key) {
  ValidateUtils.checkTrue(SecurityUtils.isEDDSACurveSupported(), SecurityUtils.EDDSA + " not supported");
  EdDSAPublicKey edKey = ValidateUtils.checkInstanceOf(key, EdDSAPublicKey.class, "Not an EDDSA public key: %s", key);
  byte[] seed = Ed25519PublicKeyDecoder.getSeedValue(edKey);
  ValidateUtils.checkNotNull(seed, "No seed extracted from key: %s", edKey.getA());
  buffer.putString(KeyPairProvider.SSH_ED25519);
  buffer.putBytes(seed);
  return buffer;
}

相关文章