|
20 | 20 | *
|
21 | 21 | * @author Bastiaan Jansen
|
22 | 22 | */
|
23 |
| -public class OTPGenerator { |
| 23 | +class OTPGenerator { |
24 | 24 | private final static String URL_SCHEME = "otpauth";
|
25 | 25 |
|
26 | 26 | /**
|
@@ -57,6 +57,10 @@ protected OTPGenerator(final int passwordLength, final HMACAlgorithm algorithm,
|
57 | 57 | this.secret = secret;
|
58 | 58 | }
|
59 | 59 |
|
| 60 | + protected OTPGenerator(final Builder<?, ?> builder) { |
| 61 | + this(builder.getPasswordLength(), builder.getAlgorithm(), builder.getSecret()); |
| 62 | + } |
| 63 | + |
60 | 64 | public int getPasswordLength() {
|
61 | 65 | return passwordLength;
|
62 | 66 | }
|
@@ -248,27 +252,27 @@ protected abstract static class Builder<B, G> {
|
248 | 252 | /**
|
249 | 253 | * Number of digits for generated code in range 6...8, defaults to 6
|
250 | 254 | */
|
251 |
| - protected int passwordLength; |
| 255 | + private int passwordLength; |
252 | 256 |
|
253 | 257 | /**
|
254 | 258 | * Hashing algorithm used to generate code, defaults to SHA1
|
255 | 259 | */
|
256 |
| - protected HMACAlgorithm algorithm; |
| 260 | + private HMACAlgorithm algorithm; |
257 | 261 |
|
258 | 262 | /**
|
259 | 263 | * Secret key used to generate the code, this should be a base32 string
|
260 | 264 | */
|
261 |
| - protected byte[] secret; |
| 265 | + private final byte[] secret; |
262 | 266 |
|
263 | 267 | /**
|
264 | 268 | * Default value for password length
|
265 | 269 | */
|
266 |
| - public static final int DEFAULT_PASSWORD_LENGTH = 6; |
| 270 | + private static final int DEFAULT_PASSWORD_LENGTH = 6; |
267 | 271 |
|
268 | 272 | /**
|
269 | 273 | * Default value for HMAC Algorithm
|
270 | 274 | */
|
271 |
| - public static final HMACAlgorithm DEFAULT_HMAC_ALGORITHM = HMACAlgorithm.SHA1; |
| 275 | + private static final HMACAlgorithm DEFAULT_HMAC_ALGORITHM = HMACAlgorithm.SHA1; |
272 | 276 |
|
273 | 277 | public Builder(final byte[] secret) {
|
274 | 278 | this.secret = secret;
|
|
0 commit comments