• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Buffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.sshd.common.util.Buffer的典型用法代码示例。如果您正苦于以下问题:Java Buffer类的具体用法?Java Buffer怎么用?Java Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Buffer类属于org.apache.sshd.common.util包,在下文中一共展示了Buffer类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startRemotePortForwarding

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
@Override
public synchronized SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException {
    Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_GLOBAL_REQUEST, 0);
    buffer.putString("tcpip-forward");
    buffer.putBoolean(true);
    buffer.putString(remote.getHostName());
    buffer.putInt(remote.getPort());
    Buffer result = session.request(buffer);
    if (result == null) {
        throw new SshException("Tcpip forwarding request denied by server");
    }
    int port = remote.getPort() == 0 ? result.getInt() : remote.getPort();
    // TODO: Is it really safe to only store the local address after the request ?
    remoteToLocal.put(port, local);

    if ( remote.getPort() == 0 ) {
        /* TODO: This will create a leak if stopRemotePortForwarding is called
         * because it won't be removed.  So this hack is incomplete, but works
         * if you never change forwarding during the session.
         */
        remoteToLocal.put(0, local);
    }

    return new SshdSocketAddress(remote.getHostName(), port);
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:26,代码来源:DefaultTcpipForwarder.java


示例2: read

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
@Override
public synchronized int read() throws IOException {
    int c;
    if (buffer.available() > 0) {
        c = buffer.getByte();
        buffer.compact();
    } else {
        c = super.read();
    }
    if (c == '\n' && ttyOptions.contains(TtyOptions.ONlCr) && lastChar != '\r') {
        c = '\r';
        Buffer buf = new Buffer();
        buf.putByte((byte) '\n');
        buf.putBuffer(buffer);
        buffer = buf;
    } else if (c == '\r' && ttyOptions.contains(TtyOptions.OCrNl)) {
        c = '\n';
    }
    lastChar = c;
    return c;
}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:22,代码来源:TtyFilterInputStream.java


示例3: sendPath

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void sendPath(int id, SshFile f, boolean sendAttrs) throws IOException {
    Buffer buffer = new Buffer();
    buffer.putByte((byte) SSH_FXP_NAME);
    buffer.putInt(id);
    buffer.putInt(1);
    //normalize the given path, use *nix style separator
    String normalizedPath = SelectorUtils.normalizePath(f.getAbsolutePath(), "/");
    if (normalizedPath.length() == 0) {
        normalizedPath = "/";
    }
    buffer.putString(normalizedPath);
    f = resolveFile(normalizedPath);
    if (f.getName().length() == 0) {
        f = resolveFile(".");
    }
    buffer.putString(getLongName(f, sendAttrs)); // Format specified in the specs
    buffer.putInt(0);
    send(buffer);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:20,代码来源:SftpSubsystem.java


示例4: sendName

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void sendName(int id, Iterator<SshFile> files) throws IOException {
    Buffer buffer = new Buffer();
    buffer.putByte((byte) SSH_FXP_NAME);
    buffer.putInt(id);
    int wpos = buffer.wpos();
    buffer.putInt(0);
    int nb = 0;
    while (files.hasNext() && buffer.wpos() < MAX_PACKET_LENGTH) {
        SshFile f = files.next();
        buffer.putString(f.getName());
        buffer.putString(getLongName(f)); // Format specified in the specs
        writeAttrs(buffer, f, false);
        nb++;
    }
    int oldpos = buffer.wpos();
    buffer.wpos(wpos);
    buffer.putInt(nb);
    buffer.wpos(oldpos);
    send(buffer);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:21,代码来源:SftpSubsystem.java


示例5: readAttrs

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected Map<SshFile.Attribute, Object> readAttrs(Buffer buffer) throws IOException {
    Map<SshFile.Attribute, Object> attrs = new HashMap<SshFile.Attribute, Object>();
    int flags = buffer.getInt();
    if ((flags & SSH_FILEXFER_ATTR_SIZE) != 0) {
        attrs.put(SshFile.Attribute.Size, buffer.getLong());
    }
    if ((flags & SSH_FILEXFER_ATTR_UIDGID) != 0) {
        attrs.put(SshFile.Attribute.Uid, buffer.getInt());
        attrs.put(SshFile.Attribute.Gid, buffer.getInt());
    }
    if ((flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0) {
        attrs.putAll(getPermissions(buffer.getInt()));
    }
    if ((flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) {
        attrs.put(SshFile.Attribute.LastAccessTime, ((long) buffer.getInt()) * 1000);
        attrs.put(SshFile.Attribute.LastModifiedTime, ((long) buffer.getInt()) * 1000);
    }
    return attrs;
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:20,代码来源:SftpSubsystem.java


示例6: stopRemotePortForwarding

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
@Override
public synchronized void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException {
    if (remoteToLocal.remove(remote.getPort()) != null) {
        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_GLOBAL_REQUEST, 0);
        buffer.putString("cancel-tcpip-forward");
        buffer.putBoolean(false);
        buffer.putString(remote.getHostName());
        buffer.putInt(remote.getPort());
        session.writePacket(buffer);
    }
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:12,代码来源:DefaultTcpipForwarder.java


示例7: messageReceived

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
@Override
public void messageReceived(IoSession session, Readable message) throws Exception {
    TcpipClientChannel channel = (TcpipClientChannel) session.getAttribute(TcpipClientChannel.class);
    Buffer buffer = new Buffer();
    buffer.putBuffer(message);
    channel.waitFor(ClientChannel.OPENED | ClientChannel.CLOSED, Long.MAX_VALUE);
    channel.getOut().write(buffer.array(), buffer.rpos(), buffer.available());
    channel.getOut().flush();
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:10,代码来源:DefaultTcpipForwarder.java


示例8: handleRequest

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
@Override
public void handleRequest(Buffer buffer) throws IOException {
    log.info("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id);
    String type = buffer.getString();
    log.info("Received channel request: {}", type);
    buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_FAILURE, 0);
    buffer.putInt(recipient);
    writePacket(buffer);
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:10,代码来源:TcpipServerChannel.java


示例9: sendHandle

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void sendHandle(int id, String handle) throws IOException {
    Buffer buffer = new Buffer();
    buffer.putByte((byte) SSH_FXP_HANDLE);
    buffer.putInt(id);
    buffer.putString(handle);
    send(buffer);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:8,代码来源:SftpSubsystem.java


示例10: sendAttrs

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void sendAttrs(int id, SshFile file, boolean followLinks) throws IOException {
    Buffer buffer = new Buffer();
    buffer.putByte((byte) SSH_FXP_ATTRS);
    buffer.putInt(id);
    writeAttrs(buffer, file, followLinks);
    send(buffer);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:8,代码来源:SftpSubsystem.java


示例11: sendLink

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void sendLink(int id, String link) throws IOException {
    Buffer buffer = new Buffer();
    buffer.putByte((byte) SSH_FXP_NAME);
    buffer.putInt(id);
    buffer.putInt(1);
    //normalize the given path, use *nix style separator
    buffer.putString(link);
    buffer.putString(link);
    buffer.putInt(0);
    send(buffer);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:12,代码来源:SftpSubsystem.java


示例12: writeAttrs

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void writeAttrs(Buffer buffer, SshFile file, boolean followLinks) throws IOException {
	/* TODO restore
    if (!file.doesExist()) {
        throw new FileNotFoundException(file.getAbsolutePath());
    }
    Map<SshFile.Attribute, Object> attributes = file.getAttributes(followLinks);
    boolean isReg = getBool((Boolean) attributes.get(SshFile.Attribute.IsRegularFile));
    boolean isDir = getBool((Boolean) attributes.get(SshFile.Attribute.IsDirectory));
    boolean isLnk = getBool((Boolean) attributes.get(SshFile.Attribute.IsSymbolicLink));
    int flags = 0;
    if ((isReg || isLnk) && attributes.containsKey(SshFile.Attribute.Size)) {
        flags |= SSH_FILEXFER_ATTR_SIZE;
    }
    if (attributes.containsKey(SshFile.Attribute.Uid) && attributes.containsKey(SshFile.Attribute.Gid)) {
        flags |= SSH_FILEXFER_ATTR_UIDGID;
    }
    if (attributes.containsKey(SshFile.Attribute.Permissions)) {
        flags |= SSH_FILEXFER_ATTR_PERMISSIONS;
    }
    if (attributes.containsKey(SshFile.Attribute.LastAccessTime) && attributes.containsKey(SshFile.Attribute.LastModifiedTime)) {
        flags |= SSH_FILEXFER_ATTR_ACMODTIME;
    }
    buffer.putInt(flags);
    if ((flags & SSH_FILEXFER_ATTR_SIZE) != 0) {
        buffer.putLong((Long) attributes.get(SshFile.Attribute.Size));
    }
    if ((flags & SSH_FILEXFER_ATTR_UIDGID) != 0) {
        buffer.putInt((Integer) attributes.get(SshFile.Attribute.Uid));
        buffer.putInt((Integer) attributes.get(SshFile.Attribute.Gid));
    }
    if ((flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0) {
        buffer.putInt(getPermissions(attributes));
    }
    if ((flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) {
        buffer.putInt(((Long) attributes.get(SshFile.Attribute.LastAccessTime)) / 1000);
        buffer.putInt(((Long) attributes.get(SshFile.Attribute.LastModifiedTime)) / 1000);
    }
    */
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:40,代码来源:SftpSubsystem.java


示例13: sendStatus

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void sendStatus(int id, int substatus, String msg, String lang) throws IOException {
    log.debug("Send SSH_FXP_STATUS (substatus={}, msg={})", substatus, msg);
    Buffer buffer = new Buffer();
    buffer.putByte((byte) SSH_FXP_STATUS);
    buffer.putInt(id);
    buffer.putInt(substatus);
    buffer.putString(msg);
    buffer.putString(lang);
    send(buffer);
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:11,代码来源:SftpSubsystem.java


示例14: doWriteData

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
@Override
protected void doWriteData(byte[] data, int off, int len) throws IOException {
    ioSession.write(new Buffer(data, off, len));
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:5,代码来源:TcpipServerChannel.java


示例15: TtyFilterInputStream

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
public TtyFilterInputStream(EnumSet<TtyOptions> ttyOptions, InputStream in) {
    super(in);
    buffer = new Buffer(32);
    this.ttyOptions = ttyOptions;
}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:6,代码来源:TtyFilterInputStream.java


示例16: run

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
public void run() {
	//System.out.println("check read ");
	
    try {
    	int avail = dis.available();
    	
    	if (avail == -1) {
    		this.close();
    		return;
    	}
    	
    	if (avail == 0) {
			this.requestInput();
    		return;
    	}
    	
    	if (avail < 9) {
            log.error("Exception caught in SFTP subsystem: Illegal Argument for command");
            this.close();
    			
    		return;
    	}
    	
        int length = dis.readInt();
        
        if (length < 5) 
            throw new IllegalArgumentException();
        
        Buffer buffer = new Buffer(length + 4);            
        buffer.putInt(length);            
        int nb = length;
        
        while (nb > 0) {
            int l = dis.read(buffer.array(), buffer.wpos(), nb);
            
            if (l < 0) 
                throw new IllegalArgumentException();
            
            buffer.wpos(buffer.wpos() + l);                
            nb -= l;
        }
        
        this.process(buffer);
    } 
    catch (Throwable t) {
        if (!this.closed && !(t instanceof EOFException))  // Ignore han
            log.error("Exception caught in SFTP subsystem", t);
        
    	this.close();
    } 
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:52,代码来源:SftpSubsystem.java


示例17: send

import org.apache.sshd.common.util.Buffer; //导入依赖的package包/类
protected void send(Buffer buffer) throws IOException {
    this.dos.writeInt(buffer.available());
    this.dos.write(buffer.array(), buffer.rpos(), buffer.available());
    this.dos.flush();
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:6,代码来源:SftpSubsystem.java



注:本文中的org.apache.sshd.common.util.Buffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityReferenceImpl类代码示例发布时间:2022-05-23
下一篇:
Java AbstractSEIModelImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap