User Tools

Site Tools


Sidebar

Dave Orme muses about agile and functional programming.

My current work emphasizes SOA applications using Scala, Kubernetes, and AWS with a React-based SPA front-end. I'm also interested in progressive web applications and developer tools.


Blog

Scala, Clojure, and FP

Agile

The Cloud

Data-First Development

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)