]> source.dussan.org Git - archiva.git/commitdiff
prevent NPE
authorOlivier Lamy <olamy@apache.org>
Mon, 21 Jan 2013 22:42:59 +0000 (22:42 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 21 Jan 2013 22:42:59 +0000 (22:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1436670 13f79535-47bb-0310-9956-ffa450edef68

redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/GuestUserEnvironmentCheck.java

index fcbcb94f1cbd5e11c8223347f2c2efeada2687f1..c004ebcc6a9420c2388b80adad83a832f78cf9c2 100644 (file)
@@ -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;
         }
     }