Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-3781

Support a mechanism for modules to execute code in Daemon thread

    XMLWordPrintable

    Details

    • Complexity:
      Medium

      Description

      Currently, if a module wants to execute code with elevated privileges, it needs to either use proxy privileges, or else store a username and password and use those to authenticate. This leads to ugly code and/or security flaws.

      Instead, we need a mechanism for a module to run code within a Daemon thread that has the appropriate privileges for the module (at first this will always be super user privileges, but in the future, Daemon can impose tighter control).

      Proposed solution:

      1. When the module framework starts/refreshes a module, it should create a secure token for each module, look for a method on each module's activator like
        void setDaemonToken(DaemonToken)

        . If present, we inject the daemon token for the module.

      2. Add methods like the following, which throw an exception if you don't pass back exactly the token that the module architecture gave you:
        Thread Daemon.executeInDaemonThread(Runnable, DaemonToken)
        void Daemon.executeInDaemonThreadAndWait(Runnable, DaemonToken)

      Note that DaemonToken is a pretty bad name, so try to think of something better.

      PIH needs this implemented in a (backwards-compatible) way that will let us take advantage of this in 1.9.2.

        Attachments

          Activity

            People

            Assignee:
            raff Rafal Korytkowski
            Reporter:
            darius Darius Jazayeri [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3 hours
                3h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours
                3h