mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
Updates to NTLM authentication component/provider to line up with new password encryptor code.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2762 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 Alfresco, Inc.
|
* Copyright (C) 2005-2006 Alfresco, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
* with a permitted attribution clause. You may obtain a
|
* with a permitted attribution clause. You may obtain a
|
||||||
@@ -24,6 +24,16 @@ import java.io.PrintStream;
|
|||||||
public final class HexDump
|
public final class HexDump
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hex dump a byte array
|
||||||
|
*
|
||||||
|
* @param byt Byte array to dump
|
||||||
|
*/
|
||||||
|
public static final void Dump(byte[] byt)
|
||||||
|
{
|
||||||
|
Dump(byt, byt.length, 0, System.out);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hex dump a byte array
|
* Hex dump a byte array
|
||||||
*
|
*
|
||||||
@@ -31,7 +41,6 @@ public final class HexDump
|
|||||||
* @param len Length of data to dump
|
* @param len Length of data to dump
|
||||||
* @param offset Offset to start data dump
|
* @param offset Offset to start data dump
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final void Dump(byte[] byt, int len, int offset)
|
public static final void Dump(byte[] byt, int len, int offset)
|
||||||
{
|
{
|
||||||
Dump(byt, len, offset, System.out);
|
Dump(byt, len, offset, System.out);
|
||||||
@@ -51,8 +60,8 @@ public final class HexDump
|
|||||||
|
|
||||||
// Create buffers for the ASCII and Hex output
|
// Create buffers for the ASCII and Hex output
|
||||||
|
|
||||||
StringBuffer ascBuf = new StringBuffer();
|
StringBuilder ascBuf = new StringBuilder();
|
||||||
StringBuffer hexBuf = new StringBuffer();
|
StringBuilder hexBuf = new StringBuilder();
|
||||||
|
|
||||||
// Dump 16 byte blocks from the array until the length has been
|
// Dump 16 byte blocks from the array until the length has been
|
||||||
// reached
|
// reached
|
||||||
@@ -122,7 +131,7 @@ public final class HexDump
|
|||||||
*/
|
*/
|
||||||
public static final String hexString(byte[] buf)
|
public static final String hexString(byte[] buf)
|
||||||
{
|
{
|
||||||
return hexString(buf, buf.length, null);
|
return hexString(buf, 0, buf.length, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,18 +143,19 @@ public final class HexDump
|
|||||||
*/
|
*/
|
||||||
public static final String hexString(byte[] buf, String gap)
|
public static final String hexString(byte[] buf, String gap)
|
||||||
{
|
{
|
||||||
return hexString(buf, buf.length, gap);
|
return hexString(buf, 0, buf.length, gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a hex string for the specified bytes
|
* Generate a hex string for the specified bytes
|
||||||
*
|
*
|
||||||
* @param buf byte[]
|
* @param buf byte[]
|
||||||
|
* @param off int
|
||||||
* @param len int
|
* @param len int
|
||||||
* @param gap String
|
* @param gap String
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static final String hexString(byte[] buf, int len, String gap)
|
public static final String hexString(byte[] buf, int off, int len, String gap)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check if the buffer is valid
|
// Check if the buffer is valid
|
||||||
@@ -155,11 +165,11 @@ public final class HexDump
|
|||||||
|
|
||||||
// Create a string buffer for the hex string
|
// Create a string buffer for the hex string
|
||||||
|
|
||||||
int buflen = buf.length * 2;
|
int buflen = (buf.length - off) * 2;
|
||||||
if (gap != null)
|
if (gap != null)
|
||||||
buflen += buf.length * gap.length();
|
buflen += buf.length * gap.length();
|
||||||
|
|
||||||
StringBuffer hex = new StringBuffer(buflen);
|
StringBuilder hex = new StringBuilder(buflen);
|
||||||
|
|
||||||
// Convert the bytes to hex-ASCII
|
// Convert the bytes to hex-ASCII
|
||||||
|
|
||||||
@@ -168,7 +178,7 @@ public final class HexDump
|
|||||||
|
|
||||||
// Get the current byte
|
// Get the current byte
|
||||||
|
|
||||||
int curbyt = (int) (buf[i] & 0x00FF);
|
int curbyt = (int) (buf[off + i] & 0x00FF);
|
||||||
|
|
||||||
// Output the hex string
|
// Output the hex string
|
||||||
|
|
||||||
@@ -197,7 +207,7 @@ public final class HexDump
|
|||||||
|
|
||||||
// Create a buffer position string
|
// Create a buffer position string
|
||||||
|
|
||||||
StringBuffer posStr = new StringBuffer("" + off + " - ");
|
StringBuilder posStr = new StringBuilder("" + off + " - ");
|
||||||
while (posStr.length() < 8)
|
while (posStr.length() < 8)
|
||||||
posStr.insert(0, " ");
|
posStr.insert(0, " ");
|
||||||
|
|
||||||
@@ -216,7 +226,7 @@ public final class HexDump
|
|||||||
* @return New offset value
|
* @return New offset value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static final int generateLine(byte[] byt, int off, StringBuffer ascBuf, StringBuffer hexBuf)
|
private static final int generateLine(byte[] byt, int off, StringBuilder ascBuf, StringBuilder hexBuf)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check if there is enough buffer space to dump 16 bytes
|
// Check if there is enough buffer space to dump 16 bytes
|
||||||
|
@@ -19,6 +19,7 @@ package org.alfresco.repo.security.authentication.ntlm;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
@@ -599,7 +600,7 @@ public class NTLMAuthenticationComponentImpl extends AbstractAuthenticationCompo
|
|||||||
|
|
||||||
String username = (String) ntlmToken.getPrincipal();
|
String username = (String) ntlmToken.getPrincipal();
|
||||||
String plainPwd = (String) ntlmToken.getCredentials();
|
String plainPwd = (String) ntlmToken.getCredentials();
|
||||||
byte[] ntlm1Pwd = m_encryptor.generateEncryptedPassword( plainPwd, authSess.getEncryptionKey(), PasswordEncryptor.NTLM1);
|
byte[] ntlm1Pwd = m_encryptor.generateEncryptedPassword( plainPwd, authSess.getEncryptionKey(), PasswordEncryptor.NTLM1, null, null);
|
||||||
|
|
||||||
// Send the logon request to the authentication server
|
// Send the logon request to the authentication server
|
||||||
//
|
//
|
||||||
@@ -684,6 +685,12 @@ public class NTLMAuthenticationComponentImpl extends AbstractAuthenticationCompo
|
|||||||
|
|
||||||
throw new AuthenticationServiceException("JCE provider error", ex);
|
throw new AuthenticationServiceException("JCE provider error", ex);
|
||||||
}
|
}
|
||||||
|
catch (InvalidKeyException ex)
|
||||||
|
{
|
||||||
|
// Problem creating key during encryption
|
||||||
|
|
||||||
|
throw new AuthenticationServiceException("Invalid key error", ex);
|
||||||
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
// Error connecting to the authentication server
|
// Error connecting to the authentication server
|
||||||
|
@@ -19,6 +19,7 @@ package org.alfresco.repo.security.authentication.ntlm;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
@@ -519,7 +520,7 @@ public class NTLMAuthenticationProvider implements AuthenticationProvider
|
|||||||
|
|
||||||
String username = (String) ntlmToken.getPrincipal();
|
String username = (String) ntlmToken.getPrincipal();
|
||||||
String plainPwd = (String) ntlmToken.getCredentials();
|
String plainPwd = (String) ntlmToken.getCredentials();
|
||||||
byte[] ntlm1Pwd = m_encryptor.generateEncryptedPassword( plainPwd, authSess.getEncryptionKey(), PasswordEncryptor.NTLM1);
|
byte[] ntlm1Pwd = m_encryptor.generateEncryptedPassword( plainPwd, authSess.getEncryptionKey(), PasswordEncryptor.NTLM1, null, null);
|
||||||
|
|
||||||
// Send the logon request to the authentication server
|
// Send the logon request to the authentication server
|
||||||
//
|
//
|
||||||
@@ -560,6 +561,12 @@ public class NTLMAuthenticationProvider implements AuthenticationProvider
|
|||||||
|
|
||||||
throw new AuthenticationServiceException("JCE provider error", ex);
|
throw new AuthenticationServiceException("JCE provider error", ex);
|
||||||
}
|
}
|
||||||
|
catch (InvalidKeyException ex)
|
||||||
|
{
|
||||||
|
// Problem creating key during encryption
|
||||||
|
|
||||||
|
throw new AuthenticationServiceException("Invalid key error", ex);
|
||||||
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
// Error connecting to the authentication server
|
// Error connecting to the authentication server
|
||||||
|
Reference in New Issue
Block a user