当前位置: 首页>>代码示例>>Java>>正文


Java NtlmFlags类代码示例

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


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

示例1: NtlmContext

import jcifs.ntlmssp.NtlmFlags; //导入依赖的package包/类
/**
 * @param tc
 *            context to use
 * @param auth
 *            credentials
 * @param doSigning
 *            whether signing is requested
 */
public NtlmContext ( CIFSContext tc, NtlmPasswordAuthentication auth, boolean doSigning ) {
    this.transportContext = tc;
    this.auth = auth;
    this.ntlmsspFlags = this.ntlmsspFlags | NtlmFlags.NTLMSSP_REQUEST_TARGET | NtlmFlags.NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
            | NtlmFlags.NTLMSSP_NEGOTIATE_128;
    if ( !auth.isAnonymous() ) {
        this.ntlmsspFlags |= NtlmFlags.NTLMSSP_NEGOTIATE_SIGN | NtlmFlags.NTLMSSP_NEGOTIATE_SEAL | NtlmFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN
                | NtlmFlags.NTLMSSP_NEGOTIATE_KEY_EXCH;
    }
    else {
        this.ntlmsspFlags |= NtlmFlags.NTLMSSP_NEGOTIATE_ANONYMOUS;
    }
    this.requireKeyExchange = doSigning;
    this.workstation = tc.getNameServiceClient().getLocalHost().getHostName();
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:24,代码来源:NtlmContext.java

示例2: generateType3Msg

import jcifs.ntlmssp.NtlmFlags; //导入依赖的package包/类
private String generateType3Msg(String username, String password,
             String host, String domain, String challenge) {
       jcifs.ntlmssp.Type2Message t2m;
       try {
             t2m = new jcifs.ntlmssp.Type2Message(
                           jcifs.util.Base64.decode(challenge));
       } catch (IOException e) {
             throw new RuntimeException("Invalid Type2 message", e);
       }

       final int type2Flags = t2m.getFlags();
       final int type3Flags = type2Flags
                    & (0xffffffff ^ (NtlmFlags.NTLMSSP_TARGET_TYPE_DOMAIN | NtlmFlags.NTLMSSP_TARGET_TYPE_SERVER));

       jcifs.ntlmssp.Type3Message t3m = new jcifs.ntlmssp.Type3Message(
                    t2m, password, domain, username, host, type3Flags);
       return jcifs.util.Base64.encode(t3m.toByteArray());
}
 
开发者ID:sheymans,项目名称:todopl,代码行数:19,代码来源:EwsJCIFSNTLMScheme.java

示例3: calculateMIC

import jcifs.ntlmssp.NtlmFlags; //导入依赖的package包/类
@Override
public byte[] calculateMIC ( byte[] data ) throws CIFSException {
    byte[] sk = this.signKey;
    if ( sk == null ) {
        throw new CIFSException("Signing is not initialized");
    }

    int seqNum = this.signSequence.getAndIncrement();
    byte[] seqBytes = new byte[4];
    SMBUtil.writeInt4(seqNum, seqBytes, 0);

    MessageDigest mac = Crypto.getHMACT64(sk);
    mac.update(seqBytes); // sequence
    mac.update(data); // data
    byte[] dgst = mac.digest();
    byte[] trunc = new byte[8];
    System.arraycopy(dgst, 0, trunc, 0, 8);

    if ( log.isDebugEnabled() ) {
        log.debug("Digest " + Hexdump.toHexString(dgst));
        log.debug("Truncated " + Hexdump.toHexString(trunc));
    }

    if ( ( this.ntlmsspFlags & NtlmFlags.NTLMSSP_NEGOTIATE_KEY_EXCH ) != 0 ) {
        try {
            trunc = this.sealClientHandle.doFinal(trunc);
            if ( log.isDebugEnabled() ) {
                log.debug("Encrypted " + Hexdump.toHexString(trunc));
            }
        }
        catch ( GeneralSecurityException e ) {
            throw new CIFSException("Failed to encrypt MIC", e);
        }
    }

    byte[] sig = new byte[16];
    SMBUtil.writeInt4(1, sig, 0); // version
    System.arraycopy(trunc, 0, sig, 4, 8); // checksum
    SMBUtil.writeInt4(seqNum, sig, 12); // seqNum

    return sig;
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:43,代码来源:NtlmContext.java

示例4: verifyMIC

import jcifs.ntlmssp.NtlmFlags; //导入依赖的package包/类
@Override
public void verifyMIC ( byte[] data, byte[] mic ) throws CIFSException {
    byte[] sk = this.verifyKey;
    if ( sk == null ) {
        throw new CIFSException("Signing is not initialized");
    }

    int ver = SMBUtil.readInt4(mic, 0);
    if ( ver != 1 ) {
        throw new SmbUnsupportedOperationException("Invalid signature version");
    }

    MessageDigest mac = Crypto.getHMACT64(sk);
    int seq = SMBUtil.readInt4(mic, 12);
    mac.update(mic, 12, 4); // sequence
    byte[] dgst = mac.digest(data); // data
    byte[] trunc = Arrays.copyOf(dgst, 8);

    if ( log.isDebugEnabled() ) {
        log.debug("Digest " + Hexdump.toHexString(dgst));
        log.debug("Truncated " + Hexdump.toHexString(trunc));
    }

    boolean encrypted = ( this.ntlmsspFlags & NtlmFlags.NTLMSSP_NEGOTIATE_KEY_EXCH ) != 0;
    if ( encrypted ) {
        try {
            trunc = this.sealServerHandle.doFinal(trunc);
            if ( log.isDebugEnabled() ) {
                log.debug("Decrypted " + Hexdump.toHexString(trunc));
            }
        }
        catch ( GeneralSecurityException e ) {
            throw new CIFSException("Failed to decrypt MIC", e);
        }
    }

    int expectSeq = this.verifySequence.getAndIncrement();
    if ( expectSeq != seq ) {
        throw new CIFSException(String.format("Invalid MIC sequence, expect %d have %d", expectSeq, seq));
    }

    byte[] verify = new byte[8];
    System.arraycopy(mic, 4, verify, 0, 8);
    if ( !MessageDigest.isEqual(trunc, verify) ) {
        if ( log.isDebugEnabled() ) {
            log.debug(String.format("Seq = %d ver = %d encrypted = %s", seq, ver, encrypted));
            log.debug(String.format("Expected MIC %s != %s", Hexdump.toHexString(trunc), Hexdump.toHexString(verify)));
        }
        throw new CIFSException("Invalid MIC");
    }

}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:53,代码来源:NtlmContext.java


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