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


Java Type3NTLMMessage类代码示例

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


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

示例1: validateLocalHashedPassword

import org.alfresco.jlan.server.auth.ntlm.Type3NTLMMessage; //导入依赖的package包/类
/**
 * Validate the MD4 hash against local password
 * 
 * @param type3Msg Type3NTLMMessage
 * @param ntlmDetails NTLMLogonDetails
 * @param authenticated boolean
 * @param md4hash String
 * 
 * @return true if password hash is valid, false otherwise
 */
protected boolean validateLocalHashedPassword(Type3NTLMMessage type3Msg, NTLMLogonDetails ntlmDetails, boolean authenticated, String md4hash)
{
	// Make sure we have hte cached NTLM details, including the type2 message with the server challenge
	
	if ( ntlmDetails == null || ntlmDetails.getType2Message() == null)
	{
		// DEBUG
		
		if ( getLogger().isDebugEnabled())
			getLogger().debug("No cached Type2, ntlmDetails=" + ntlmDetails);
		
		// Not authenticated
		
		return false;
	}
	
    //  Determine if the client sent us NTLMv1 or NTLMv2
    if (type3Msg.hasFlag(NTLM.FlagNTLM2Key))
    {
        //  Determine if the client sent us an NTLMv2 blob or an NTLMv2 session key
        if (type3Msg.getNTLMHashLength() > 24)
        {
            //  Looks like an NTLMv2 blob
            authenticated = checkNTLMv2(md4hash, ntlmDetails.getChallengeKey(), type3Msg);
            
            if (getLogger().isDebugEnabled())
                getLogger().debug((authenticated ? "Logged on" : "Logon failed") + " using NTLMSSP/NTLMv2");
            
            // If the NTlmv2 autentication failed then check if the client has sent an NTLMv1 hash
            
            if ( authenticated == false && type3Msg.hasFlag(NTLM.Flag56Bit) && type3Msg.getLMHashLength() == 24)
            {
        		// Check the LM hash field
        		
        		authenticated = checkNTLMv1(md4hash, ntlmDetails.getChallengeKey(), type3Msg, true);

        		// DEBUG
        		
                if (getLogger().isDebugEnabled())
                    getLogger().debug((authenticated ? "Logged on" : "Logon failed") + " using NTLMSSP/NTLMv1 (via fallback)");
            }
        }
        else
        {
            //  Looks like an NTLMv2 session key
            authenticated = checkNTLMv2SessionKey(md4hash, ntlmDetails.getChallengeKey(), type3Msg);
            
            if (getLogger().isDebugEnabled())
                getLogger().debug((authenticated ? "Logged on" : "Logon failed") + " using NTLMSSP/NTLMv2SessKey");
        }
    }
    else
    {
        //  Looks like an NTLMv1 blob
        authenticated = checkNTLMv1(md4hash, ntlmDetails.getChallengeKey(), type3Msg, false);
        
        if (getLogger().isDebugEnabled())
            getLogger().debug((authenticated ? "Logged on" : "Logon failed") + " using NTLMSSP/NTLMv1");
    }
    return authenticated;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:72,代码来源:BaseNTLMAuthenticationFilter.java

示例2: checkNTLMv1

import org.alfresco.jlan.server.auth.ntlm.Type3NTLMMessage; //导入依赖的package包/类
/**
 * Perform an NTLMv1 hashed password check
 * 
 * @param md4hash String
 * @param challenge byte[]
 * @param type3Msg Type3NTLMMessage
 * @param checkLMHash boolean
 * @return boolean
 */
protected final boolean checkNTLMv1(String md4hash, byte[] challenge, Type3NTLMMessage type3Msg, boolean checkLMHash)
{
    if (getLogger().isDebugEnabled())
        getLogger().debug(("Perform an NTLMv1 hashed password check."));
    
    // Generate the local encrypted password using the challenge that was sent to the client
    byte[] p21 = new byte[21];
    byte[] md4byts = m_md4Encoder.decodeHash(md4hash);
    System.arraycopy(md4byts, 0, p21, 0, 16);

    // Generate the local hash of the password using the same challenge
    byte[] localHash = null;

    try
    {
        localHash = m_encryptor.doNTLM1Encryption(p21, challenge);
    }
    catch (NoSuchAlgorithmException ex)
    {
    }

    // Validate the password
    byte[] clientHash = checkLMHash ? type3Msg.getLMHash() : type3Msg.getNTLMHash();

    if (clientHash != null && localHash != null && clientHash.length == localHash.length)
    {
        int i = 0;

        while (i < clientHash.length && clientHash[i] == localHash[i])
        {
            i++;
        }

        if (i == clientHash.length)
        {
            if (getLogger().isDebugEnabled())
                getLogger().debug(("Hashed passwords match."));
            return true;
        }
    }

    if (getLogger().isDebugEnabled())
        getLogger().debug(("Hashed passwords do not match."));
    return false;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:55,代码来源:BaseNTLMAuthenticationFilter.java


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