Remove dependency to Spring Security
[lgpl/argeo-commons.git] / org.argeo.security.ui.rap / src / org / argeo / security / ui / rap / SecureEntryPoint.java
index eec4d0bd0665e2ede831f23a0e23ac5b28046d04..c27fbc70e4dda02e09b089cf764dad9588d945fe 100644 (file)
@@ -23,7 +23,7 @@ import java.security.PrivilegedAction;
 
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.CredentialNotFoundException;
+import javax.security.auth.login.FailedLoginException;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 import javax.security.auth.x500.X500Principal;
@@ -43,7 +43,6 @@ import org.eclipse.rap.rwt.RWT;
 import org.eclipse.rap.rwt.application.EntryPoint;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PlatformUI;
-import org.springframework.security.authentication.BadCredentialsException;
 
 /**
  * RAP entry point with login capabilities. Once the user has been
@@ -117,14 +116,12 @@ public class SecureEntryPoint implements EntryPoint {
 
                                        if (log.isDebugEnabled())
                                                log.debug("Authenticated " + subject);
+                               } catch (FailedLoginException e) {
+                                       MessageDialog.openInformation(display.getActiveShell(),
+                                                       "Bad Credentials", e.getMessage());
+                                       // retry login
+                                       continue tryLogin;
                                } catch (LoginException e) {
-                                       BadCredentialsException bce = wasCausedByBadCredentials(e);
-                                       if (bce != null) {
-                                               MessageDialog.openInformation(display.getActiveShell(),
-                                                               "Bad Credentials", bce.getMessage());
-                                               // retry login
-                                               continue tryLogin;
-                                       }
                                        return processLoginDeath(display, e);
                                }
                        }
@@ -192,20 +189,6 @@ public class SecureEntryPoint implements EntryPoint {
 
        }
 
-       /** Recursively look for {@link BadCredentialsException} in the root causes. */
-       private BadCredentialsException wasCausedByBadCredentials(Throwable t) {
-               if (t instanceof BadCredentialsException)
-                       return (BadCredentialsException) t;
-
-               if (t instanceof CredentialNotFoundException)
-                       return new BadCredentialsException("Login canceled");
-
-               if (t.getCause() != null)
-                       return wasCausedByBadCredentials(t.getCause());
-               else
-                       return null;
-       }
-
        /**
         * If there is a {@link ThreadDeath} in the root causes, rethrow it
         * (important for RAP cleaning mechanism)