Skip to content

Commit

Permalink
Fixing deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Sep 7, 2024
1 parent b745925 commit 04280cb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected void onUpdate(final AjaxRequestTarget target) {

AjaxTextFieldPanel clientSecret = new AjaxTextFieldPanel(
"field", "clientSecret", new PropertyModel<>(clientAppTO, "clientSecret"), false);
clientSecret.setChoices(List.of(RandomStringUtils.randomAlphanumeric(15)));
clientSecret.setChoices(List.of(RandomStringUtils.secure().nextNumeric(15)));
fields.add(clientSecret.setRequired(true));

fields.add(new AjaxCheckBoxPanel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void login() {
doLogin(ADMIN_UNAME, ADMIN_PWD);

// create user with linked account
String email = "linkedAccount" + RandomStringUtils.randomNumeric(4) + "@syncope.apache.org";
String email = "linkedAccount" + RandomStringUtils.insecure().nextNumeric(4) + "@syncope.apache.org";
UserCR userCR = UserITCase.getSample(email);
String connObjectKeyValue = "uid=" + userCR.getUsername() + ",ou=People,o=isp";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public void thirdPartyTokenBadSignature()
notBeforeTime(currentTime);

AccessTokenJWSSigner customJWSSigner =
new AccessTokenJWSSigner(JWS_ALGORITHM, RandomStringUtils.randomAlphanumeric(512));
new AccessTokenJWSSigner(JWS_ALGORITHM, RandomStringUtils.insecure().nextAlphanumeric(512));

SignedJWT jwt = new SignedJWT(new JWSHeader(customJWSSigner.getJwsAlgorithm()), claimsSet.build());
jwt.sign(customJWSSigner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class LinkedAccountITCase extends AbstractITCase {
public void createWithLinkedAccountThenUpdateThenRemove() throws NamingException {
// 1. create user with linked account
UserCR userCR = UserITCase.getSample(
"linkedAccount" + RandomStringUtils.randomNumeric(5) + "@syncope.apache.org");
"linkedAccount" + RandomStringUtils.insecure().nextNumeric(5) + "@syncope.apache.org");
String connObjectKeyValue = "firstAccountOf" + userCR.getUsername();
String privilege = APPLICATION_SERVICE.read("mightyApp").getPrivileges().get(0).getKey();

Expand Down Expand Up @@ -157,7 +157,7 @@ public void createWithLinkedAccountThenUpdateThenRemove() throws NamingException
public void createWithLinkedAccountThenUpdateUsingPutThenRemove() throws NamingException {
// 1. create user with linked account
UserCR userCR = UserITCase.getSample(
"linkedAccount" + RandomStringUtils.randomNumeric(5) + "@syncope.apache.org");
"linkedAccount" + RandomStringUtils.insecure().nextNumeric(5) + "@syncope.apache.org");
String connObjectKeyValue = "uid=" + userCR.getUsername() + ",ou=People,o=isp";
String privilege = APPLICATION_SERVICE.read("mightyApp").getPrivileges().get(0).getKey();

Expand Down Expand Up @@ -197,7 +197,7 @@ public void createWithLinkedAccountThenUpdateUsingPutThenRemove() throws NamingE
public void createWithoutLinkedAccountThenAdd() throws NamingException {
// 1. create user without linked account
UserCR userCR = UserITCase.getSample(
"linkedAccount" + RandomStringUtils.randomNumeric(5) + "@syncope.apache.org");
"linkedAccount" + RandomStringUtils.insecure().nextNumeric(5) + "@syncope.apache.org");
String connObjectKeyValue = "uid=" + userCR.getUsername() + ",ou=People,o=isp";

UserTO user = createUser(userCR).getEntity();
Expand Down Expand Up @@ -246,7 +246,7 @@ public void createWithoutLinkedAccountThenAddAndUpdatePassword() throws NamingEx

// 2. create user without linked account
UserCR userCR = UserITCase.getSample(
"linkedAccount" + RandomStringUtils.randomNumeric(5) + "@syncope.apache.org");
"linkedAccount" + RandomStringUtils.insecure().nextNumeric(5) + "@syncope.apache.org");
String connObjectKeyValue = "uid=" + userCR.getUsername() + ",ou=People,o=isp";

UserTO user = createUser(userCR).getEntity();
Expand All @@ -269,7 +269,7 @@ public void createWithoutLinkedAccountThenAddAndUpdatePassword() throws NamingEx
userUR = new UserUR();
userUR.setKey(user.getKey());
userUR.getLinkedAccounts().add(new LinkedAccountUR.Builder().linkedAccountTO(account).build());

// 4.1 SYNCOPE-1824 update with a wrong password, a error must be raised
account.setPassword("password");
try {
Expand All @@ -280,7 +280,7 @@ public void createWithoutLinkedAccountThenAddAndUpdatePassword() throws NamingEx
assertEquals("InvalidUser [InvalidPassword: Password must be 10 or more characters in length.]",
sce.getMessage());
}

// set a correct password
account.setPassword("Password123");
user = updateUser(userUR).getEntity();
Expand Down Expand Up @@ -323,7 +323,7 @@ public void push() {
try {
// 1. create user with linked account
UserCR userCR = UserITCase.getSample(
"linkedAccount" + RandomStringUtils.randomNumeric(5) + "@syncope.apache.org");
"linkedAccount" + RandomStringUtils.insecure().nextNumeric(5) + "@syncope.apache.org");

LinkedAccountTO account = new LinkedAccountTO.Builder(RESOURCE_NAME_REST, connObjectKeyValue).build();
userCR.getLinkedAccounts().add(account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void unauthorizedOrForbidden() {

// service with invalid JWT string: 401 unauthorized
try {
CLIENT_FACTORY.create(RandomStringUtils.random(20, true, true)).self();
CLIENT_FACTORY.create(RandomStringUtils.insecure().next(20, true, true)).self();
fail("This should not happen");
} catch (NotAuthorizedException e) {
assertNotNull(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public void searchByRelationshipType() {

@Test
public void searchBySecurityAnswer() {
String securityAnswer = RandomStringUtils.randomAlphanumeric(10);
String securityAnswer = RandomStringUtils.insecure().nextAlphanumeric(10);
UserCR userCR = UserITCase.getUniqueSample("securityAnswer@syncope.apache.org");
userCR.setSecurityQuestion("887028ea-66fc-41e7-b397-620d7ea6dfbb");
userCR.setSecurityAnswer(securityAnswer);
Expand Down Expand Up @@ -1028,14 +1028,14 @@ void issueSYNCOPE1826() {
// ignore
}
}

try {
assertFalse(USER_SERVICE.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).details(false)
.fiql(SyncopeClient.getUserSearchConditionBuilder().is("username")
.equalToIgnoreCase("user test 1826").query()).build()).getResult().isEmpty());
assertFalse(ANY_OBJECT_SERVICE.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM)
.details(false).fiql(SyncopeClient.getAnyObjectSearchConditionBuilder(PRINTER).is("name")
.equalToIgnoreCase("obj test 1826").query()).build()).getResult().isEmpty());
.equalToIgnoreCase("obj test 1826").query()).build()).getResult().isEmpty());
assertFalse(USER_SERVICE.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).details(false)
.fiql(SyncopeClient.getUserSearchConditionBuilder().is("username")
.equalToIgnoreCase("user 1826 test").query()).build()).getResult().isEmpty());
Expand All @@ -1049,5 +1049,5 @@ void issueSYNCOPE1826() {
deleteUser("user test 182");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ public void haveIBeenPwned() {
assertEquals("InvalidPassword: Password pwned", e.getElements().iterator().next());
}

userCR.setPassword('1' + RandomStringUtils.randomAlphanumeric(10));
userCR.setPassword('1' + RandomStringUtils.insecure().nextAlphanumeric(10));
UserTO userTO = createUser(userCR).getEntity();
assertNotNull(userTO.getKey());
}
Expand Down

0 comments on commit 04280cb

Please sign in to comment.