Commit fa0e4bb2 authored by Dave Cridland's avatar Dave Cridland

OF-631 Add logging to trace fault

parent 09a11a0c
...@@ -40,6 +40,8 @@ import org.jivesoftware.openfire.auth.InternalUnauthenticatedException; ...@@ -40,6 +40,8 @@ import org.jivesoftware.openfire.auth.InternalUnauthenticatedException;
import org.jivesoftware.openfire.auth.ScramUtils; import org.jivesoftware.openfire.auth.ScramUtils;
import org.jivesoftware.openfire.user.UserManager; import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Implements the SCRAM-SHA-1 server-side mechanism. * Implements the SCRAM-SHA-1 server-side mechanism.
...@@ -47,7 +49,7 @@ import org.jivesoftware.openfire.user.UserNotFoundException; ...@@ -47,7 +49,7 @@ import org.jivesoftware.openfire.user.UserNotFoundException;
* @author Richard Midwinter * @author Richard Midwinter
*/ */
public class ScramSha1SaslServer implements SaslServer { public class ScramSha1SaslServer implements SaslServer {
private static final Logger Log = LoggerFactory.getLogger(ScramSha1SaslServer.class);
private static final Pattern private static final Pattern
CLIENT_FIRST_MESSAGE = Pattern.compile("^(([pny])=?([^,]*),([^,]*),)(m?=?[^,]*,?n=([^,]*),r=([^,]*),?.*)$"), CLIENT_FIRST_MESSAGE = Pattern.compile("^(([pny])=?([^,]*),([^,]*),)(m?=?[^,]*,?n=([^,]*),r=([^,]*),?.*)$"),
CLIENT_FINAL_MESSAGE = Pattern.compile("(c=([^,]*),r=([^,]*)),p=(.*)$"); CLIENT_FINAL_MESSAGE = Pattern.compile("(c=([^,]*),r=([^,]*)),p=(.*)$");
...@@ -320,6 +322,7 @@ public class ScramSha1SaslServer implements SaslServer { ...@@ -320,6 +322,7 @@ public class ScramSha1SaslServer implements SaslServer {
String saltshaker = UserManager.getUserProvider().loadUser(username).getSalt(); String saltshaker = UserManager.getUserProvider().loadUser(username).getSalt();
byte[] salt; byte[] salt;
if (saltshaker == null) { if (saltshaker == null) {
Log.debug("No salt found, so resetting password.");
String password = AuthFactory.getPassword(username); String password = AuthFactory.getPassword(username);
AuthFactory.setPassword(username, password); AuthFactory.setPassword(username, password);
salt = DatatypeConverter.parseBase64Binary(UserManager.getUserProvider().loadUser(username).getSalt()); salt = DatatypeConverter.parseBase64Binary(UserManager.getUserProvider().loadUser(username).getSalt());
...@@ -328,6 +331,7 @@ public class ScramSha1SaslServer implements SaslServer { ...@@ -328,6 +331,7 @@ public class ScramSha1SaslServer implements SaslServer {
} }
return salt; return salt;
} catch (UserNotFoundException | UnsupportedOperationException | ConnectionException | InternalUnauthenticatedException e) { } catch (UserNotFoundException | UnsupportedOperationException | ConnectionException | InternalUnauthenticatedException e) {
Log.warn("Exception in SCRAM.getSalt():", e);
byte[] salt = new byte[32]; byte[] salt = new byte[32];
random.nextBytes(salt); random.nextBytes(salt);
return salt; return salt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment