Apparently I'm behind the times on this constructor
// FREEBIE
This commit is contained in:
parent
6fce69bbac
commit
54f25358eb
|
@ -38,12 +38,8 @@ public class AuthenticationCredentials {
|
|||
}
|
||||
|
||||
public AuthenticationCredentials(String authenticationToken) {
|
||||
try {
|
||||
this.salt = Math.abs(SecureRandom.getInstance("SHA1PRNG").nextInt()) + "";
|
||||
this.hashedAuthenticationToken = getHashedValue(salt, authenticationToken);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
this.salt = Math.abs(new SecureRandom().nextInt()) + "";
|
||||
this.hashedAuthenticationToken = getHashedValue(salt, authenticationToken);
|
||||
}
|
||||
|
||||
public String getHashedAuthenticationToken() {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TurnTokenGenerator {
|
|||
try {
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
long validUntilSeconds = (System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)) / 1000;
|
||||
long user = Math.abs(SecureRandom.getInstance("SHA1PRNG").nextInt());
|
||||
long user = Math.abs(new SecureRandom().nextInt());
|
||||
String userTime = validUntilSeconds + ":" + user;
|
||||
|
||||
mac.init(new SecretKeySpec(key, "HmacSHA1"));
|
||||
|
|
|
@ -360,16 +360,12 @@ public class AccountController {
|
|||
}
|
||||
|
||||
@VisibleForTesting protected VerificationCode generateVerificationCode(String number) {
|
||||
try {
|
||||
if (testDevices.containsKey(number)) {
|
||||
return new VerificationCode(testDevices.get(number));
|
||||
}
|
||||
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
if (testDevices.containsKey(number)) {
|
||||
return new VerificationCode(testDevices.get(number));
|
||||
}
|
||||
|
||||
SecureRandom random = new SecureRandom();
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,14 +103,10 @@ public class AttachmentController {
|
|||
}
|
||||
|
||||
private long generateAttachmentId() {
|
||||
try {
|
||||
byte[] attachmentBytes = new byte[8];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(attachmentBytes);
|
||||
byte[] attachmentBytes = new byte[8];
|
||||
new SecureRandom().nextBytes(attachmentBytes);
|
||||
|
||||
attachmentBytes[0] = (byte)(attachmentBytes[0] & 0x7F);
|
||||
return Conversions.byteArrayToLong(attachmentBytes);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new AssertionError(nsae);
|
||||
}
|
||||
attachmentBytes[0] = (byte)(attachmentBytes[0] & 0x7F);
|
||||
return Conversions.byteArrayToLong(attachmentBytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,12 +205,8 @@ public class DeviceController {
|
|||
}
|
||||
|
||||
@VisibleForTesting protected VerificationCode generateVerificationCode() {
|
||||
try {
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
SecureRandom random = new SecureRandom();
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ public class FederatedClient {
|
|||
trustManagerFactory.init(initializeTrustStore(peer.getName(), peer.getCertificate()));
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, trustManagerFactory.getTrustManagers(), SecureRandom.getInstance("SHA1PRNG"));
|
||||
sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());
|
||||
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier());
|
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", sslConnectionSocketFactory).build();
|
||||
|
|
|
@ -22,11 +22,11 @@ public class ProvisioningAddress extends WebsocketAddress {
|
|||
public static ProvisioningAddress generate() {
|
||||
try {
|
||||
byte[] random = new byte[16];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(random);
|
||||
new SecureRandom().nextBytes(random);
|
||||
|
||||
return new ProvisioningAddress(Base64.encodeBytesWithoutPadding(random)
|
||||
.replace('+', '-').replace('/', '_'), 0);
|
||||
} catch (NoSuchAlgorithmException | InvalidWebsocketAddressException e) {
|
||||
} catch (InvalidWebsocketAddressException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
|||
|
||||
if (device.isPresent()) {
|
||||
byte[] random = new byte[16];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(random);
|
||||
new SecureRandom().nextBytes(random);
|
||||
|
||||
device.get().setGcmId(null);
|
||||
device.get().setFetchesMessages(false);
|
||||
|
|
|
@ -244,18 +244,14 @@ public class PubSubConnectionTest {
|
|||
}
|
||||
|
||||
public int read(byte[] input, int offset, int length) {
|
||||
try {
|
||||
int maxCopy = Math.min(data.length - index, length);
|
||||
int randomCopy = SecureRandom.getInstance("SHA1PRNG").nextInt(maxCopy) + 1;
|
||||
int copyAmount = Math.min(maxCopy, randomCopy);
|
||||
int maxCopy = Math.min(data.length - index, length);
|
||||
int randomCopy = new SecureRandom().nextInt(maxCopy) + 1;
|
||||
int copyAmount = Math.min(maxCopy, randomCopy);
|
||||
|
||||
System.arraycopy(data, index, input, offset, copyAmount);
|
||||
index += copyAmount;
|
||||
System.arraycopy(data, index, input, offset, copyAmount);
|
||||
index += copyAmount;
|
||||
|
||||
return copyAmount;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
return copyAmount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue