Package auxiliar

Source Code of auxiliar.SecurityInterceptor

package auxiliar;

import javax.servlet.http.HttpSession;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.controller.ExecutionContext;
import net.sourceforge.stripes.controller.Interceptor;
import net.sourceforge.stripes.controller.Intercepts;
import net.sourceforge.stripes.controller.LifecycleStage;
import net.sourceforge.stripes.controller.UrlBindingFactory;

@Intercepts(LifecycleStage.ActionBeanResolution)
public class SecurityInterceptor implements Interceptor {

    public Resolution intercept(ExecutionContext execContext) throws Exception {
        Resolution resolution = execContext.proceed();
        ActionBean actionBean = execContext.getActionBean();
        String path = UrlBindingFactory.getInstance().getBindingPrototype(
                actionBean.getClass()).getPath();
        if (path.contains("validareConturi") || path.contains("stergereConturiGeologi") || path.contains("Admin.action?datePersonale")) {
            HttpSession session = execContext.getActionBeanContext().getRequest().getSession(false);
            if (session == null || session.getAttribute("admin") == null || session.getAttribute("admin").equals(0)) {
                resolution = new ForwardResolution("/WEB-INF/jsp/home.jsp");
            }
        } else if (path.contains("/Amplasament") || path.contains("/Beneficiar") || path.contains("/Compresibilitate") || path.contains("/Compresiune") || path.contains("/DensitateaPamanturilor") || path.contains("/Foraj") || path.contains("/MetodaCernerii") || path.contains("/MetodaSedimentarii") || path.contains("/Proba") || path.contains("/Rezultate") || path.contains("/Stanta") || path.contains("/Strat") || path.contains("/VizualizareForaj") || path.contains("/W") || path.contains("/WL") || path.contains("/WP") || path.contains("datePersonale") || path.contains("proiecteGeologSef")) {
            HttpSession session = execContext.getActionBeanContext().getRequest().getSession(false);
            if (session == null || session.getAttribute("user") == null || session.getAttribute("user").equals(0) || session.getAttribute("user").equals(-1)) {
                resolution = new ForwardResolution("/WEB-INF/jsp/home.jsp");
            }
        }
        return resolution;
    }
}
TOP

Related Classes of auxiliar.SecurityInterceptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.