updated Random() to SecureRandom() (#1670)

* updated Random() to SecureRandom()

* batch 2 of SecureRandom updates
This commit is contained in:
Subhrodip Mohanta
2021-03-06 16:56:02 +05:30
committed by GitHub
parent c150871a94
commit b423002e6c
15 changed files with 32 additions and 31 deletions

View File

@ -23,8 +23,8 @@
package com.iluwatar.commander;
import java.security.SecureRandom;
import java.util.Hashtable;
import java.util.Random;
/**
* Order class holds details of the order.
@ -45,7 +45,7 @@ public class Order { //can store all transactions ids also
public final String id;
final float price;
final long createdTime;
private static final Random RANDOM = new Random();
private static final SecureRandom RANDOM = new SecureRandom();
private static final String ALL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
private static final Hashtable<String, Boolean> USED_IDS = new Hashtable<String, Boolean>();
PaymentStatus paid;

View File

@ -23,10 +23,10 @@
package com.iluwatar.commander;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
@ -56,7 +56,7 @@ public class Retry<T> {
void handleIssue(T obj, Exception e);
}
private static final Random RANDOM = new Random();
private static final SecureRandom RANDOM = new SecureRandom();
private final Operation op;
private final HandleErrorIssue<T> handleError;

View File

@ -24,10 +24,11 @@
package com.iluwatar.commander;
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;
/**
* Service class is an abstract class extended by all services in this example. They all have a
@ -42,7 +43,7 @@ public abstract class Service {
protected final Database database;
public ArrayList<Exception> exceptionsList;
private static final Random RANDOM = new Random();
private static final SecureRandom RANDOM = new SecureRandom();
private static final String ALL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
private static final Hashtable<String, Boolean> USED_IDS = new Hashtable<>();