@Test public void digitsShouldFailWhenArgumentIsNotInValidRange() { HOTPBuilder builder = new HOTPBuilder(RFC4226TestVectors.KEY); try { builder.digits(5); fail("Should have failed since digits argument is in invalid range!"); } catch (IllegalArgumentException ignore) { } try { builder.digits(9); fail("Should have failed since digits argument is outside the valid range!"); } catch (IllegalArgumentException ignore) { } }
public HOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; }
HOTPBuilder { public HOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } }
HOTPBuilder { public HOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } HOTPBuilder(byte[] key); }
HOTPBuilder { public HOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } HOTPBuilder(byte[] key); HOTPBuilder movingFactor(long movingFactor); HOTPBuilder digits(int digits); HOTP build(); }
HOTPBuilder { public HOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } HOTPBuilder(byte[] key); HOTPBuilder movingFactor(long movingFactor); HOTPBuilder digits(int digits); HOTP build(); static final int DEFAULT_DIGITS; static final int MIN_ALLOWED_DIGITS; static final int MAX_ALLOWED_DIGITS; }