本文整理汇总了Java中net.sourceforge.stripes.controller.ExecutionContext.getActionBean方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionContext.getActionBean方法的具体用法?Java ExecutionContext.getActionBean怎么用?Java ExecutionContext.getActionBean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.stripes.controller.ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.getActionBean方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
HttpServletRequest request = context.getActionBeanContext().getRequest();
String url = HttpUtil.getRequestedPath(request);
if (request.getQueryString() != null)
url = url + '?' + request.getQueryString();
log.debug("Intercepting request: ", url);
Resolution resolution = context.proceed();
// A null resolution here indicates a normal flow to the next stage
boolean authed = ((BugzookyActionBeanContext) context.getActionBeanContext()).getUser() != null;
if (!authed && resolution == null) {
ActionBean bean = context.getActionBean();
if (bean != null && !bean.getClass().isAnnotationPresent(Public.class)) {
log.warn("Thwarted attempted to access ", bean.getClass().getSimpleName());
return new RedirectResolution(LoginActionBean.class).addParameter("targetUrl", url);
}
}
log.debug("Allowing public access to ", context.getActionBean().getClass().getSimpleName());
return resolution;
}
示例2: 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();
}
}
示例3: 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);
}
}
}
示例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: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
@Override
public Resolution intercept(ExecutionContext context) throws Exception {
HttpServletRequest request = context.getActionBeanContext().getRequest();
String url = HttpUtil.getRequestedPath(request);
if (request.getQueryString() != null) {
url = url + '?' + request.getQueryString();
}
log.debug("Intercepting request: ", url);
Resolution resolution = context.proceed();
// A null resolution here indicates a normal flow to the next stage
boolean authed = ((MobileActionBeanContext) context.getActionBeanContext()).getCustomer() != null;
if (!authed && resolution == null) {
ActionBean bean = context.getActionBean();
if (bean != null && !bean.getClass().isAnnotationPresent(Public.class)) {
log.warn("Thwarted attempted to access ", bean.getClass().getSimpleName());
return new RedirectResolution(CustomerAuthorizationActionBean.class).addParameter("targetUrl", url);
}
}
log.debug("Allowing public access to ", context.getActionBean().getClass().getSimpleName());
return resolution;
}
示例6: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
@Override
public Resolution intercept(ExecutionContext context) throws Exception {
HttpServletRequest request = context.getActionBeanContext().getRequest();
String url = HttpUtil.getRequestedPath(request);
if (request.getQueryString() != null) {
url = url + '?' + request.getQueryString();
}
log.debug("Intercepting request: ", url);
Resolution resolution = context.proceed();
// A null resolution here indicates a normal flow to the next stage
boolean authed = ((MobileActionBeanContext) context.getActionBeanContext()).getUser() != null;
if (!authed && resolution == null) {
ActionBean bean = context.getActionBean();
if (bean != null && !bean.getClass().isAnnotationPresent(Public.class)) {
log.warn("Thwarted attempted to access ", bean.getClass().getSimpleName());
return new RedirectResolution(UserAuthorizationActionBean.class).addParameter("targetUrl", url);
}
}
log.debug("Allowing public access to ", context.getActionBean().getClass().getSimpleName());
return resolution;
}
示例7: 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;
}
示例8: intercept
import net.sourceforge.stripes.controller.ExecutionContext; //导入方法依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
Object action = context.getActionBean();
ActionBeanContext actionContext = context.getActionBeanContext();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
ServletContext servletContext = actionContext.getServletContext();
Injections.inject(action, servletContext, request);
return context.proceed();
}
示例9: 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);
}
}
示例10: 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();
}