1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-09 18:29:45 +02:00

Make StringUtils.randomString(int) use SecureRandom

This commit is contained in:
Florian Schmaus 2016-01-06 14:56:49 +01:00
parent f79a7d9d5f
commit 658a671cbe
6 changed files with 34 additions and 8 deletions

View file

@ -42,8 +42,8 @@ public class IntTestUtil {
public static UsernameAndPassword registerAccount(XMPPConnection connection)
throws NoResponseException, XMPPErrorException, NotConnectedException,
InterruptedException {
return registerAccount(connection, StringUtils.randomString(12),
StringUtils.randomString(12));
return registerAccount(connection, StringUtils.insecureRandomString(12),
StringUtils.insecureRandomString(12));
}
public static UsernameAndPassword registerAccount(XMPPConnection connection, String username,

View file

@ -519,7 +519,7 @@ public class SmackIntegrationTestFramework {
accountUsername = USERNAME_PREFIX + '-' + middlefix + '-' +testRunResult.testRunId;
}
if (StringUtils.isNullOrEmpty(accountPassword)) {
accountPassword = StringUtils.randomString(16);
accountPassword = StringUtils.insecureRandomString(16);
}
// @formatter:off
Builder builder = XMPPTCPConnectionConfiguration.builder()
@ -584,7 +584,7 @@ public class SmackIntegrationTestFramework {
}
public static final class TestRunResult {
public final String testRunId = StringUtils.randomString(5);
public final String testRunId = StringUtils.insecureRandomString(5);
private final List<SuccessfulTest> successfulTests = Collections.synchronizedList(new LinkedList<SuccessfulTest>());
private final List<FailedTest> failedIntegrationTests = Collections.synchronizedList(new LinkedList<FailedTest>());
private final List<TestNotPossible> impossibleTestMethods = Collections.synchronizedList(new LinkedList<TestNotPossible>());

View file

@ -52,7 +52,7 @@ public class LoginIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
@SmackIntegrationTest
public void testInvalidLogin() throws SmackException, IOException, XMPPException,
InterruptedException, KeyManagementException, NoSuchAlgorithmException {
final String nonExistentUserString = StringUtils.randomString(24);
final String nonExistentUserString = StringUtils.insecureRandomString(24);
XMPPTCPConnectionConfiguration conf = getConnectionConfiguration().setUsernameAndPassword(
nonExistentUserString, "invalidPassword").build();

View file

@ -43,7 +43,7 @@ public class FileTransferIntegrationTest extends AbstractSmackIntegrationTest {
ftManagerTwo = FileTransferManager.getInstanceFor(conTwo);
}
private static final byte[] dataToSend = StringUtils.randomString(1024 * 4 * 5).getBytes();
private static final byte[] dataToSend = StringUtils.insecureRandomString(1024 * 4 * 5).getBytes();
@SmackIntegrationTest
public void fileTransferTest() throws Exception {

View file

@ -39,7 +39,7 @@ import org.jxmpp.jid.parts.Resourcepart;
public class MultiUserChatIntegrationTest extends AbstractSmackIntegrationTest {
private final String randomString = StringUtils.randomString(6);
private final String randomString = StringUtils.insecureRandomString(6);
private final MultiUserChatManager mucManagerOne;
private final MultiUserChatManager mucManagerTwo;