From 8e61f56f9d519fcf32653b740cee511a242009f2 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 21 Jan 2013 22:42:59 +0000 Subject: [PATCH] prevent NPE git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1436670 13f79535-47bb-0310-9956-ffa450edef68 --- .../security/GuestUserEnvironmentCheck.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/GuestUserEnvironmentCheck.java b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/GuestUserEnvironmentCheck.java index fcbcb94f1..c004ebcc6 100644 --- a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/GuestUserEnvironmentCheck.java +++ b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/GuestUserEnvironmentCheck.java @@ -53,7 +53,7 @@ public class GuestUserEnvironmentCheck private SecuritySystem securitySystem; @Inject - @Named( value = "userConfiguration#default" ) + @Named(value = "userConfiguration#default") private UserConfiguration config; /** @@ -86,20 +86,29 @@ public class GuestUserEnvironmentCheck catch ( UserManagerException ume ) { violations.add( "unable to initialize guest user properly: " + ume.getMessage() ); + checked = true; return; } policy.setEnabled( true ); } - try + if ( guest != null ) { - roleManager.assignRole( config.getString( UserConfigurationKeys.DEFAULT_GUEST ), guest.getUsername() ); + + try + { + roleManager.assignRole( config.getString( UserConfigurationKeys.DEFAULT_GUEST ), + guest.getUsername() ); + } + catch ( RoleManagerException rpe ) + { + violations.add( "unable to initialize guest user properly: " + rpe.getMessage() ); + } } - catch ( RoleManagerException rpe ) + else { - violations.add( "unable to initialize guest user properly: " + rpe.getMessage() ); + violations.add( "cannot find neither create guest user" ); } - checked = true; } } -- 2.39.5