prevent NPE

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1436670 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-21 22:42:59 +00:00
parent e12772a856
commit 8e61f56f9d

View File

@ -53,7 +53,7 @@ public class GuestUserEnvironmentCheck
private SecuritySystem securitySystem; private SecuritySystem securitySystem;
@Inject @Inject
@Named( value = "userConfiguration#default" ) @Named(value = "userConfiguration#default")
private UserConfiguration config; private UserConfiguration config;
/** /**
@ -86,20 +86,29 @@ public void validateEnvironment( List<String> violations )
catch ( UserManagerException ume ) catch ( UserManagerException ume )
{ {
violations.add( "unable to initialize guest user properly: " + ume.getMessage() ); violations.add( "unable to initialize guest user properly: " + ume.getMessage() );
checked = true;
return; return;
} }
policy.setEnabled( true ); policy.setEnabled( true );
} }
try if ( guest != null )
{ {
roleManager.assignRole( config.getString( UserConfigurationKeys.DEFAULT_GUEST ), guest.getUsername() );
}
catch ( RoleManagerException rpe )
{
violations.add( "unable to initialize guest user properly: " + rpe.getMessage() );
}
try
{
roleManager.assignRole( config.getString( UserConfigurationKeys.DEFAULT_GUEST ),
guest.getUsername() );
}
catch ( RoleManagerException rpe )
{
violations.add( "unable to initialize guest user properly: " + rpe.getMessage() );
}
}
else
{
violations.add( "cannot find neither create guest user" );
}
checked = true; checked = true;
} }
} }