Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package com.cloud.projects;

import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -106,6 +106,8 @@
public class ProjectManagerImpl extends ManagerBase implements ProjectManager, Configurable {
public static final Logger s_logger = Logger.getLogger(ProjectManagerImpl.class);

private static final SecureRandom secureRandom = new SecureRandom();

@Inject
private DomainDao _domainDao;
@Inject
Expand Down Expand Up @@ -1349,10 +1351,9 @@ private boolean suspendProject(ProjectVO project) throws ConcurrentOperationExce

public static String generateToken(int length) {
String charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random rand = new Random(System.currentTimeMillis());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int pos = rand.nextInt(charset.length());
int pos = secureRandom.nextInt(charset.length());
sb.append(charset.charAt(pos));
}
return sb.toString();
Expand Down