]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/auth/AnonymousLoginModule.java
- Improve CMS login (HTTP session now supported)
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / auth / AnonymousLoginModule.java
index 372f27e60bc0205ff54d77c8cc729b4430e2bf4d..855524961c86e390fe14b742e90c53ce95362c86 100644 (file)
@@ -43,19 +43,22 @@ public class AnonymousLoginModule extends AbstractLoginModule {
                        InterruptedException {
                Locale selectedLocale = null;
                // multi locale
-               if (availableLocales != null && !availableLocales.trim().equals("")) {
-                       LocaleCallback localeCallback = new LocaleCallback(availableLocales);
-                       callbackHandler.handle(new Callback[] { localeCallback });
-                       selectedLocale = localeCallback.getSelectedLocale();
-               } else {
-                       callbackHandler.handle(new Callback[] {});
-               }
+               if (callbackHandler != null)
+                       if (availableLocales != null && !availableLocales.trim().equals("")) {
+                               LocaleCallback localeCallback = new LocaleCallback(
+                                               availableLocales);
+                               callbackHandler.handle(new Callback[] { localeCallback });
+                               selectedLocale = localeCallback.getSelectedLocale();
+                       } else {
+                               callbackHandler.handle(new Callback[] {});
+                       }
 
                List<GrantedAuthorityPrincipal> authorities = Collections
                                .singletonList(new GrantedAuthorityPrincipal(
                                                KernelHeader.ROLE_ANONYMOUS));
                AnonymousAuthenticationToken anonymousToken = new AnonymousAuthenticationToken(
-                               Activator.getSystemKey(), null, authorities);
+                               Activator.getSystemKey(), KernelHeader.USERNAME_ANONYMOUS,
+                               authorities);
 
                Authentication auth = getAuthenticationManager().authenticate(
                                anonymousToken);