private void createUser( String username, String fullname, String email, String password, boolean locked,
boolean validated )
{
UserManager userManager = securitySystem.getUserManager();
UserSecurityPolicy policy = securitySystem.getPolicy();
User user;
try
{
user = userManager.findUser( username );
}
catch ( UserNotFoundException e )
{
policy.setEnabled( false );
user = userManager.createUser( username, fullname, email );
user.setPassword( password );
user.setLocked( locked );
user.setValidated( validated );
user = userManager.addUser( user );
}
finally
{
policy.setEnabled( true );
}
try
{
roleManager.assignRole( "registered-user", user.getPrincipal().toString() );