Skip to content

Commit f6e7422

Browse files
authored
Remove Joda-Time dependency from the user-source-profile example.
The Joda-Time dependency was removed from the 8.3.0 final release. This also fixes a password expiration calculation error.
2 parents 660518e + 7f9196e commit f6e7422

File tree

1 file changed

+4
-9
lines changed
  • user-source-profile/user-source-gateway/src/main/java/com/inductiveautomation/ignition/examples/usersource/mongodb

1 file changed

+4
-9
lines changed

user-source-profile/user-source-gateway/src/main/java/com/inductiveautomation/ignition/examples/usersource/mongodb/MongoDbUserSource.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
import org.apache.log4j.Level;
2828
import org.bson.Document;
2929
import org.bson.conversions.Bson;
30-
import org.joda.time.DateTime;
31-
import org.joda.time.Days;
3230

3331
import javax.annotation.Nonnull;
3432
import java.nio.charset.StandardCharsets;
3533
import java.util.*;
34+
import java.util.concurrent.TimeUnit;
3635
import java.util.stream.Collectors;
3736

3837
/**
@@ -264,13 +263,9 @@ private boolean isPasswordInvalid(Document document, String pwd, boolean bypassE
264263
// Password is valid, now check if the password is expired
265264
if (settings.passwordMaxAge() > 0 && !bypassExpiration) {
266265
long pwdTimestamp = document.getLong(KEY_PASSWORD_DATE);
267-
if (pwdTimestamp > 0) {
268-
DateTime passwordCreatedOn = new DateTime(pwdTimestamp);
269-
DateTime now = DateTime.now();
270-
int days = Days.daysBetween(passwordCreatedOn.toLocalDate(), now.toLocalDate()).getDays();
271-
if (days > settings.passwordMaxAge()) {
272-
throw new PasswordExpiredException(getName(), uname);
273-
}
266+
long pwdExpiration = pwdTimestamp + TimeUnit.DAYS.toMillis(settings.passwordMaxAge());
267+
if (pwdTimestamp > 0 && System.currentTimeMillis() >= pwdExpiration) {
268+
throw new PasswordExpiredException(getName(), uname);
274269
}
275270
}
276271

0 commit comments

Comments
 (0)