| Chunk |
|---|
| Conflicting content |
|---|
public final class GoogleAuthenticator implements IGoogleAuthenticator {
/**
<<<<<<< HEAD
* Minimum validation window size.
*/
public static final int MIN_WINDOW = 1;
/**
* Maximum validation window size.
*/
public static final int MAX_WINDOW = 17;
/**
* The number of seconds a key is valid.
*/
public static final long KEY_VALIDATION_INTERVAL_MS =
TimeUnit.SECONDS.toMillis(30);
/**
=======
>>>>>>> faf4deeade71408fa33bc8030ace85bf7b791f16
* The logger for this class.
*/
private static final Logger LOGGER = |
| Solution content |
|---|
public final class GoogleAuthenticator implements IGoogleAuthenticator {
/**
* The logger for this class.
*/
private static final Logger LOGGER = |
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Attribute |
| Comment |
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
private static final String HMAC_HASH_FUNCTION = "HmacSHA1";
/**
<<<<<<< HEAD
* Minimum secret key length (inclusive).
*/
private static final int SECRET_KEY_LENGTH_MIN = 6;
/**
*/
* Maximum secret key length (inclusive).
private static final int SECRET_KEY_LENGTH_MAX = 9;
/**
* The secret key length used by the current instance.
*/
private final int secretKeyModule;
/**
* The initial windowSize used when validating the codes. We are using
* Google's default behaviour of using a window size equal to 3. The maximum
* window size is 17.
=======
* The configuration used by the current instance.
>>>>>>> faf4deeade71408fa33bc8030ace85bf7b791f16
*/
private final GoogleAuthenticatorConfig config;
|
| Solution content |
|---|
private static final String HMAC_HASH_FUNCTION = "HmacSHA1";
/**
* The configuration used by the current instance.
*/
private final GoogleAuthenticatorConfig config;
|
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Attribute |
| Comment |
| Chunk |
|---|
| Conflicting content |
|---|
* Default constructor.
*/
public GoogleAuthenticator() {
<<<<<<< HEAD
this(SECRET_KEY_LENGTH_MIN);
}
/**
* This constructor builds a Google Authenticator object and set the
* secret key length to the specified value.
*
* @param secretKeyLength The secret key length, which must satisfy
* |
| Solution content |
|---|
public GoogleAuthenticator() {
config = new GoogleAuthenticatorConfig();
}
public GoogleAuthenticator(GoogleAuthenticatorConfig config) {
checkNotNull(config, "Configuration cannot be null.");
this.config = config;
}
/** |
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Attribute |
| Cast expression |
| Comment |
| If statement |
| Method invocation |
| Method signature |
| Chunk |
|---|
| Conflicting content |
|---|
// Clean bits higher than the 32nd (inclusive) and calculate the
// module with the maximum validation code value.
truncatedHash &= 0x7FFFFFFF;
<<<<<<< HEAD
truncatedHash %= this.secretKeyModule;
=======
truncatedHash %= config.getKeyModulus();
>>>>>>> faf4deeade71408fa33bc8030ace85bf7b791f16
// Returning the validation code to the caller.
return (int) truncatedHash; |
| Solution content |
|---|
// Clean bits higher than the 32nd (inclusive) and calculate the
// module with the maximum validation code value.
truncatedHash &= 0x7FFFFFFF;
truncatedHash %= config.getKeyModulus();
// Returning the validation code to the caller.
return (int) truncatedHash; |
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Other |
| Chunk |
|---|
| Conflicting content |
|---|
byte[] decodedKey;
// Decoding the secret key to get its raw byte representation.
<<<<<<< HEAD
byte[] decodedKey = decodeSecretKey(secret);
=======
switch (config.getKeyRepresentation()) {
case BASE32:
Base32 codec32 = new Base32();
decodedKey = codec32.decode(secret);
break;
case BASE64:
Base64 codec64 = new Base64();
decodedKey = codec64.decode(secret);
break;
default:
throw new IllegalArgumentException("Unknown key representation type.");
}
>>>>>>> faf4deeade71408fa33bc8030ace85bf7b791f16
// convert unix time into a 30 second "window" as specified by the
// TOTP specification. Using Google's default interval of 30 seconds. |
| Solution content |
|---|
byte[] decodedKey;
// Decoding the secret key to get its raw byte representation.
switch (config.getKeyRepresentation()) {
case BASE32:
Base32 codec32 = new Base32();
decodedKey = codec32.decode(secret);
break;
case BASE64:
Base64 codec64 = new Base64();
decodedKey = codec64.decode(secret);
break;
default:
throw new IllegalArgumentException("Unknown key representation type.");
}
// convert unix time into a 30 second "window" as specified by the
// TOTP specification. Using Google's default interval of 30 seconds. |
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Method invocation |
| Switch statement |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
* @param secretKey a random byte buffer.
* @return the secret key.
*/
<<<<<<< HEAD
private String encodeSecretKey(byte[] secretKey) {
Base32 codec = new Base32();
byte[] encodedKey = codec.encode(secretKey);
=======
private String calculateSecretKey(byte[] secretKey) {
byte[] encodedKey;
switch (config.getKeyRepresentation()) {
case BASE32:
Base32 codec = new Base32();
encodedKey = codec.encode(secretKey);
break;
case BASE64:
Base64 codec64 = new Base64();
encodedKey = codec64.encode(secretKey);
break;
default:
throw new IllegalArgumentException("Unknown key representation type.");
}
>>>>>>> faf4deeade71408fa33bc8030ace85bf7b791f16
// Creating a string in the specified representation.
return new String(encodedKey); |
| Solution content |
|---|
* @param secretKey a random byte buffer.
* @return the secret key.
*/
private String calculateSecretKey(byte[] secretKey) {
byte[] encodedKey;
switch (config.getKeyRepresentation()) {
case BASE32:
Base32 codec = new Base32();
encodedKey = codec.encode(secretKey);
break;
case BASE64:
Base64 codec64 = new Base64();
encodedKey = codec64.encode(secretKey);
break;
default:
throw new IllegalArgumentException("Unknown key representation type.");
}
// Creating a string in the specified representation.
return new String(encodedKey); |
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Method invocation |
| Method signature |
| Switch statement |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
return null;
}
<<<<<<< HEAD
@Override
public boolean authorize(
String secret,
int verificationCode,
int window)
throws GoogleAuthenticatorException {
// Checking user input and failing if the secret key was not provided.
if (secret == null) {
throw new GoogleAuthenticatorException("Secret cannot be null.");
}
// Checking if the verification code is between the legal bounds.
if (verificationCode <= 0 || verificationCode >= this.secretKeyModule) {
return false;
}
// Checking if the window size is between the legal bounds.
if (window < MIN_WINDOW || window > MAX_WINDOW) {
throw new GoogleAuthenticatorException("Invalid window size.");
}
// Checking the validation code using the current UNIX time.
return checkCode(
secret,
verificationCode,
new Date().getTime(),
window);
}
=======
>>>>>>> faf4deeade71408fa33bc8030ace85bf7b791f16
} |
| Solution content |
|---|
return null;
}
} |
| File |
|---|
| GoogleAuthenticator.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Annotation |
| Method declaration |