import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.argeo.security.equinox.CurrentUser;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.ErrorSupportProvider;
-import org.eclipse.jface.util.Policy;
-import org.eclipse.jface.window.Window.IExceptionHandler;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.WorkbenchAdvisor;
-import org.eclipse.ui.internal.statushandlers.StackTraceSupportArea;
-import org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager;
public abstract class AbstractSecureApplication implements IApplication {
private static final Log log = LogFactory
protected abstract WorkbenchAdvisor createWorkbenchAdvisor();
+ @SuppressWarnings("unchecked")
public Object start(IApplicationContext context) throws Exception {
Integer returnCode = null;
try {
String username = null;
Exception loginException = null;
+ Subject subject = null;
try {
- username = CurrentUser.getUsername();
+ SecureApplicationActivator.getLoginContext().login();
+ subject = SecureApplicationActivator.getLoginContext()
+ .getSubject();
+
+ // username = CurrentUser.getUsername();
} catch (Exception e) {
loginException = e;
+ e.printStackTrace();
}
- if (username == null) {
+ if (subject == null) {
IStatus status = new Status(IStatus.ERROR,
"org.argeo.security.application", "Login is mandatory",
loginException);
}
if (log.isDebugEnabled())
log.debug("Logged in as " + username);
- returnCode = (Integer) Subject.doAs(CurrentUser.getSubject(),
- getRunAction(display));
- if (log.isDebugEnabled())
- log.debug("secure action completed");
- CurrentUser.logout();
+ returnCode = (Integer) Subject.doAs(subject, getRunAction(display));
+ SecureApplicationActivator.getLoginContext().logout();
return processReturnCode(returnCode);
} catch (Exception e) {
// e.printStackTrace();
if (log.isDebugEnabled())
log.debug("workbench stopped");
- String username = CurrentUser.getUsername();
- if (log.isDebugEnabled())
- log.debug("workbench stopped, logged in as " + username);
+ // String username = CurrentUser.getUsername();
+ // if (log.isDebugEnabled())
+ // log.debug("workbench stopped, logged in as " + username);
}