Use IllegalArgumentException for invalid characters found in authority and person name (#980)

This commit is contained in:
Abdul Mohammed
2020-05-01 17:58:35 +01:00
parent 778e5146fb
commit 82d99d68cd
4 changed files with 6 additions and 6 deletions

View File

@@ -1670,7 +1670,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
{
if (authorityName.indexOf(illegalCharacter) != -1)
{
throw new AuthorityException("Group name contains characters that are not permitted: "+authorityName.charAt(authorityName.indexOf(illegalCharacter)));
throw new IllegalArgumentException("Group name contains characters that are not permitted: "+authorityName.charAt(authorityName.indexOf(illegalCharacter)));
}
}
}

View File

@@ -1797,7 +1797,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
{
if (userName.indexOf(illegalCharacter) != -1)
{
throw new PersonException("Person name contains characters that are not permitted: "+userName.charAt(userName.indexOf(illegalCharacter)));
throw new IllegalArgumentException("Person name contains characters that are not permitted: "+userName.charAt(userName.indexOf(illegalCharacter)));
}
}
}

View File

@@ -261,9 +261,9 @@ public class AuthorityServiceTest extends TestCase
try
{
authorityService.createAuthority(AuthorityType.GROUP, groupName);
fail("AuthorityException not caught for illegalCharacter: " +groupName.charAt(groupName.indexOf(illegalCharacter)));
fail("IllegalArgumentException not caught for illegalCharacter: " +groupName.charAt(groupName.indexOf(illegalCharacter)));
}
catch (AuthorityException ignored)
catch (IllegalArgumentException ignored)
{
// Expected
}

View File

@@ -467,9 +467,9 @@ public class PersonTest extends TestCase
try
{
personService.createPerson(createDefaultProperties(personName, "Some", "User", "some.user@example.com", "alfresco", rootNodeRef));
fail("PersonException not caught for illegalCharacter: " +personName.charAt(personName.indexOf(illegalCharacter)));
fail("IllegalArgumentException not caught for illegalCharacter: " +personName.charAt(personName.indexOf(illegalCharacter)));
}
catch (PersonException ignored)
catch (IllegalArgumentException ignored)
{
// Expected
}