@Test public void digitsShouldFailWhenArgumentIsNotInValidRange() { TOTPBuilder builder = new TOTPBuilder(RFC6238TestVectors.KEY_FOR_HMAC_SHA_1); 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 TOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; }
TOTPBuilder { public TOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } }
TOTPBuilder { public TOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } TOTPBuilder(byte[] key); }
TOTPBuilder { public TOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } TOTPBuilder(byte[] key); TOTPBuilder timeStep(long timeStep); TOTPBuilder digits(int digits); TOTPBuilder hmacSha(HmacShaAlgorithm algorithm); TOTPBuilder hmacSha1(); TOTPBuilder hmacSha256(); TOTPBuilder hmacSha512(); TOTP build(); TOTP build(long time); }
TOTPBuilder { public TOTPBuilder digits(int digits) { Preconditions.checkArgument(Range.closed(MIN_ALLOWED_DIGITS, MAX_ALLOWED_DIGITS).contains(digits)); this.digits = digits; return this; } TOTPBuilder(byte[] key); TOTPBuilder timeStep(long timeStep); TOTPBuilder digits(int digits); TOTPBuilder hmacSha(HmacShaAlgorithm algorithm); TOTPBuilder hmacSha1(); TOTPBuilder hmacSha256(); TOTPBuilder hmacSha512(); TOTP build(); TOTP build(long time); static final long DEFAULT_TIME_STEP; static final int DEFAULT_DIGITS; static final int MIN_ALLOWED_DIGITS; static final int MAX_ALLOWED_DIGITS; }