本文整理了Java中org.apache.sshd.common.util.buffer.Buffer.wpos()
方法的一些代码示例,展示了Buffer.wpos()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.wpos()
方法的具体详情如下:
包路径:org.apache.sshd.common.util.buffer.Buffer
类名称:Buffer
方法名:wpos
暂无
代码示例来源:origin: org.apache.sshd/sshd-core
protected Buffer prepare(Buffer buffer) {
int wpos = buffer.wpos();
buffer.wpos(0);
buffer.putInt(wpos - 4);
buffer.wpos(wpos);
return buffer;
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
protected Buffer prepare(Buffer buffer) {
int wpos = buffer.wpos();
buffer.wpos(0);
buffer.putInt(wpos - 4);
buffer.wpos(wpos);
return buffer;
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
public void putPublicKey(PublicKey key) {
int ow = wpos();
putInt(0);
int ow1 = wpos();
putRawPublicKey(key);
int ow2 = wpos();
wpos(ow);
putInt(ow2 - ow1);
wpos(ow2);
}
代码示例来源:origin: org.apache.sshd/sshd-common
/**
* Updates a 32-bit "placeholder" location for data length - moves
* the write position to the specified placeholder position, updates the length
* value and then moves the write position it back to its original value.
*
* @param buffer The {@link Buffer}
* @param lenPos The offset in the buffer where the length placeholder is
* to be update - <B>Note:</B> assumption is that the encoded data starts
* <U>immediately</U> after the placeholder
* @param dataLength The length to update
*/
public static void updateLengthPlaceholder(Buffer buffer, int lenPos, int dataLength) {
int curPos = buffer.wpos();
buffer.wpos(lenPos);
buffer.putInt(dataLength);
buffer.wpos(curPos);
}
代码示例来源:origin: org.apache.sshd/sshd-common
public void putPublicKey(PublicKey key) {
int ow = wpos();
putInt(0);
int ow1 = wpos();
putRawPublicKey(key);
int ow2 = wpos();
wpos(ow);
putInt(ow2 - ow1);
wpos(ow2);
}
代码示例来源:origin: org.apache.sshd/sshd-core
protected Buffer prepare(Buffer buf) {
int len = buf.available();
int rpos = buf.rpos();
int wpos = buf.wpos();
buf.rpos(rpos - 4);
buf.wpos(rpos - 4);
buf.putInt(len);
buf.wpos(wpos);
return buf;
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
protected Buffer prepare(Buffer buf) {
int len = buf.available();
int rpos = buf.rpos();
int wpos = buf.wpos();
buf.rpos(rpos - 4);
buf.wpos(rpos - 4);
buf.putInt(len);
buf.wpos(wpos);
return buf;
}
代码示例来源:origin: org.apache.sshd/sshd-common
/**
* @param parser A {@link BufferPublicKeyParser} to extract the key from the buffer
* - never {@code null}
* @return The extracted {@link PublicKey} - may be {@code null} if the parser so decided
* @throws SshException If failed to extract the key
* @see #getRawPublicKey(BufferPublicKeyParser)
*/
public PublicKey getPublicKey(BufferPublicKeyParser<? extends PublicKey> parser) throws SshException {
int ow = wpos();
int len = getInt();
wpos(rpos() + len);
try {
return getRawPublicKey(parser);
} finally {
wpos(ow);
}
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
@Override
public String toString() {
return getClass().getSimpleName()
+ "[rpos=" + rpos()
+ ", wpos=" + wpos()
+ ", size=" + size()
+ "]";
}
}
代码示例来源:origin: org.apache.sshd/sshd-common
@Override
public String toString() {
return "Buffer [rpos=" + rpos() + ", wpos=" + wpos() + ", size=" + size() + "]";
}
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
@Override
public void compress(Buffer buffer) throws IOException {
compresser.setInput(buffer.array(), buffer.rpos(), buffer.available());
buffer.wpos(buffer.rpos());
for (int len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH);
len > 0;
len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH)) {
buffer.putRawBytes(tmpbuf, 0, len);
}
}
代码示例来源:origin: org.apache.sshd/sshd-common
@Override
public void compress(Buffer buffer) throws IOException {
compresser.setInput(buffer.array(), buffer.rpos(), buffer.available());
buffer.wpos(buffer.rpos());
for (int len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH);
len > 0;
len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH)) {
buffer.putRawBytes(tmpbuf, 0, len);
}
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
@Override
public Buffer prepareBuffer(byte cmd, Buffer buffer) {
buffer = validateTargetBuffer(cmd & 0xFF, buffer);
buffer.rpos(SshConstants.SSH_PACKET_HEADER_LEN);
buffer.wpos(SshConstants.SSH_PACKET_HEADER_LEN);
buffer.putByte(cmd);
return buffer;
}
代码示例来源:origin: org.apache.sshd/sshd-core
@Override
public Buffer prepareBuffer(byte cmd, Buffer buffer) {
buffer = validateTargetBuffer(cmd & 0xFF, buffer);
buffer.rpos(SshConstants.SSH_PACKET_HEADER_LEN);
buffer.wpos(SshConstants.SSH_PACKET_HEADER_LEN);
buffer.putByte(cmd);
return buffer;
}
代码示例来源:origin: org.apache.sshd/sshd-sftp
public static <B extends Buffer> B writeACLs(B buffer, int version, Collection<? extends AclEntry> acl) {
int lenPos = buffer.wpos();
buffer.putInt(0); // length placeholder
buffer = encodeACLs(buffer, version, acl);
BufferUtils.updateLengthPlaceholder(buffer, lenPos);
return buffer;
}
代码示例来源:origin: org.apache.sshd/sshd-common
/**
* @param d The {@link Digest} to use
* @param key the public key - ignored if {@code null}
* @return the fingerprint or {@code null} if no key.
* <B>Note:</B> if exception encountered then returns the exception's simple class name
* @see DigestUtils#getFingerPrint(Digest, byte[], int, int)
*/
public static String getFingerPrint(Digest d, PublicKey key) {
if (key == null) {
return null;
}
try {
Buffer buffer = new ByteArrayBuffer();
buffer.putRawPublicKey(key);
return DigestUtils.getFingerPrint(d, buffer.array(), 0, buffer.wpos());
} catch (Exception e) {
return e.getClass().getSimpleName();
}
}
代码示例来源:origin: org.apache.sshd/sshd-core
protected Buffer insertCharacter(Buffer org, int c) {
int remaining = org.capacity();
int readPos = org.rpos();
// see if can accommodate the character in the original buffer
if ((remaining > 0) && (readPos > 0)) {
int writePos = org.wpos();
org.wpos(readPos - 1);
org.putByte((byte) c);
org.wpos(writePos);
org.rpos(readPos - 1);
return org;
} else {
Buffer buf = new ByteArrayBuffer(org.available() + Byte.SIZE, false);
buf.putByte((byte) c);
buf.putBuffer(org);
return buf;
}
}
代码示例来源:origin: org.apache.sshd/sshd-common
public static byte[] getRawFingerprint(Digest d, PublicKey key) throws Exception {
if (key == null) {
return null;
}
Buffer buffer = new ByteArrayBuffer();
buffer.putRawPublicKey(key);
return DigestUtils.getRawFingerprint(d, buffer.array(), 0, buffer.wpos());
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
public static byte[] getRawFingerprint(Digest d, PublicKey key) throws Exception {
if (key == null) {
return null;
}
Buffer buffer = new ByteArrayBuffer();
buffer.putRawPublicKey(key);
return DigestUtils.getRawFingerprint(d, buffer.array(), 0, buffer.wpos());
}
代码示例来源:origin: org.apache.sshd/sshd-sftp
protected int appendAclSupportedExtension(Buffer buffer) {
ServerSession session = getServerSession();
Collection<Integer> maskValues = resolveAclSupportedCapabilities(session);
int mask = AclSupportedParser.AclCapabilities.constructAclCapabilities(maskValues);
if (mask != 0) {
if (log.isTraceEnabled()) {
log.trace("appendAclSupportedExtension({}) capabilities={}",
session, AclSupportedParser.AclCapabilities.decodeAclCapabilities(mask));
}
buffer.putString(SftpConstants.EXT_ACL_SUPPORTED);
// placeholder for length
int lenPos = buffer.wpos();
buffer.putInt(0);
buffer.putInt(mask);
BufferUtils.updateLengthPlaceholder(buffer, lenPos);
}
return mask;
}
内容来源于网络,如有侵权,请联系作者删除!