Added support for LDAP SSHA (salted SHA) encoded passwords.

This commit is contained in:
Luke Taylor
2006-04-16 21:12:39 +00:00
parent c6dd545de0
commit 7a0a87a167
2 changed files with 134 additions and 3 deletions

View File

@@ -0,0 +1,49 @@
/* Copyright 2004, 2005 Acegi Technology Pty Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.acegisecurity.providers.ldap.authenticator;
import junit.framework.TestCase;
/**
* Tests {@link LdapShaPasswordEncoder}.
*
* @author Luke Taylor
* @version $Id$
*/
public class LdapShaPasswordEncoderTests extends TestCase {
LdapShaPasswordEncoder sha;
protected void setUp() throws Exception {
super.setUp();
sha = new LdapShaPasswordEncoder();
}
/** Test values generated by 'slappasswd -h {SHA} -s boabspasswurd' */
public void testValidPasswordSucceeds() {
assertTrue(sha.isPasswordValid("{SHA}ddSFGmjXYPbZC+NXR2kCzBRjqiE=", "boabspasswurd", null));
}
/** Test values generated by 'slappasswd -s boabspasswurd' */
public void testValidSaltedPasswordSucceeds() {
assertTrue(sha.isPasswordValid("{SSHA}25ro4PKC8jhQZ26jVsozhX/xaP0suHgX", "boabspasswurd", null));
assertTrue(sha.isPasswordValid("{SSHA}PQy2j+6n5ytA+YlAKkM8Fh4p6u2JxfVd", "boabspasswurd", null));
}
public void testInvalidSaltedPasswordFails() {
assertFalse(sha.isPasswordValid("{SSHA}25ro4PKC8jhQZ26jVsozhX/xaP0suHgX", "wrongpassword", null));
assertFalse(sha.isPasswordValid("{SSHA}PQy2j+6n5ytA+YlAKkM8Fh4p6u2JxfVd", "wrongpassword", null));
}
}