@Override public boolean checkEntropy(String password) { if (!accountsSettings.getPasswordRequirements().getMinimalEntropyBits().isPresent()) { return true; } return meter.getStrength(password).getEntropy() >= accountsSettings.getPasswordRequirements().getMinimalEntropyBits().get(); } }
public void initialize() { try (Reader reader = getResourceReader(zxcvbnFilePath)) { Context engineContext = Context.enter(); engineContext.setOptimizationLevel(9); try { global = engineContext.initStandardObjects(); // No one loves rhino... fake a window object so that zxcvbn is exported to the global scope engineContext.evaluateString(global, "var window = this;", "rhino-no-love.js", 1, null); engineContext.evaluateReader(global, reader, zxcvbnFileName, 0, null); } finally { Context.exit(); this.hasInitialized = true; } } catch (IOException ex) { throw new RuntimeException("Unable to initialize zxcvbn strength checker: ", ex); } }
public PasswordStrength getStrength(String password) this.initialize();