Merge branch 'jetty-9.4.x'
This commit is contained in:
commit
7fb303a191
|
@ -43,6 +43,8 @@ import javax.security.auth.callback.UnsupportedCallbackException;
|
|||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import org.eclipse.jetty.jaas.callback.ObjectCallback;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.security.Credential;
|
||||
|
@ -687,38 +689,36 @@ public class LdapLoginModule extends AbstractLoginModule
|
|||
return env;
|
||||
}
|
||||
|
||||
public static String convertCredentialJettyToLdap(String encryptedPassword)
|
||||
{
|
||||
if ("MD5:".startsWith(encryptedPassword.toUpperCase(Locale.ENGLISH)))
|
||||
{
|
||||
return "{MD5}" + encryptedPassword.substring("MD5:".length(), encryptedPassword.length());
|
||||
}
|
||||
|
||||
if ("CRYPT:".startsWith(encryptedPassword.toUpperCase(Locale.ENGLISH)))
|
||||
{
|
||||
return "{CRYPT}" + encryptedPassword.substring("CRYPT:".length(), encryptedPassword.length());
|
||||
}
|
||||
|
||||
return encryptedPassword;
|
||||
}
|
||||
|
||||
public static String convertCredentialLdapToJetty(String encryptedPassword)
|
||||
{
|
||||
if (encryptedPassword == null)
|
||||
{
|
||||
return encryptedPassword;
|
||||
return null;
|
||||
}
|
||||
|
||||
if ("{MD5}".startsWith(encryptedPassword.toUpperCase(Locale.ENGLISH)))
|
||||
if (encryptedPassword.toUpperCase(Locale.ENGLISH).startsWith("{MD5}"))
|
||||
{
|
||||
return "MD5:" + encryptedPassword.substring("{MD5}".length(), encryptedPassword.length());
|
||||
String src = encryptedPassword.substring("{MD5}".length(), encryptedPassword.length());
|
||||
return "MD5:" + base64ToHex(src);
|
||||
}
|
||||
|
||||
if ("{CRYPT}".startsWith(encryptedPassword.toUpperCase(Locale.ENGLISH)))
|
||||
if (encryptedPassword.toUpperCase(Locale.ENGLISH).startsWith("{CRYPT}"))
|
||||
{
|
||||
return "CRYPT:" + encryptedPassword.substring("{CRYPT}".length(), encryptedPassword.length());
|
||||
}
|
||||
|
||||
return encryptedPassword;
|
||||
}
|
||||
|
||||
private static String base64ToHex(String src)
|
||||
{
|
||||
byte[] bytes = B64Code.decode(src);
|
||||
return TypeUtil.toString(bytes, 16);
|
||||
}
|
||||
|
||||
private static String hexToBase64(String src)
|
||||
{
|
||||
byte[] bytes = TypeUtil.fromHexString(src);
|
||||
return new String(B64Code.encode(bytes));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue