[Beepcore-java-commits] CVS: beepcore-java/src/org/beepcore/beep/profile/sasl/otp SASLOTPProfile.jav
Status: Beta
Brought to you by:
huston
|
From: Huston F. <hu...@us...> - 2003-04-23 15:23:38
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp
In directory sc8-pr-cvs1:/tmp/cvs-serv31233/src/org/beepcore/beep/profile/sasl/otp
Modified Files:
SASLOTPProfile.java OTPAuthenticator.java OTPGenerator.java
Log Message:
cleanup of imports
Index: SASLOTPProfile.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/SASLOTPProfile.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** SASLOTPProfile.java 5 Oct 2002 15:32:06 -0000 1.9
--- SASLOTPProfile.java 23 Apr 2003 15:23:03 -0000 1.10
***************
*** 17,27 ****
package org.beepcore.beep.profile.sasl.otp;
- import java.security.MessageDigest;
-
import java.util.Hashtable;
- import java.util.StringTokenizer;
-
- import sun.misc.BASE64Decoder;
- import sun.misc.BASE64Encoder;
import org.apache.commons.logging.Log;
--- 17,21 ----
***************
*** 35,39 ****
import org.beepcore.beep.profile.sasl.otp.algorithm.sha1.SHA1;
import org.beepcore.beep.profile.sasl.otp.database.*;
- import org.beepcore.beep.transport.tcp.*;
--- 29,32 ----
***************
*** 101,106 ****
algorithms = new Hashtable();
! algorithms.put(md5.getAlgorithmName(), md5);
! algorithms.put(sha1.getAlgorithmName(), sha1);
userDatabase = new UserDatabasePool();
}
--- 94,99 ----
algorithms = new Hashtable();
! algorithms.put(MD5.getAlgorithmName(), md5);
! algorithms.put(SHA1.getAlgorithmName(), sha1);
userDatabase = new UserDatabasePool();
}
Index: OTPAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/OTPAuthenticator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** OTPAuthenticator.java 5 Oct 2002 15:32:06 -0000 1.12
--- OTPAuthenticator.java 23 Apr 2003 15:23:03 -0000 1.13
***************
*** 20,24 ****
import java.io.InputStream;
import java.io.IOException;
- import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
--- 20,23 ----
***************
*** 31,38 ****
import org.beepcore.beep.profile.sasl.*;
import org.beepcore.beep.profile.sasl.otp.algorithm.*;
- import org.beepcore.beep.profile.sasl.otp.algorithm.md5.*;
- import org.beepcore.beep.profile.sasl.otp.algorithm.sha1.*;
import org.beepcore.beep.profile.sasl.otp.database.UserDatabase;
- import org.beepcore.beep.profile.sasl.otp.database.*;
/**
--- 30,34 ----
***************
*** 203,208 ****
try
{
! database = profile.getUserDatabase().getUser(authenticated);
! algorithm = profile.getAlgorithm(database.getAlgorithmName());
}
catch(SASLException x)
--- 199,204 ----
try
{
! database = SASLOTPProfile.getUserDatabase().getUser(authenticated);
! algorithm = SASLOTPProfile.getAlgorithm(database.getAlgorithmName());
}
catch(SASLException x)
***************
*** 292,297 ****
// get the last hash and that's how we verify. Semi-slick.
// So hooray for assymetric hash functions
! if (response.indexOf(profile.HEX_INIT) != -1 ||
! response.indexOf(profile.WORD_INIT) != -1 )
{
return validateInitResponse(response);
--- 288,293 ----
// get the last hash and that's how we verify. Semi-slick.
// So hooray for assymetric hash functions
! if (response.indexOf(SASLOTPProfile.HEX_INIT) != -1 ||
! response.indexOf(SASLOTPProfile.WORD_INIT) != -1 )
{
return validateInitResponse(response);
***************
*** 302,306 ****
response = response.substring(WORD.length());
long l = OTPDictionary.convertWordsToHash(response);
! responseHash = profile.convertLongToBytes(l);
if (log.isDebugEnabled()) {
log.debug("Hacked response=>" + response);
--- 298,302 ----
response = response.substring(WORD.length());
long l = OTPDictionary.convertWordsToHash(response);
! responseHash = SASLOTPProfile.convertLongToBytes(l);
if (log.isDebugEnabled()) {
log.debug("Hacked response=>" + response);
***************
*** 308,312 ****
} else if (response.indexOf(HEX) != -1) {
response = response.substring(HEX.length());
! responseHash = profile.convertHexToBytes(response);
if (log.isDebugEnabled()) {
log.debug("Hacked response=>" + response);
--- 304,308 ----
} else if (response.indexOf(HEX) != -1) {
response = response.substring(HEX.length());
! responseHash = SASLOTPProfile.convertHexToBytes(response);
if (log.isDebugEnabled()) {
log.debug("Hacked response=>" + response);
***************
*** 321,326 ****
SessionCredential cred = validateHash(responseHash);
! database.updateLastHash(profile.convertBytesToHex(responseHash));
! profile.getUserDatabase().updateUserDB(database);
return cred;
}
--- 317,322 ----
SessionCredential cred = validateHash(responseHash);
! database.updateLastHash(SASLOTPProfile.convertBytesToHex(responseHash));
! SASLOTPProfile.getUserDatabase().updateUserDB(database);
return cred;
}
***************
*** 337,342 ****
byte responseHash[] = algorithm.generateHash(hash);
if (log.isTraceEnabled()) {
! log.trace("Test====>"+profile.convertBytesToHex(responseHash));
! log.trace("Control=>"+profile.convertBytesToHex(nextHash));
}
boolean match = true;
--- 333,338 ----
byte responseHash[] = algorithm.generateHash(hash);
if (log.isTraceEnabled()) {
! log.trace("Test====>"+SASLOTPProfile.convertBytesToHex(responseHash));
! log.trace("Control=>"+SASLOTPProfile.convertBytesToHex(nextHash));
}
boolean match = true;
***************
*** 384,396 ****
// Validate login
! Algorithm a = profile.getAlgorithm(database.getAlgorithmName());
! if(profile.HEX_INIT.startsWith(command)) {
! log.debug("CMD is "+profile.HEX_INIT);
! oldHash = profile.convertHexToBytes(oldHashData);
! } else if(profile.WORD_INIT.startsWith(command)) {
! log.debug("CMD is "+profile.WORD_INIT);
// @todo obviate the 2nd step when you get a chance
long l = OTPDictionary.convertWordsToHash(oldHashData);
! oldHash = profile.convertLongToBytes(l);
} else {
abort(ERR_UNKNOWN_COMMAND+command);
--- 380,392 ----
// Validate login
! Algorithm a = SASLOTPProfile.getAlgorithm(database.getAlgorithmName());
! if(SASLOTPProfile.HEX_INIT.startsWith(command)) {
! log.debug("CMD is "+SASLOTPProfile.HEX_INIT);
! oldHash = SASLOTPProfile.convertHexToBytes(oldHashData);
! } else if(SASLOTPProfile.WORD_INIT.startsWith(command)) {
! log.debug("CMD is "+SASLOTPProfile.WORD_INIT);
// @todo obviate the 2nd step when you get a chance
long l = OTPDictionary.convertWordsToHash(oldHashData);
! oldHash = SASLOTPProfile.convertLongToBytes(l);
} else {
abort(ERR_UNKNOWN_COMMAND+command);
***************
*** 399,403 ****
if (log.isDebugEnabled()) {
log.debug("Retrieved from init-* oldHash=>" +
! profile.convertBytesToHex(oldHash));
}
--- 395,399 ----
if (log.isDebugEnabled()) {
log.debug("Retrieved from init-* oldHash=>" +
! SASLOTPProfile.convertBytesToHex(oldHash));
}
***************
*** 418,423 ****
log.debug("Hash=>"+newHashData);
}
! profile.getUserDatabase().addUser(authenticated, algorithm,
! newHashData, seed, sequence);
log.debug("Successful Authentication!");
return cred;
--- 414,420 ----
log.debug("Hash=>"+newHashData);
}
! SASLOTPProfile.getUserDatabase().addUser(authenticated, algorithm,
! newHashData, seed,
! sequence);
log.debug("Successful Authentication!");
return cred;
***************
*** 455,462 ****
log.debug("Dict.getA()" + database.getAlgorithmName());
log.debug("Dict.getA()"
! + profile.getAlgorithm(database.getAlgorithmName()));
}
! algorithm = profile.getAlgorithm(database.getAlgorithmName());
profile = otpProfile;
password = pwd;
--- 452,459 ----
log.debug("Dict.getA()" + database.getAlgorithmName());
log.debug("Dict.getA()"
! + SASLOTPProfile.getAlgorithm(database.getAlgorithmName()));
}
! algorithm = SASLOTPProfile.getAlgorithm(database.getAlgorithmName());
profile = otpProfile;
password = pwd;
***************
*** 575,579 ****
algo = st.nextToken();
! algorithm = profile.getAlgorithm(algo);
if (algorithm == null) {
--- 572,576 ----
algo = st.nextToken();
! algorithm = SASLOTPProfile.getAlgorithm(algo);
if (algorithm == null) {
***************
*** 616,621 ****
{
StringBuffer sb = new StringBuffer(128);
! sb.append(profile.HEX_INIT);
! sb.append(profile.convertBytesToHex(temp));
sb.append(initData);
phrase = sb.toString();
--- 613,618 ----
{
StringBuffer sb = new StringBuffer(128);
! sb.append(SASLOTPProfile.HEX_INIT);
! sb.append(SASLOTPProfile.convertBytesToHex(temp));
sb.append(initData);
phrase = sb.toString();
Index: OTPGenerator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/OTPGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** OTPGenerator.java 5 Oct 2002 15:32:06 -0000 1.5
--- OTPGenerator.java 23 Apr 2003 15:23:03 -0000 1.6
***************
*** 31,35 ****
import org.beepcore.beep.profile.sasl.SASLException;
import org.beepcore.beep.profile.sasl.otp.algorithm.Algorithm;
- import org.beepcore.beep.profile.sasl.otp.database.UserDatabase;
import org.beepcore.beep.profile.sasl.otp.database.UserDatabasePool;
--- 31,34 ----
|