Improve login and keyring
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 2 Oct 2011 13:04:41 +0000 (13:04 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 2 Oct 2011 13:04:41 +0000 (13:04 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4770 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

12 files changed:
basic/runtime/org.argeo.basic.nodeps/src/main/java/org/argeo/util/crypto/AbstractKeyring.java
demo/argeo_node_web.properties
security/plugins/org.argeo.security.equinox/src/main/java/org/argeo/security/equinox/SpringLoginModule.java
security/plugins/org.argeo.security.ui.rap/META-INF/jaas_default.txt
security/plugins/org.argeo.security.ui.rcp/META-INF/jaas_default.txt
security/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/AbstractLoginDialog.java
security/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/DefaultLoginDialog.java
server/plugins/org.argeo.jcr.ui.explorer/META-INF/MANIFEST.MF
server/plugins/org.argeo.jcr.ui.explorer/META-INF/spring/jcr.xml
server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/commands/AddRemoteRepository.java
server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/security/CaManager.java [deleted file]
server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/security/SecurityTypes.java [deleted file]

index 3e9da4c2cd501ee807879544a8c71b01d5625d3c..ee82fd944c072a1cebe5a17dd7376b73046d1801 100644 (file)
@@ -160,13 +160,13 @@ public abstract class AbstractKeyring implements Keyring {
                        } else {// setup keyring
                                TextOutputCallback textCb1 = new TextOutputCallback(
                                                TextOutputCallback.INFORMATION,
-                                               "Enter a master password");
+                                               "Enter a master password which will protect your private data");
                                TextOutputCallback textCb2 = new TextOutputCallback(
                                                TextOutputCallback.INFORMATION,
-                                               "It will encrypt your private data");
+                                               "(for example your credentials to third-party services)");
                                TextOutputCallback textCb3 = new TextOutputCallback(
                                                TextOutputCallback.INFORMATION,
-                                               "Don't forget it or your data is lost");
+                                               "Don't forget this password since the data cannot be read without it");
                                PasswordCallback confirmPasswordCb = new PasswordCallback(
                                                "Confirm password", false);
                                // first try
index 062aeeca15059de2a7a3c68408b4dee711a05329..bece10ceebce6eab27d9d749e24237c181a88385 100644 (file)
@@ -1,9 +1,9 @@
 argeo.osgi.start=\
 org.springframework.osgi.extender,\
+org.argeo.security.services,\
 org.argeo.node.repofactory.jackrabbit,\
 org.argeo.node.repo.jackrabbit,\
 org.argeo.security.dao.ldap,\
-org.argeo.security.services,\
 org.argeo.security.equinox,\
 org.eclipse.core.runtime,\
 org.eclipse.equinox.common,\
index ad6390d367a13333fc9f459a0199b7cc78bd121e..03f5f35ed960d2c8d529337f4c0f8cef7838cb2c 100644 (file)
@@ -7,7 +7,6 @@ import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.TextOutputCallback;
 import javax.security.auth.login.LoginException;
 
 import org.apache.commons.logging.Log;
@@ -28,8 +27,8 @@ public class SpringLoginModule extends SecurityContextLoginModule {
        private CallbackHandler callbackHandler;
 
        private Subject subject;
-       
-       private Long waitBetweenFailedLoginAttempts = 5*1000l;
+
+       private Long waitBetweenFailedLoginAttempts = 5 * 1000l;
 
        public SpringLoginModule() {
 
@@ -61,8 +60,6 @@ public class SpringLoginModule extends SecurityContextLoginModule {
                                subject.getPublicCredentials().clear();
 
                        // ask for username and password
-                       Callback label = new TextOutputCallback(
-                                       TextOutputCallback.INFORMATION, "Required login");
                        NameCallback nameCallback = new NameCallback("User");
                        PasswordCallback passwordCallback = new PasswordCallback(
                                        "Password", false);
@@ -71,7 +68,7 @@ public class SpringLoginModule extends SecurityContextLoginModule {
 
                        if (callbackHandler == null)
                                throw new LoginException("No call back handler available");
-                       callbackHandler.handle(new Callback[] { label, nameCallback,
+                       callbackHandler.handle(new Callback[] { nameCallback,
                                        passwordCallback });
 
                        // Set user name and password
index b6cbaa655da9bbadc18f6524f73e70c99b26c90b..72b66eabfa0044d5293d50d1263efdd6c1f1f897 100644 (file)
@@ -11,4 +11,8 @@ SPRING {
 SPRING_SECURITY_CONTEXT {
     org.eclipse.equinox.security.auth.module.ExtensionLoginModule sufficient
         extensionId="org.argeo.security.equinox.springSecurityContextLoginModule";
-};
\ No newline at end of file
+};
+
+KEYRING {
+    org.argeo.util.crypto.KeyringLoginModule required;
+};
index 98e39b54f8b7cd54e48855e99b920faeba103f10..bbabac66a197754f0e49937a3a6d63840502e45a 100644 (file)
@@ -17,11 +17,6 @@ WINDOWS {
         extensionId="org.argeo.security.equinox.osSpringLoginModule";
 };
 
-KEYRING_OLD {
-    org.eclipse.equinox.security.auth.module.ExtensionLoginModule required
-        extensionId="org.argeo.security.equinox.keyringLoginModule";
-};
-
 KEYRING {
     org.argeo.util.crypto.KeyringLoginModule required;
 };
index fecb80afc9107ecc46c2c440b61f4ee5669d112a..7c7104577517c604252fb8a4f4c2cdddb0a69e17 100644 (file)
@@ -79,6 +79,7 @@ public abstract class AbstractLoginDialog extends TrayDialog implements
                                isCancelled = false;
                                setBlockOnOpen(false);
                                open();
+
                                final Button okButton = getButton(IDialogConstants.OK_ID);
                                okButton.setText("Login");
                                okButton.addSelectionListener(new SelectionListener() {
@@ -170,6 +171,6 @@ public abstract class AbstractLoginDialog extends TrayDialog implements
 
        protected void configureShell(Shell shell) {
                super.configureShell(shell);
-               shell.setText("Login");
+               shell.setText("Autentication");
        }
 }
index 8c8554c6b77a0ef8ff2700acc4590f190617a4ba..208eefea8b1b84a644552b4ad485cf0df7487a7e 100644 (file)
@@ -1,6 +1,7 @@
 package org.argeo.security.ui.dialogs;
 
 import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.TextOutputCallback;
@@ -9,6 +10,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
@@ -18,6 +20,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
+/** Default authentication dialog, to be used as {@link CallbackHandler}. */
 public class DefaultLoginDialog extends AbstractLoginDialog {
 
        public DefaultLoginDialog() {
@@ -26,7 +29,6 @@ public class DefaultLoginDialog extends AbstractLoginDialog {
 
        protected DefaultLoginDialog(Shell parentShell) {
                super(parentShell);
-               // setBlockOnOpen(false);
        }
 
        protected Point getInitialSize() {
@@ -37,6 +39,12 @@ public class DefaultLoginDialog extends AbstractLoginDialog {
        protected Control createContents(Composite parent) {
                Control control = super.createContents(parent);
                parent.pack();
+               // Move the dialog to the center of the top level shell.
+               Rectangle shellBounds = Display.getCurrent().getBounds();
+               Point dialogSize = parent.getSize();
+               int x = shellBounds.x + (shellBounds.width - dialogSize.x) / 2;
+               int y = shellBounds.y + (shellBounds.height - dialogSize.y) / 2;
+               parent.setLocation(x, y);
                return control;
        }
 
@@ -123,35 +131,4 @@ public class DefaultLoginDialog extends AbstractLoginDialog {
 
        public void internalHandle() {
        }
-
-       // hack to simulate modal
-       // see
-       // http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.platform.jface/msg00181.html
-       // protected void setShellStyle(int newShellStyle) {
-       // // turn off APPLICATION_MODAL
-       // int newstyle = newShellStyle & ~SWT.APPLICATION_MODAL;
-       // // turn on MODELESS
-       // newstyle |= SWT.MODELESS;
-       // super.setShellStyle(newstyle);
-       // }
-       //
-       // public int open() {
-       //
-       // int retVal = super.open();
-       // // this will let the caller wait till OK, Cancel is
-       // // pressed, but will let the other GUI responsive
-       // pumpMessages();
-       // return retVal;
-       // }
-       //
-       // protected void pumpMessages() {
-       // Shell sh = getShell();
-       // Display disp = sh.getDisplay();
-       // while (!sh.isDisposed()) {
-       // if (!disp.readAndDispatch())
-       // disp.sleep();
-       // }
-       // disp.update();
-       // }
-
 }
index b903e07630acdb3730c69ccb9fe0d28c064b0c5e..4572f0a44a618cf8ef00f2a988b835b5a320a38f 100644 (file)
@@ -32,8 +32,6 @@ Import-Package: javax.jcr,
  org.argeo.jcr,
  org.argeo.jcr.security,
  org.argeo.jcr.spring,
- org.argeo.security.jcr,
- org.argeo.security.ui,
  org.argeo.util,
  org.argeo.util.crypto,
  org.eclipse.ui.forms,
index 728e005b5d7f63d4ba7c558488b5a233f5c0afa8..7869429d4e16fa612a718b1357613aab1284139c 100644 (file)
@@ -8,7 +8,7 @@
        <bean id="repositoryRegister" class="org.argeo.jcr.DefaultRepositoryRegister">
        </bean>
 
-       <bean id="nodeSession" class="org.argeo.security.jcr.SecureThreadBoundSession">
+       <bean id="nodeSession" class="org.argeo.jcr.spring.ThreadBoundSession">
                <property name="repository" ref="nodeRepository" />
        </bean>
 
index 4e120ac478a88afab8946ba058c490afe2f5a769..f784bb6985af2d20a8931ee37c6e14189c02e6ed 100644 (file)
@@ -157,7 +157,8 @@ public class AddRemoteRepository extends AbstractHandler implements
                                                        username.getText(), pwd);
                                        session = repository.login(sc);
                                        MessageDialog.openInformation(getParentShell(), "Success",
-                                                       "Connection to " + uri + "successful");
+                                                       "Connection to '" + uriText.getText()
+                                                                       + "' successful");
                                }
                        } catch (Exception e) {
                                ErrorFeedback.show(
diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/security/CaManager.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/security/CaManager.java
deleted file mode 100644 (file)
index be6687c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.jcr.security;
-
-
-public class CaManager {
-       // private Session session;
-
-}
diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/security/SecurityTypes.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/security/SecurityTypes.java
deleted file mode 100644 (file)
index c2bde84..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.jcr.security;
-
-public interface SecurityTypes {
-       public final static String SECURITY_CA = "security:ca";
-}