mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Use IllegalArgumentException for invalid characters found in authority and person name (#980)
This commit is contained in:
@@ -1670,7 +1670,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
|||||||
{
|
{
|
||||||
if (authorityName.indexOf(illegalCharacter) != -1)
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1797,7 +1797,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
|||||||
{
|
{
|
||||||
if (userName.indexOf(illegalCharacter) != -1)
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -261,9 +261,9 @@ public class AuthorityServiceTest extends TestCase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
authorityService.createAuthority(AuthorityType.GROUP, groupName);
|
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
|
// Expected
|
||||||
}
|
}
|
||||||
|
@@ -467,9 +467,9 @@ public class PersonTest extends TestCase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
personService.createPerson(createDefaultProperties(personName, "Some", "User", "some.user@example.com", "alfresco", rootNodeRef));
|
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
|
// Expected
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user