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

Java Encdec类代码示例

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

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



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

示例1: writeUTF

import jcifs.util.Encdec; //导入依赖的package包/类
public final void writeUTF( String str ) throws SmbException {
    int len = str.length();
    int ch, size = 0;
    byte[] dst;

    for( int i = 0; i < len; i++ ) {
        ch = str.charAt( i );
        size += ch > 0x07F ? (ch > 0x7FF ? 3 : 2) : 1;
    }
    dst = new byte[size];
    writeShort( size );
    try {
        Encdec.enc_utf8( str, dst, 0, size );
    } catch( IOException ioe ) {
        throw new SmbException( "", ioe );
    }
    write( dst, 0, size );
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:19,代码来源:SmbRandomAccessFile.java


示例2: getNtlmsspListItem

import jcifs.util.Encdec; //导入依赖的package包/类
private String getNtlmsspListItem(byte[] type2token, int id0)
{
    int ri = 58;

    for ( ;; ) {
        int id = Encdec.dec_uint16le(type2token, ri);
        int len = Encdec.dec_uint16le(type2token, ri + 2);
        ri += 4;
        if (id == 0 || (ri + len) > type2token.length) {
            break;
        } else if (id == id0) {
            try {
                return new String(type2token, ri, len, SmbConstants.UNI_ENCODING);
            } catch (java.io.UnsupportedEncodingException uee) {
                break;
            }
        }
        ri += len;
    }

    return null;
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:23,代码来源:NtlmContext.java


示例3: enc_ndr_string

import jcifs.util.Encdec; //导入依赖的package包/类
public void enc_ndr_string(String s) {
    align(4);
    int i = index;
    int len = s.length();
    Encdec.enc_uint32le(len + 1, buf, i); i += 4;
    Encdec.enc_uint32le(0, buf, i); i += 4;
    Encdec.enc_uint32le(len + 1, buf, i); i += 4;
    try {
        System.arraycopy(s.getBytes("UTF-16LE"), 0, buf, i, len * 2);
    } catch( UnsupportedEncodingException uee ) {
    }
    i += len * 2;
    buf[i++] = (byte)'\0';
    buf[i++] = (byte)'\0';
    advance(i - index);
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:17,代码来源:NdrBuffer.java


示例4: doSend

import jcifs.util.Encdec; //导入依赖的package包/类
protected void doSend( Request request ) throws IOException {
    synchronized (BUF) {
        ServerMessageBlock smb = (ServerMessageBlock)request;
        int n = smb.encode( BUF, 4 );
        Encdec.enc_uint32be( n & 0xFFFF, BUF, 0 ); /* 4 byte session message header */
        if (log.level >= 4) {
            do {
                log.println( smb );
            } while (smb instanceof AndXServerMessageBlock &&
                    (smb = ((AndXServerMessageBlock)smb).andx) != null);
            if (log.level >= 6) {
                Hexdump.hexdump( log, BUF, 4, n );
            }
        }
        /* For some reason this can sometimes get broken up into another
         * "NBSS Continuation Message" frame according to WireShark
         */
        out.write( BUF, 0, 4 + n );
    }
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:21,代码来源:SmbTransport.java


示例5: dec_ndr_string

import jcifs.util.Encdec; //导入依赖的package包/类
public String dec_ndr_string() throws NdrException {
    align(4);
    int i = index;
    String val = null;
    int len = Encdec.dec_uint32le(buf, i);
    i += 12;
    if (len != 0) {
        len--;
        int size = len * 2;
        try {
            if (size < 0 || size > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE );
            val = new String(buf, i, size, "UTF-16LE");
            i += size + 2;
        } catch( UnsupportedEncodingException uee ) {
        }
    }
    advance(i - index);
    return val;
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:20,代码来源:NdrBuffer.java


示例6: negotiateWrite

import jcifs.util.Encdec; //导入依赖的package包/类
/**
 * @return
 * @throws IOException
 */
private int negotiateWrite ( CommonServerMessageBlockRequest req, boolean setmid ) throws IOException {
    if ( setmid ) {
        makeKey(req);
    }
    else {
        req.setMid(0);
        this.mid.set(1);
    }
    int n = req.encode(this.sbuf, 4);
    Encdec.enc_uint32be(n & 0xFFFF, this.sbuf, 0); /* 4 byte ssn msg header */

    if ( log.isTraceEnabled() ) {
        log.trace(req.toString());
        log.trace(Hexdump.toHexString(this.sbuf, 4, n));
    }

    this.out.write(this.sbuf, 0, 4 + n);
    this.out.flush();
    log.trace("Wrote negotiate request");
    return n;
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:26,代码来源:SmbTransportImpl.java


示例7: negotiatePeek

import jcifs.util.Encdec; //导入依赖的package包/类
/**
 * @throws SocketException
 * @throws IOException
 */
private void negotiatePeek () throws SocketException, IOException {
    /*
     * Note the Transport thread isn't running yet so we can
     * read from the socket here.
     */
    try {
        this.socket.setSoTimeout(this.transportContext.getConfig().getConnTimeout());
        if ( peekKey() == null ) /* try to read header */
            throw new IOException("transport closed in negotiate");
    }
    finally {
        this.socket.setSoTimeout(this.transportContext.getConfig().getSoTimeout());
    }
    int size = Encdec.dec_uint16be(this.sbuf, 2) & 0xFFFF;
    if ( size < 33 || ( 4 + size ) > this.sbuf.length ) {
        throw new IOException("Invalid payload size: " + size);
    }
    int hdrSize = this.smb2 ? Smb2Constants.SMB2_HEADER_LENGTH : SMB1_HEADER_LENGTH;
    readn(this.in, this.sbuf, 4 + hdrSize, size - hdrSize);
    log.trace("Read negotiate response");
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:26,代码来源:SmbTransportImpl.java


示例8: doSkip

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
protected void doSkip ( Long key ) throws IOException {
    synchronized ( this.inLock ) {
        int size = Encdec.dec_uint16be(this.sbuf, 2) & 0xFFFF;
        if ( size < 33 || ( 4 + size ) > this.getContext().getConfig().getRecieveBufferSize() ) {
            /* log message? */
            log.warn("Flusing stream input");
            this.in.skip(this.in.available());
        }
        else {
            Response notification = createNotification(key);
            if ( notification != null ) {
                log.debug("Parsing notification");
                doRecv(notification);
                handleNotification(notification);
                return;
            }
            log.warn("Skipping message " + key);
            this.in.skip(size - 32);
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:23,代码来源:SmbTransportImpl.java


示例9: getNTLMv2Response

import jcifs.util.Encdec; //导入依赖的package包/类
/**
 * 
 * @param responseKeyNT
 * @param serverChallenge
 * @param clientChallenge
 * @param nanos1601
 * @param avPairs
 * @return the calculated response
 */
public static byte[] getNTLMv2Response ( byte[] responseKeyNT, byte[] serverChallenge, byte[] clientChallenge, long nanos1601, byte[] avPairs ) {
    int avPairsLength = avPairs != null ? avPairs.length : 0;
    byte[] temp = new byte[28 + avPairsLength + 4];

    Encdec.enc_uint32le(0x00000101, temp, 0); // Header
    Encdec.enc_uint32le(0x00000000, temp, 4); // Reserved
    Encdec.enc_uint64le(nanos1601, temp, 8);
    System.arraycopy(clientChallenge, 0, temp, 16, 8);
    Encdec.enc_uint32le(0x00000000, temp, 24); // Unknown
    if ( avPairs != null )
        System.arraycopy(avPairs, 0, temp, 28, avPairsLength);
    Encdec.enc_uint32le(0x00000000, temp, 28 + avPairsLength); // mystery bytes!

    return NtlmUtil.computeResponse(responseKeyNT, serverChallenge, temp, 0, temp.length);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:25,代码来源:NtlmUtil.java


示例10: enc_ndr_string

import jcifs.util.Encdec; //导入依赖的package包/类
public void enc_ndr_string ( String s ) {
    align(4);
    int i = this.index;
    int len = s.length();
    Encdec.enc_uint32le(len + 1, this.buf, i);
    i += 4;
    Encdec.enc_uint32le(0, this.buf, i);
    i += 4;
    Encdec.enc_uint32le(len + 1, this.buf, i);
    i += 4;
    System.arraycopy(Strings.getUNIBytes(s), 0, this.buf, i, len * 2);
    i += len * 2;
    this.buf[ i++ ] = (byte) '\0';
    this.buf[ i++ ] = (byte) '\0';
    advance(i - this.index);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:17,代码来源:NdrBuffer.java


示例11: dec_ndr_string

import jcifs.util.Encdec; //导入依赖的package包/类
public String dec_ndr_string () throws NdrException {
    align(4);
    int i = this.index;
    String val = null;
    int len = Encdec.dec_uint32le(this.buf, i);
    i += 12;
    if ( len != 0 ) {
        len--;
        int size = len * 2;
        if ( size < 0 || size > 0xFFFF )
            throw new NdrException(NdrException.INVALID_CONFORMANCE);
        val = Strings.fromUNIBytes(this.buf, i, size);
        i += size + 2;
    }
    advance(i - this.index);
    return val;
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:18,代码来源:NdrBuffer.java


示例12: readUTF

import jcifs.util.Encdec; //导入依赖的package包/类
public final String readUTF() throws SmbException {
    int size = readUnsignedShort();
    byte[] b = new byte[size];
    read( b, 0, size );
    try {
        return Encdec.dec_utf8( b, 0, size );
    } catch( IOException ioe ) {
        throw new SmbException( "", ioe );
    }
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:11,代码来源:SmbRandomAccessFile.java


示例13: doSkip

import jcifs.util.Encdec; //导入依赖的package包/类
protected void doSkip() throws IOException {
    int size = Encdec.dec_uint16be( sbuf, 2 ) & 0xFFFF;
    if (size < 33 || (4 + size) > rcv_buf_size ) {
        /* log message? */
        in.skip( in.available() );
    } else {
        in.skip( size - 32 );
    }
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:10,代码来源:SmbTransport.java


示例14: doReceiveFragment

import jcifs.util.Encdec; //导入依赖的package包/类
protected void doReceiveFragment(byte[] buf, boolean isDirect) throws IOException {
    int off, flags, length;

    if (buf.length < max_recv)
        throw new IllegalArgumentException("buffer too small");

    if (isStart && !isDirect) { // start of new frag, do trans
        off = in.read(buf, 0, 1024);
    } else {
        off = in.readDirect(buf, 0, buf.length);
    }

    if (buf[0] != 5 && buf[1] != 0)
        throw new IOException("Unexpected DCERPC PDU header");

    flags = buf[3] & 0xFF;
    // next read is start of new frag
    isStart = (flags & DCERPC_LAST_FRAG) == DCERPC_LAST_FRAG;

    length = Encdec.dec_uint16le(buf, 8);
    if (length > max_recv)
        throw new IOException("Unexpected fragment length: " + length);

    while (off < length) {
        off += in.readDirect(buf, off, length - off);
    }
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:28,代码来源:DcerpcPipeHandle.java


示例15: readShort

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
public final short readShort () throws SmbException {
    if ( ( read(this.tmp, 0, 2) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_uint16be(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java


示例16: readUnsignedShort

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
public final int readUnsignedShort () throws SmbException {
    if ( ( read(this.tmp, 0, 2) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_uint16be(this.tmp, 0) & 0xFFFF;
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java


示例17: readChar

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
public final char readChar () throws SmbException {
    if ( ( read(this.tmp, 0, 2) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return (char) Encdec.dec_uint16be(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java


示例18: readInt

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
public final int readInt () throws SmbException {
    if ( ( read(this.tmp, 0, 4) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_uint32be(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java


示例19: readLong

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
public final long readLong () throws SmbException {
    if ( ( read(this.tmp, 0, 8) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_uint64be(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java


示例20: readFloat

import jcifs.util.Encdec; //导入依赖的package包/类
@Override
public final float readFloat () throws SmbException {
    if ( ( read(this.tmp, 0, 4) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_floatbe(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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