Skip to content

Commit b1a807e

Browse files
authored
spring-boot: remove deprecated RandomStringUtils usage (#28082)
1 parent 6d957a6 commit b1a807e

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

generators/spring-boot/templates/src/test/java/_package_/_entityPackage_/service/UserServiceIT.java.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class UserServiceIT {
222222
<%_ } _%>
223223
user.setLogin(DEFAULT_LOGIN);
224224
<%_ if (!authenticationTypeOauth2) { _%>
225-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
225+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
226226
<%_ } _%>
227227
user.setActivated(true);
228228
user.setEmail(DEFAULT_EMAIL);
@@ -391,7 +391,7 @@ class UserServiceIT {
391391
when(dateTimeProvider.getNow()).thenReturn(Optional.of(now.minus(4, ChronoUnit.DAYS)));
392392
<%_ } _%>
393393
user.setActivated(false);
394-
user.setActivationKey(RandomStringUtils.random(20));
394+
user.setActivationKey(RandomStringUtils.insecure().next(20));
395395
<%= user.persistClass %> dbUser = userRepository.save<% if (databaseTypeSql && !reactive) { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
396396
dbUser.setCreatedDate(now.minus(4, ChronoUnit.DAYS));
397397
userRepository.save<% if (databaseTypeSql && !reactive) { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;

generators/spring-boot/templates/src/test/java/_package_/_entityPackage_/web/rest/UserResourceIT.java.ejs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ class UserResourceIT {
231231
<%_ if (databaseTypeCassandra || (authenticationTypeOauth2 && !databaseTypeCouchbase)) { _%>
232232
persistUser.setId(UUID.randomUUID().toString());
233233
<%_ } _%>
234-
persistUser.setLogin(DEFAULT_LOGIN<% if (databaseTypeSql) { %> + RandomStringUtils.randomAlphabetic(5)<% } %>);
234+
persistUser.setLogin(DEFAULT_LOGIN<% if (databaseTypeSql) { %> + RandomStringUtils.insecure().nextAlphabetic(5)<% } %>);
235235
<%_ if (!authenticationTypeOauth2) { _%>
236-
persistUser.setPassword(RandomStringUtils.randomAlphanumeric(60));
236+
persistUser.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
237237
<%_ } _%>
238238
persistUser.setActivated(true);
239-
persistUser.setEmail(<% if (databaseTypeSql) { %>RandomStringUtils.randomAlphabetic(5) + <% } %>DEFAULT_EMAIL);
239+
persistUser.setEmail(<% if (databaseTypeSql) { %>RandomStringUtils.insecure().nextAlphabetic(5) + <% } %>DEFAULT_EMAIL);
240240
persistUser.setFirstName(DEFAULT_FIRSTNAME);
241241
persistUser.setLastName(DEFAULT_LASTNAME);
242242
<%_ if (!databaseTypeCassandra) { _%>
@@ -733,7 +733,7 @@ class UserResourceIT {
733733
anotherUser.setId(UUID.randomUUID().toString());
734734
<%_ } _%>
735735
anotherUser.setLogin("jhipster");
736-
anotherUser.setPassword(RandomStringUtils.randomAlphanumeric(60));
736+
anotherUser.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
737737
anotherUser.setActivated(true);
738738
anotherUser.setEmail("jhipster@localhost");
739739
anotherUser.setFirstName("java");
@@ -803,7 +803,7 @@ class UserResourceIT {
803803
anotherUser.setId(UUID.randomUUID().toString());
804804
<%_ } _%>
805805
anotherUser.setLogin("jhipster");
806-
anotherUser.setPassword(RandomStringUtils.randomAlphanumeric(60));
806+
anotherUser.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
807807
anotherUser.setActivated(true);
808808
anotherUser.setEmail("jhipster@localhost");
809809
anotherUser.setFirstName("java");

generators/spring-boot/templates/src/test/java/_package_/security/DomainUserDetailsServiceIT.java.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class DomainUserDetailsServiceIT {
9393
userOne.setId(UUID.randomUUID().toString());
9494
<%_ } _%>
9595
userOne.setLogin(USER_ONE_LOGIN);
96-
userOne.setPassword(RandomStringUtils.randomAlphanumeric(60));
96+
userOne.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
9797
userOne.setActivated(true);
9898
userOne.setEmail(USER_ONE_EMAIL);
9999
userOne.setFirstName("userOne");
@@ -111,7 +111,7 @@ class DomainUserDetailsServiceIT {
111111
userTwo.setId(UUID.randomUUID().toString());
112112
<%_ } _%>
113113
userTwo.setLogin(USER_TWO_LOGIN);
114-
userTwo.setPassword(RandomStringUtils.randomAlphanumeric(60));
114+
userTwo.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
115115
userTwo.setActivated(true);
116116
userTwo.setEmail(USER_TWO_EMAIL);
117117
userTwo.setFirstName("userTwo");
@@ -129,7 +129,7 @@ class DomainUserDetailsServiceIT {
129129
userThree.setId(UUID.randomUUID().toString());
130130
<%_ } _%>
131131
userThree.setLogin(USER_THREE_LOGIN);
132-
userThree.setPassword(RandomStringUtils.randomAlphanumeric(60));
132+
userThree.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
133133
userThree.setActivated(false);
134134
userThree.setEmail(USER_THREE_EMAIL);
135135
userThree.setFirstName("userThree");

generators/spring-boot/templates/src/test/java/_package_/service/mapper/UserMapperTest.java.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class UserMapperTest {
6969
user = new <%= user.persistClass %>();
7070
user.setLogin(DEFAULT_LOGIN);
7171
<%_ if (!authenticationTypeOauth2) { _%>
72-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
72+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
7373
<%_ } _%>
7474
user.setActivated(true);
7575
user.setEmail("johndoe@localhost");

generators/spring-boot/templates/src/test/java/_package_/web/rest/AccountResourceIT.java.ejs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ class AccountResourceIT {
690690
<%_ } _%>
691691
user.setLogin("activate-account");
692692
user.setEmail("activate-account@example.com");
693-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
693+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
694694
user.setActivated(false);
695695
user.setActivationKey(activationKey);
696696
<%_ if (databaseTypeSql && reactive) { _%>
@@ -741,7 +741,7 @@ class AccountResourceIT {
741741
<%_ } _%>
742742
user.setLogin("save-account");
743743
user.setEmail("save-account@example.com");
744-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
744+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
745745
user.setActivated(true);
746746
<%_ if (databaseTypeSql && reactive) { _%>
747747
user.setCreatedBy(Constants.SYSTEM);
@@ -802,7 +802,7 @@ class AccountResourceIT {
802802
<%_ } _%>
803803
user.setLogin("save-invalid-email");
804804
user.setEmail("save-invalid-email@example.com");
805-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
805+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
806806
user.setActivated(true);
807807
<%_ if (databaseTypeSql && reactive) { _%>
808808
user.setCreatedBy(Constants.SYSTEM);
@@ -857,7 +857,7 @@ class AccountResourceIT {
857857
<%_ } _%>
858858
user.setLogin("save-existing-email");
859859
user.setEmail("save-existing-email@example.com");
860-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
860+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
861861
user.setActivated(true);
862862
<%_ if (databaseTypeSql && reactive) { _%>
863863
user.setCreatedBy(Constants.SYSTEM);
@@ -870,7 +870,7 @@ class AccountResourceIT {
870870
<%_ } _%>
871871
anotherUser.setLogin("save-existing-email2");
872872
anotherUser.setEmail("save-existing-email2@example.com");
873-
anotherUser.setPassword(RandomStringUtils.randomAlphanumeric(60));
873+
anotherUser.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
874874
anotherUser.setActivated(true);
875875
<%_ if (databaseTypeSql && reactive) { _%>
876876
anotherUser.setCreatedBy(Constants.SYSTEM);
@@ -924,7 +924,7 @@ class AccountResourceIT {
924924
<%_ } _%>
925925
user.setLogin("save-existing-email-and-login");
926926
user.setEmail("save-existing-email-and-login@example.com");
927-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
927+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
928928
user.setActivated(true);
929929
<%_ if (databaseTypeSql && reactive) { _%>
930930
user.setCreatedBy(Constants.SYSTEM);
@@ -974,7 +974,7 @@ class AccountResourceIT {
974974
<%_ if (databaseTypeCassandra) { _%>
975975
user.setId(UUID.randomUUID().toString());
976976
<%_ } _%>
977-
String currentPassword = RandomStringUtils.randomAlphanumeric(60);
977+
String currentPassword = RandomStringUtils.insecure().nextAlphanumeric(60);
978978
user.setPassword(passwordEncoder.encode(currentPassword));
979979
user.setLogin("change-password-wrong-existing-password");
980980
user.setEmail("change-password-wrong-existing-password@example.com");
@@ -1015,7 +1015,7 @@ class AccountResourceIT {
10151015
<%_ if (databaseTypeCassandra) { _%>
10161016
user.setId(UUID.randomUUID().toString());
10171017
<%_ } _%>
1018-
String currentPassword = RandomStringUtils.randomAlphanumeric(60);
1018+
String currentPassword = RandomStringUtils.insecure().nextAlphanumeric(60);
10191019
user.setPassword(passwordEncoder.encode(currentPassword));
10201020
user.setLogin("change-password");
10211021
user.setEmail("change-password@example.com");
@@ -1055,7 +1055,7 @@ class AccountResourceIT {
10551055
<%_ if (databaseTypeCassandra) { _%>
10561056
user.setId(UUID.randomUUID().toString());
10571057
<%_ } _%>
1058-
String currentPassword = RandomStringUtils.randomAlphanumeric(60);
1058+
String currentPassword = RandomStringUtils.insecure().nextAlphanumeric(60);
10591059
user.setPassword(passwordEncoder.encode(currentPassword));
10601060
user.setLogin("change-password-too-small");
10611061
user.setEmail("change-password-too-small@example.com");
@@ -1064,7 +1064,7 @@ class AccountResourceIT {
10641064
<%_ } _%>
10651065
userRepository.save<% if (databaseTypeSql && !reactive) { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
10661066
1067-
String newPassword = RandomStringUtils.random(ManagedUserVM.PASSWORD_MIN_LENGTH - 1);
1067+
String newPassword = RandomStringUtils.insecure().next(ManagedUserVM.PASSWORD_MIN_LENGTH - 1);
10681068
10691069
<%_ if (reactive) { _%>
10701070
accountWebTestClient.post().uri("/api/account/change-password")
@@ -1097,7 +1097,7 @@ class AccountResourceIT {
10971097
<%_ if (databaseTypeCassandra) { _%>
10981098
user.setId(UUID.randomUUID().toString());
10991099
<%_ } _%>
1100-
String currentPassword = RandomStringUtils.randomAlphanumeric(60);
1100+
String currentPassword = RandomStringUtils.insecure().nextAlphanumeric(60);
11011101
user.setPassword(passwordEncoder.encode(currentPassword));
11021102
user.setLogin("change-password-too-long");
11031103
user.setEmail("change-password-too-long@example.com");
@@ -1106,7 +1106,7 @@ class AccountResourceIT {
11061106
<%_ } _%>
11071107
userRepository.save<% if (databaseTypeSql && !reactive) { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
11081108
1109-
String newPassword = RandomStringUtils.random(ManagedUserVM.PASSWORD_MAX_LENGTH + 1);
1109+
String newPassword = RandomStringUtils.insecure().next(ManagedUserVM.PASSWORD_MAX_LENGTH + 1);
11101110
11111111
<%_ if (reactive) { _%>
11121112
accountWebTestClient.post().uri("/api/account/change-password")
@@ -1139,7 +1139,7 @@ class AccountResourceIT {
11391139
<%_ if (databaseTypeCassandra) { _%>
11401140
user.setId(UUID.randomUUID().toString());
11411141
<%_ } _%>
1142-
String currentPassword = RandomStringUtils.randomAlphanumeric(60);
1142+
String currentPassword = RandomStringUtils.insecure().nextAlphanumeric(60);
11431143
user.setPassword(passwordEncoder.encode(currentPassword));
11441144
user.setLogin("change-password-empty");
11451145
user.setEmail("change-password-empty@example.com");
@@ -1180,7 +1180,7 @@ class AccountResourceIT {
11801180
<%_ if (databaseTypeCassandra) { _%>
11811181
user.setId(UUID.randomUUID().toString());
11821182
<%_ } _%>
1183-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
1183+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
11841184
user.setLogin("current-sessions");
11851185
user.setEmail("current-sessions@example.com");
11861186
<%_ if (databaseTypeSql && reactive) { _%>
@@ -1229,7 +1229,7 @@ class AccountResourceIT {
12291229
<%_ if (databaseTypeCassandra) { _%>
12301230
user.setId(UUID.randomUUID().toString());
12311231
<%_ } _%>
1232-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
1232+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
12331233
user.setLogin("invalidate-session");
12341234
user.setEmail("invalidate-session@example.com");
12351235
<%_ if (databaseTypeSql && reactive) { _%>
@@ -1277,7 +1277,7 @@ class AccountResourceIT {
12771277
<%_ if (databaseTypeCassandra) { _%>
12781278
user.setId(UUID.randomUUID().toString());
12791279
<%_ } _%>
1280-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
1280+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
12811281
user.setActivated(true);
12821282
user.setLogin("password-reset");
12831283
user.setEmail("password-reset@example.com");
@@ -1312,7 +1312,7 @@ class AccountResourceIT {
13121312
<%_ if (databaseTypeCassandra) { _%>
13131313
user.setId(UUID.randomUUID().toString());
13141314
<%_ } _%>
1315-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
1315+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
13161316
user.setActivated(true);
13171317
user.setLogin("password-reset-upper-case");
13181318
user.setEmail("password-reset-upper-case@example.com");
@@ -1364,7 +1364,7 @@ class AccountResourceIT {
13641364
<%_ if (databaseTypeCassandra) { _%>
13651365
user.setId(UUID.randomUUID().toString());
13661366
<%_ } _%>
1367-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
1367+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
13681368
user.setLogin("finish-password-reset");
13691369
user.setEmail("finish-password-reset@example.com");
13701370
user.setResetDate(Instant.now().plusSeconds(60));
@@ -1408,7 +1408,7 @@ class AccountResourceIT {
14081408
<%_ if (databaseTypeCassandra) { _%>
14091409
user.setId(UUID.randomUUID().toString());
14101410
<%_ } _%>
1411-
user.setPassword(RandomStringUtils.randomAlphanumeric(60));
1411+
user.setPassword(RandomStringUtils.insecure().nextAlphanumeric(60));
14121412
user.setLogin("finish-password-reset-too-small");
14131413
user.setEmail("finish-password-reset-too-small@example.com");
14141414
user.setResetDate(Instant.now().plusSeconds(60));

0 commit comments

Comments
 (0)