]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - security/plugins/org.argeo.security.ui.rcp/src/main/java/org/argeo/security/ui/rcp/AbstractSecureApplication.java
Update license headers
[lgpl/argeo-commons.git] / security / plugins / org.argeo.security.ui.rcp / src / main / java / org / argeo / security / ui / rcp / AbstractSecureApplication.java
index 7487567a8ba03c01557e95be665111c569f688d7..5d9d9d763827452eaa4c8a1f5b0854f6d48ad471 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.argeo.security.ui.rcp;
 
 import java.security.PrivilegedAction;
@@ -20,6 +35,8 @@ import org.eclipse.ui.application.WorkbenchAdvisor;
  * RCP workbench initialization
  */
 public abstract class AbstractSecureApplication implements IApplication {
+       final static String NODE_REPO_URI = "argeo.node.repo.uri";
+
        private static final Log log = LogFactory
                        .getLog(AbstractSecureApplication.class);
 
@@ -29,20 +46,27 @@ public abstract class AbstractSecureApplication implements IApplication {
 
        public Object start(IApplicationContext context) throws Exception {
                // wait for the system to be initialized
-//             try {
-//                     Thread.sleep(3000);
-//             } catch (Exception e2) {
-//                     // silent
-//             }
+               // try {
+               // Thread.sleep(3000);
+               // } catch (Exception e2) {
+               // // silent
+               // }
+
+               boolean remote = System.getProperty(NODE_REPO_URI) != null;
 
                // choose login context
                final ILoginContext loginContext;
-               if (OperatingSystem.os == OperatingSystem.WINDOWS)
-                       loginContext = SecureApplicationActivator
-                                       .createLoginContext(SecureApplicationActivator.CONTEXT_WINDOWS);
-               else
+               if (remote) {
                        loginContext = SecureApplicationActivator
-                                       .createLoginContext(SecureApplicationActivator.CONTEXT_NIX);
+                                       .createLoginContext(SecureApplicationActivator.CONTEXT_REMOTE);
+               } else {
+                       if (OperatingSystem.os == OperatingSystem.WINDOWS)
+                               loginContext = SecureApplicationActivator
+                                               .createLoginContext(SecureApplicationActivator.CONTEXT_WINDOWS);
+                       else
+                               loginContext = SecureApplicationActivator
+                                               .createLoginContext(SecureApplicationActivator.CONTEXT_NIX);
+               }
 
                final Display display = PlatformUI.createDisplay();
 
@@ -69,12 +93,12 @@ public abstract class AbstractSecureApplication implements IApplication {
                                .getName();
                if (log.isDebugEnabled())
                        log.debug(username + " logged in");
-               display.disposeExec(new Runnable() {
-                       public void run() {
-                               log.debug("Display disposed");
-                               logout(loginContext, username);
-                       }
-               });
+//             display.disposeExec(new Runnable() {
+//                     public void run() {
+//                             log.debug("Display disposed");
+//                             logout(loginContext, username);
+//                     }
+//             });
 
                try {
                        PrivilegedAction<?> privilegedAction = new PrivilegedAction<Object>() {