User Tools

Site Tools


Sidebar

Dave Orme muses about data-first development.

My current work emphasizes data engineering and analysis using Kubernetes, Clojure, Scala, Eclipse, and Google Cloud Platform or AWS.


Blog

The Cloud

Scala, Clojure, and FP

Data-First Development

Agile

Older work

Coconut Palm Software home


Donate Bitcoin:

1Ecnr9vtkC8b9FvmQjQaJ9ZsHB127UzVD6

Keywords:

Kubernetes, Docker, Streaming Data, Spark, Scala, Clojure, OSGi, Karaf, GCP, AWS, SQL

Disclaimer:

Everything I say here is my own opinion and not necessarily that of my employer.

blog:implementing_login_in_rcp_applications

Implementing Login in RCP Applications

Recently, the eclipsepowered discussion mailing list has been talking about how to implement login in an Eclipse RCP application. In the discussion, I described two major use cases:

 1. RCP is a standard framework for deploying corporate applications.
    Logging into RCP implies logging into all of your corporate
    applications.
 2. RCP is a container for many applications, some of which require a
    login.

Olivier Crameri [olivier.crameri <at> netoxygen.ch] then proposed an elegant solution to use case #1: implement your login in your RCP application's IPlatformRunnable class, after initializing the SWT Display object, but before running PlatformUI.createAndRunWorkbench.

Here's his solution with a few modifications by myself:

The IPlatformRunnable class looks something like the following:

    public class Client implements IPlatformRunnable {
 
        private static RootRMIInterface serverConnection = null;
 
        public static getDefaultConnection() {
            return serverConnection;
        }
 
        public Object run(Object args) {
            WorkbenchAdvisor workbenchAdvisor = new ClientWorkbenchAdvisor();
            Display display = PlatformUI.createDisplay();
 
            if (authenticate(display)) {
                int returnCode = PlatformUI.createAndRunWorkbench(display,
                                            workbenchAdvisor); 
 
                if (returnCode == PlatformUI.RETURN_RESTART) {
                    return IPlatformRunnable.EXIT_RESTART;
                } else {
                    return IPlatformRunnable.EXIT_OK;
                } 
 
            } else
                return IPlatformRunnable.EXIT_OK;
        } 
 
        private boolean authenticate(Display display) {
            Shell shell = new Shell(display);
            LoginDialog loginDialog = new LoginDialog(shell);
            loginDialog.setBlockOnOpen(true);
            loginDialog.open();
    	Client.serverConnection = loginDialog.serverConnection;
            return loginDialog.isAuthenticated;
        } 
 
    }

The LoginDialog object performs the following functions:

  • Attempts to authenticate the user using the username/password pair that was entered.
  • If authentication is unsuccessful, the isAuthenticated field is set to false.
  • If authentication is successful, the RMI server returns a new RMI object stub back to the LoginDialog object.

After the login dialog authenticates the user, the main Clientclass then retrieves the RMI stub and makes it available to all other classes in the application via the Singleton pattern.

~~LINKBACK~~ ~~DISCUSSION:closed~~

blog/implementing_login_in_rcp_applications.txt · Last modified: 2014/10/17 22:08 (external edit)