use of password.pwm.util.java.TimeDuration in project pwm by pwm-project.
the class AbstractWordlist method containsWord.
public boolean containsWord(final String word) {
if (wlStatus != STATUS.OPEN) {
return false;
}
final String testWord = normalizeWord(word);
if (testWord == null || testWord.length() < 1) {
return false;
}
final Set<String> testWords = chunkWord(testWord, this.wordlistConfiguration.getCheckSize());
final Instant startTime = Instant.now();
try {
boolean result = false;
for (final String t : testWords) {
if (!result) {
// stop checking once found
if (localDB.contains(getWordlistDB(), t)) {
result = true;
}
}
}
final TimeDuration timeDuration = TimeDuration.fromCurrent(startTime);
if (timeDuration.isLongerThan(100)) {
logger.debug("wordlist search time for " + testWords.size() + " wordlist permutations was greater then 100ms: " + timeDuration.asCompactString());
}
return result;
} catch (Exception e) {
logger.error("database error checking for word: " + e.getMessage());
}
return false;
}
use of password.pwm.util.java.TimeDuration in project pwm by pwm-project.
the class TokenService method maxTokenAge.
static TimeDuration maxTokenAge(final Configuration configuration) {
long maxValue = 0;
maxValue = Math.max(maxValue, configuration.readSettingAsLong(PwmSetting.TOKEN_LIFETIME));
maxValue = Math.max(maxValue, configuration.readSettingAsLong(PwmSetting.TOKEN_LIFETIME));
for (NewUserProfile newUserProfile : configuration.getNewUserProfiles().values()) {
maxValue = Math.max(maxValue, newUserProfile.readSettingAsLong(PwmSetting.NEWUSER_TOKEN_LIFETIME_EMAIL));
maxValue = Math.max(maxValue, newUserProfile.readSettingAsLong(PwmSetting.NEWUSER_TOKEN_LIFETIME_SMS));
}
return new TimeDuration(maxValue, TimeUnit.SECONDS);
}
use of password.pwm.util.java.TimeDuration in project pwm by pwm-project.
the class TelemetryService method scheduleNextJob.
private void scheduleNextJob() {
final TimeDuration durationUntilNextPublish = durationUntilNextPublish();
executorService.schedule(new PublishJob(), durationUntilNextPublish.getTotalMilliseconds(), TimeUnit.MILLISECONDS);
LOGGER.trace(SessionLabel.TELEMETRY_SESSION_LABEL, "next publish time: " + durationUntilNextPublish().asCompactString());
}
use of password.pwm.util.java.TimeDuration in project pwm by pwm-project.
the class ProgressInfo method debugOutput.
public String debugOutput() {
final TimeDuration remainingTime = remainingDuration();
final NumberFormat numberFormat = NumberFormat.getNumberInstance();
return "processed " + numberFormat.format(nowItems) + " of " + numberFormat.format(totalItems) + " (" + percentComplete().pretty(2) + ")" + ", remaining " + numberFormat.format(itemsRemaining()) + " in " + remainingTime.asCompactString();
}
use of password.pwm.util.java.TimeDuration in project pwm by pwm-project.
the class PasswordUtility method throwPasswordTooSoonException.
public static void throwPasswordTooSoonException(final UserInfo userInfo, final SessionLabel sessionLabel) throws PwmUnrecoverableException {
if (!userInfo.isWithinPasswordMinimumLifetime()) {
return;
}
final Instant lastModified = userInfo.getPasswordLastModifiedTime();
final TimeDuration minimumLifetime;
{
final int minimumLifetimeSeconds = userInfo.getPasswordPolicy().getRuleHelper().readIntValue(PwmPasswordRule.MinimumLifetime);
if (minimumLifetimeSeconds < 1) {
return;
}
if (userInfo.getPasswordPolicy() == null) {
LOGGER.debug(sessionLabel, "skipping minimum lifetime check, password last set time is unknown");
return;
}
minimumLifetime = new TimeDuration(minimumLifetimeSeconds, TimeUnit.SECONDS);
}
final Instant allowedChangeDate = Instant.ofEpochMilli(lastModified.toEpochMilli() + minimumLifetime.getTotalMilliseconds());
final TimeDuration passwordAge = TimeDuration.fromCurrent(lastModified);
final String msg = "last password change was at " + JavaHelper.toIsoDate(lastModified) + " and is too recent (" + passwordAge.asCompactString() + " ago), password cannot be changed within minimum lifetime of " + minimumLifetime.asCompactString() + ", next eligible time to change is after " + JavaHelper.toIsoDate(allowedChangeDate);
throw PwmUnrecoverableException.newException(PwmError.PASSWORD_TOO_SOON, msg);
}
Aggregations