@SuppressWarnings("unchecked")
public boolean login() throws LoginException
{
if (getContextMethod != null)
{
Credentials authCredentials = null;
try
{
HttpServletRequest request = getCurrentHttpServletRequest();
// This can be the case with CLI login
if (request == null)
{
log.debug("Unable to find HTTPServletRequest.");
return false;
}
authCredentials = (Credentials)request.getSession().getAttribute(AUTHENTICATED_CREDENTIALS);
// If authenticated credentials were presented in HTTP session, it means that we were already logged on different cluster node
// with this HTTP session. We don't need to validate password again in this case (We don't have password anyway)
if (authCredentials != null)
{
Authenticator authenticator = (Authenticator)getContainer().getComponentInstanceOfType(Authenticator.class);
if (authenticator == null)
{
throw new LoginException("No Authenticator component found, check your configuration");
}
String username = authCredentials.getUsername();
Identity identity = authenticator.createIdentity(username);
sharedState.put("exo.security.identity", identity);
sharedState.put("javax.security.auth.login.name", username);