Improve Eclipse security
[lgpl/argeo-commons.git] / security / eclipse / plugins / org.argeo.security.equinox / src / main / java / org / argeo / security / equinox / SpringLoginModule.java
index 4f8641c26db772f5a4a3d4510618ffc2bf901fea..3f88a00d94aac235fa6e0f136c606a151a0eb187 100644 (file)
@@ -10,15 +10,17 @@ import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.TextOutputCallback;
 import javax.security.auth.login.LoginException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.security.Authentication;
-import org.springframework.security.AuthenticationException;
 import org.springframework.security.AuthenticationManager;
-import org.springframework.security.BadCredentialsException;
 import org.springframework.security.context.SecurityContextHolder;
 import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
 import org.springframework.security.providers.jaas.SecurityContextLoginModule;
 
 public class SpringLoginModule extends SecurityContextLoginModule {
+       private final static Log log = LogFactory.getLog(SpringLoginModule.class);
+
        private AuthenticationManager authenticationManager;
        private Subject subject;
 
@@ -58,8 +60,8 @@ public class SpringLoginModule extends SecurityContextLoginModule {
                                        "Password", false);
 
                        if (callbackHandler == null) {
-                               // throw new LoginException("No call back handler available");
-                               return false;
+                               throw new LoginException("No call back handler available");
+                               // return false;
                        }
                        try {
                                callbackHandler.handle(new Callback[] { label, nameCallback,
@@ -94,6 +96,14 @@ public class SpringLoginModule extends SecurityContextLoginModule {
                }
        }
 
+       @Override
+       public boolean logout() throws LoginException {
+               if (log.isDebugEnabled())
+                       log.debug("Log out "
+                                       + subject.getPrincipals().iterator().next().getName());
+               return super.logout();
+       }
+
        /**
         * Register an {@link Authentication} in the security context.
         *