本文整理汇总了Java中net.sourceforge.stripes.controller.ExecutionContext.getHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionContext.getHandler方法的具体用法?Java ExecutionContext.getHandler怎么用?Java ExecutionContext.getHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.stripes.controller.ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.getHandler方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
ActionBean actionBean = context.getActionBean();
Method handler = context.getHandler();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
Dispatch dispatch = DispatcherUtil.getDispatch(request);
if(SecurityLogic.isAllowed(request, dispatch, actionBean, handler)) {
logger.debug("Security check passed.");
return context.proceed();
} else {
return new ForbiddenAccessResolution();
}
}
示例2: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
ActionBean actionBean = context.getActionBean();
Method handler = context.getHandler();
logger.debug("Checking guards on {}", handler);
if(ButtonsLogic.doGuardsPass(actionBean, handler)) {
return context.proceed();
} else {
logger.warn("Operation not permitted. Method: " + context.getHandler());
if(actionBean instanceof Guarded) {
return ((Guarded) actionBean).guardsFailed(handler);
} else {
return new ErrorResolution(CONFLICT);
}
}
}
示例3: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
if(context.getHandler() != null && context.getHandler().isAnnotationPresent(ControlsCache.class)) {
return context.proceed();
}
HttpServletResponse response = context.getActionBeanContext().getResponse();
// Avoid caching of dynamic pages
//HTTP 1.0
response.setHeader(ServletConstants.HTTP_PRAGMA, ServletConstants.HTTP_PRAGMA_NO_CACHE);
response.setDateHeader(ServletConstants.HTTP_EXPIRES, 0);
//HTTP 1.1
response.addHeader(ServletConstants.HTTP_CACHE_CONTROL, ServletConstants.HTTP_CACHE_CONTROL_NO_CACHE);
response.addHeader(ServletConstants.HTTP_CACHE_CONTROL, ServletConstants.HTTP_CACHE_CONTROL_NO_STORE);
//response.addHeader(ServletConstants.HTTP_CACHE_CONTROL, ServletConstants.HTTP_CACHE_CONTROL_MUST_REVALIDATE);
//response.addHeader(ServletConstants.HTTP_CACHE_CONTROL, ServletConstants.HTTP_CACHE_CONTROL_MAX_AGE + 0);
return context.proceed();
}
示例4: assertAuthorized
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public void assertAuthorized(final ExecutionContext context) throws AuthorizationException {
super.assertAuthorized(new MethodInvocation() {
@Override
public Object proceed() throws Throwable {
return null;
}
@Override
public Method getMethod() {
return context.getHandler();
}
@Override
public Object[] getArguments() {
return new Object[0];
}
@Override
public Object getThis() {
return context.getActionBean();
}
});
}
示例5: getAccessAllowed
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
/**
* Determine if the security manager allows access.
* The return value of this method is the same as the result of
* {@link SecurityManager#getAccessAllowed(ActionBean,Method) getAccessAllowed(ActionBean, Method)}
* of the current security manager, unless there is nu security manager (in which case the event is allowed).
*
* @param executionContext the current execution context
* @return whether or not the security manager allows access, if a decision can be made
*/
protected Boolean getAccessAllowed(ExecutionContext executionContext)
{
LOG.debug("Checking access for " + executionContext + " at " + executionContext.getLifecycleStage());
Boolean accessAllowed;
if (securityManager == null)
{
LOG.debug("There is no security manager, so access is allowed by default.");
accessAllowed = true;
}
else
{
ActionBean actionBean = executionContext.getActionBean();
Method handler = executionContext.getHandler();
accessAllowed = securityManager.getAccessAllowed(actionBean, handler);
LOG.debug("Security manager returned access allowed: " + accessAllowed);
}
return accessAllowed;
}
示例6: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBean actionBean = context.getActionBean();
Method handler = context.getHandler();
logger.debug("Checking guards on {}", handler);
if(ButtonsLogic.doGuardsPass(actionBean, handler)) {
return context.proceed();
} else {
logger.warn("Operation not permitted.");
return new ErrorResolution(CONFLICT);
}
}
示例7: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
ActionBean actionBean = context.getActionBean();
Method handler = context.getHandler();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
Subject subject = SecurityUtils.getSubject();
if (!SecurityLogic.satisfiesRequiresAdministrator(request, actionBean, handler)) {
return new ForbiddenAccessResolution();
}
logger.debug("Checking page permissions");
boolean isNotAdmin = !SecurityLogic.isAdministrator(request);
if (isNotAdmin) {
ServletContext servletContext = context.getActionBeanContext().getServletContext();
Configuration configuration = (Configuration) servletContext.getAttribute(BaseModule.PORTOFINO_CONFIGURATION);
Permissions permissions;
Dispatch dispatch = DispatcherUtil.getDispatch(request);
String resource;
boolean allowed;
if(dispatch != null) {
logger.debug("The protected resource is a page action");
resource = dispatch.getLastPageInstance().getPath();
allowed = SecurityLogic.hasPermissions(configuration, dispatch, subject, handler);
} else {
logger.debug("The protected resource is a plain Stripes ActionBean");
resource = request.getRequestURI();
permissions = new Permissions();
allowed = SecurityLogic.hasPermissions
(configuration, permissions, subject, handler, actionBean.getClass());
}
if(!allowed) {
logger.info("Access to {} is forbidden", resource);
return new ForbiddenAccessResolution();
}
}
logger.debug("Security check passed.");
return context.proceed();
}