User: starksm
Date: 02/02/06 12:01:59
Modified: src/main/org/jboss/security/auth/spi Tag: Branch_2_4
UsernamePasswordLoginModule.java
Log:
Move the password hash code to the org.jboss.security.Util class
Revision Changes Path
No revision
No revision
1.3.4.6 +5 -43
jbosssx/src/main/org/jboss/security/auth/spi/UsernamePasswordLoginModule.java
Index: UsernamePasswordLoginModule.java
===================================================================
RCS file:
/cvsroot/jboss/jbosssx/src/main/org/jboss/security/auth/spi/UsernamePasswordLoginModule.java,v
retrieving revision 1.3.4.5
retrieving revision 1.3.4.6
diff -u -r1.3.4.5 -r1.3.4.6
--- UsernamePasswordLoginModule.java 2001/12/29 04:32:21 1.3.4.5
+++ UsernamePasswordLoginModule.java 2002/02/06 20:01:59 1.3.4.6
@@ -42,13 +42,10 @@
* @see #getRoleSets()
@author [EMAIL PROTECTED]
- @version $Revision: 1.3.4.5 $
+ @version $Revision: 1.3.4.6 $
*/
public abstract class UsernamePasswordLoginModule extends AbstractServerLoginModule
{
- private static final String BASE64_ENCODING = "BASE64";
- private static final String BASE16_ENCODING = "HEX";
-
/** The login identity */
private Principal identity;
/** The proof of login identity */
@@ -89,7 +86,7 @@
{
hashEncoding = (String) options.get("hashEncoding");
if( hashEncoding == null )
- hashEncoding = BASE64_ENCODING;
+ hashEncoding = Util.BASE64_ENCODING;
hashCharset = (String) options.get("hashCharset");
if( log.isTraceEnabled() )
{
@@ -244,44 +241,8 @@
*/
protected String createPasswordHash(String username, String password)
{
- byte[] passBytes;
- String passwordHash = null;
-
- // convert password to byte data
- try
- {
- if(hashCharset == null)
- passBytes = password.getBytes();
- else
- passBytes = password.getBytes(hashCharset);
- }
- catch(UnsupportedEncodingException uee)
- {
- log.error("charset " + hashCharset + " not found. Using platform
default.", uee);
- passBytes = password.getBytes();
- }
-
- // calculate the hash and apply the encoding.
- try
- {
- byte[] hash = MessageDigest.getInstance(hashAlgorithm).digest(passBytes);
- if(hashEncoding.equalsIgnoreCase(BASE64_ENCODING))
- {
- passwordHash = Util.encodeBase64(hash);
- }
- else if(hashEncoding.equalsIgnoreCase(BASE16_ENCODING))
- {
- passwordHash = Util.encodeBase16(hash);
- }
- else
- {
- log.error("Unsupported hash encoding format " + hashEncoding);
- }
- }
- catch(Exception e)
- {
- log.error("Password hash calculation failed ", e);
- }
+ String passwordHash = Util.createPasswordHash(hashAlgorithm, hashEncoding,
+ hashCharset, username, password);
return passwordHash;
}
@@ -293,6 +254,7 @@
*/
protected boolean validatePassword(String inputPassword, String expectedPassword)
{
+System.out.println("validatePassword, inputPassword="+inputPassword+",
expectedPassword="+expectedPassword);
if( inputPassword == null || expectedPassword == null )
return false;
return inputPassword.equals(expectedPassword);
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development