/**
*
* @author Daniel Brunier-Coulin
- * @copyright OPEN CASCADE 2012
+ * @copyright OPEN CASCADE 2012-2014
*/
import java.util.Calendar;
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 {
} 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) {
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;