Salome HOME
Compare method signature and DocToCompareDTO are added.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / kernel / RealmLoginModule.java
index 0a8eeb7f1b97787303577eab4e541fa3c5ee8df7..e9b3ed0b19df3df4cb2991bc6a3fa36941776a32 100644 (file)
@@ -24,42 +24,64 @@ import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
 import org.splat.service.ServiceLocatorImpl;
 
+/**
+ * Implementation of login module for SIMAN.
+ */
 public class RealmLoginModule implements LoginModule {
 
-       // Initial state
+       /**
+        * The logger.
+        */
+       private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
+
+       /**
+        * Initial state.
+        */
        private transient Subject _subject;
        private transient CallbackHandler _callbackHandler;
        // private Map sharedState;
        // private Map options;
 
-       // Authentication status
+       /**
+        * Authentication status.
+        */
        private transient boolean _succeeded = false;
        private transient boolean _commit = false;
 
-       // Principal
+       /**
+        * Principal.
+        */
        private transient User _identity = null;
 
-       private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
-
        // ==============================================================================================================================
        // Constructor
        // ==============================================================================================================================
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler,
+        *      java.util.Map, java.util.Map)
+        */
        public void initialize(final Subject user, final CallbackHandler handler,
                        final Map<String, ?> state, final Map<String, ?> opts) {
-               // --------------------------------------------------------------------------------------------------------
                _subject = user;
                _callbackHandler = handler;
                // sharedState = state;
                // options = opts;
                // debug = "true".equalsIgnoreCase((String)options.get("debug"));
-               //_logger = Logger.getLogger(RealmLoginModule.class);
+               // _logger = Logger.getLogger(RealmLoginModule.class);
        }
 
        // ==============================================================================================================================
        // Public services
        // ==============================================================================================================================
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#login()
+        */
        public boolean login() throws LoginException {
                boolean res = false;
                try {
@@ -102,13 +124,19 @@ public class RealmLoginModule implements LoginModule {
                } catch (java.io.IOException ioe) {
                        throw new LoginException(ioe.getMessage()); // RKV: NOPMD: The message is sent into the constructor
                } catch (UnsupportedCallbackException uce) {
-                       throw new LoginException("Error: " + uce.getCallback().toString() // RKV: NOPMD: Stacktrace is printed
+                       throw new LoginException("Error: " // RKV: NOPMD: Stacktrace is printed
+                                       + uce.getCallback().toString()
                                        + " not available to garner authentication information"
                                        + " from the user");
                }
                return res;
        }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#commit()
+        */
        public boolean commit() throws LoginException {
                boolean res = _succeeded;
                if (res) {
@@ -121,19 +149,29 @@ public class RealmLoginModule implements LoginModule {
                return res;
        }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#abort()
+        */
        public boolean abort() throws LoginException {
                boolean res = _succeeded;
                if (res) {
-                       if (_succeeded && !_commit) {
+                       if (_commit) {
+                               logout();
+                       } else {
                                _identity = null;
                                _succeeded = false;
-                       } else {
-                               logout();
                        }
                }
                return res;
        }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#logout()
+        */
        public boolean logout() throws LoginException {
                _subject.getPrincipals().remove(_identity);
                _identity = null;