Skip to content

Instantly share code, notes, and snippets.

@thaniaclair
Last active December 17, 2015 05:49
Show Gist options
  • Select an option

  • Save thaniaclair/5561207 to your computer and use it in GitHub Desktop.

Select an option

Save thaniaclair/5561207 to your computer and use it in GitHub Desktop.
Interceptor que verifica se o {@link Usuario} fez a autenticação com senha.
import static br.com.sebrae.action.BaseAction.NO_PASSWORD;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import br.com.sebrae.action.BaseAction;
import br.com.sebrae.model.Usuario;
import br.com.sebrae.util.ActionRetriever;
import br.com.sebrae.util.SessionKeys;
import com.opensymphony.xwork2.ActionInvocation;
/**
* Interceptor que verifica se o {@link Usuario} fez a autenticação com senha.
* @author thania
* @since 2013-04-08
*/
public class CompleteLoginInterceptor extends BaseInterceptor {
private static final long serialVersionUID = 4745824425259102232L;
/**
* {@inheritDoc}
*/
@Override
public String intercept(ActionInvocation act) throws Exception {
BaseAction action = (BaseAction) act.getAction();
if (action.isCompleteLogged()) return act.invoke();
HttpServletRequest request = ServletActionContext.getRequest();
String currentURL = new ActionRetriever(request).getCurrentURL();
action.getSession().put(SessionKeys.PREVIOUS_URL.name(), currentURL);
return NO_PASSWORD;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment