org.springframework.security.web.access.WebInvocationPrivilegeEvaluator类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(333)

本文整理了Java中org.springframework.security.web.access.WebInvocationPrivilegeEvaluator类的一些代码示例,展示了WebInvocationPrivilegeEvaluator类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebInvocationPrivilegeEvaluator类的具体详情如下:
包路径:org.springframework.security.web.access.WebInvocationPrivilegeEvaluator
类名称:WebInvocationPrivilegeEvaluator

WebInvocationPrivilegeEvaluator介绍

[英]Allows users to determine whether they have privileges for a given web URI.
[中]允许用户确定他们是否拥有给定web URI的权限。

代码示例

代码示例来源:origin: thymeleaf/thymeleaf-extras-springsecurity

private static boolean authorizeUsingUrlCheckMvc(
    final IExpressionContext context, final String url, final String method, final Authentication authentication) {
  final String contextPath = SpringSecurityContextUtils.getContextPath(context);
  return getPrivilegeEvaluator(context).isAllowed(contextPath, url, method, authentication);
}

代码示例来源:origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity5

private static boolean authorizeUsingUrlCheckMvc(
    final IExpressionContext context, final String url, final String method, final Authentication authentication) {
  final String contextPath = SpringSecurityContextUtils.getContextPath(context);
  return getPrivilegeEvaluator(context).isAllowed(contextPath, url, method, authentication);
}

代码示例来源:origin: org.openl/org.openl.commons.web

/**
 * Returns true if current user has access to a given URI
 * (look for FilterSecurityInterceptor configuration)
 *
 * @param uri URI that will be checked
 * @return true if current user has access to a given URI
 */
public static boolean hasAccessTo(String uri) {
  return getPrivilegeEvaluator().isAllowed(uri, SecurityContextHolder.getContext().getAuthentication());
}

代码示例来源:origin: openl-tablets/openl-tablets

/**
 * Returns true if current user has access to a given URI
 * (look for FilterSecurityInterceptor configuration)
 *
 * @param uri URI that will be checked
 * @return true if current user has access to a given URI
 */
public static boolean hasAccessTo(String uri) {
  return getPrivilegeEvaluator().isAllowed(uri, SecurityContextHolder.getContext().getAuthentication());
}

代码示例来源:origin: sentilo/sentilo

private boolean isAnonymousRequest(final HttpServletRequest request) {
 final String requestUri = request.getRequestURI().substring(request.getContextPath().length());
 return requestUri.startsWith("/WEB-INF/") || getRequestEvaluator().isAllowed(requestUri, anonymousAuth);
}

代码示例来源:origin: javamonkey/beetl2.0

@Override
public Boolean call(Object[] paras, Context ctx) {
  // 如果没有安全上下文,固定返回true
  SecurityContext securityContext = SecurityContextHolder.getContext();
  if (securityContext == null) {
    return true;
  }
  // 用户未登录
  Authentication authentication = getAuthentication(securityContext);
  // 如果未提供URL,固定返回true
  if ((paras.length == 0) || (paras[0] == null) || !(paras[0] instanceof String)) {
    return true;
  }
  String url = (String) paras[0];
  // 默认请求方式为GET,由第二参数给定
  String method = "GET";
  if ((paras.length > 1) && (paras[1] != null) && (paras[1] instanceof String)) {
    method = (String) paras[1];
  }
  return privilegeEvaluator.isAllowed(servletContext.getContextPath(), url, method, authentication);
}

代码示例来源:origin: com.ibeetl/beetl

@Override
public Boolean call(Object[] paras, Context ctx) {
  // 如果没有安全上下文,固定返回true
  SecurityContext securityContext = SecurityContextHolder.getContext();
  if (securityContext == null) {
    return true;
  }
  // 用户未登录
  Authentication authentication = getAuthentication(securityContext);
  // 如果未提供URL,固定返回true
  if ((paras.length == 0) || (paras[0] == null) || !(paras[0] instanceof String)) {
    return true;
  }
  String url = (String) paras[0];
  // 默认请求方式为GET,由第二参数给定
  String method = "GET";
  if ((paras.length > 1) && (paras[1] != null) && (paras[1] instanceof String)) {
    method = (String) paras[1];
  }
  return privilegeEvaluator.isAllowed(servletContext.getContextPath(), url, method, authentication);
}

代码示例来源:origin: socialsignin/spring-social-security

private boolean providerCombinationAllowsAccessForEvaluator(HttpServletRequest request,
    Authentication existingAuthentication,
    WebInvocationPrivilegeEvaluator evaluator,
    Set<String> additionProviderIdsCombination)
{
  return evaluator.isAllowed(request.getContextPath(),getUri(request),request.getMethod(), springSocialSecurityAuthenticationFactory.updateAuthenticationForNewProviders(existingAuthentication, additionProviderIdsCombination));
  
}

代码示例来源:origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity3

public static boolean authorizeUsingUrlCheck(
    final String url, final String method, final Authentication authentication, 
    final HttpServletRequest request, final ServletContext servletContext) {
  
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checking authorization for URL \"{}\" and method \"{}\" for user \"{}\".",
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  final boolean result =
      getPrivilegeEvaluator(servletContext, request).isAllowed(
        request.getContextPath(), url, method, authentication) ? 
            true : false;
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checked authorization for URL \"{}\" and method \"{}\" for user \"{}\". " +
        (result? "Access GRANTED." : "Access DENIED."),
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  return result;
  
}

代码示例来源:origin: thymeleaf/thymeleaf-extras-springsecurity

public static boolean authorizeUsingUrlCheck(
    final String url, final String method, final Authentication authentication, 
    final HttpServletRequest request, final ServletContext servletContext) {
  
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checking authorization for URL \"{}\" and method \"{}\" for user \"{}\".",
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  final boolean result =
      getPrivilegeEvaluator(servletContext, request).isAllowed(
        request.getContextPath(), url, method, authentication) ? 
            true : false;
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checked authorization for URL \"{}\" and method \"{}\" for user \"{}\". " +
        (result? "Access GRANTED." : "Access DENIED."),
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  return result;
  
}

代码示例来源:origin: thymeleaf/thymeleaf-extras-springsecurity

public static boolean authorizeUsingUrlCheck(
    final String url, final String method, final Authentication authentication, 
    final HttpServletRequest request, final ServletContext servletContext) {
  
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checking authorization for URL \"{}\" and method \"{}\" for user \"{}\".",
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  final boolean result =
      getPrivilegeEvaluator(servletContext, request).isAllowed(
        request.getContextPath(), url, method, authentication) ? 
            true : false;
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checked authorization for URL \"{}\" and method \"{}\" for user \"{}\". " +
        (result? "Access GRANTED." : "Access DENIED."),
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  return result;
  
}

代码示例来源:origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity4

public static boolean authorizeUsingUrlCheck(
    final String url, final String method, final Authentication authentication, 
    final HttpServletRequest request, final ServletContext servletContext) {
  
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checking authorization for URL \"{}\" and method \"{}\" for user \"{}\".",
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  final boolean result =
      getPrivilegeEvaluator(servletContext, request).isAllowed(
        request.getContextPath(), url, method, authentication) ? 
            true : false;
  if (logger.isTraceEnabled()) {
    logger.trace("[THYMELEAF][{}] Checked authorization for URL \"{}\" and method \"{}\" for user \"{}\". " +
        (result? "Access GRANTED." : "Access DENIED."),
        new Object[] {TemplateEngine.threadIndex(), url, method, (authentication == null? null : authentication.getName())});
  }
  
  return result;
  
}

代码示例来源:origin: org.springframework.security/spring-security-taglibs

/**
 * Make an authorization decision based on the URL and HTTP method attributes. True is
 * returned if the user is allowed to access the given URL as defined.
 *
 * @return the result of the authorization decision
 * @throws IOException
 */
public boolean authorizeUsingUrlCheck() throws IOException {
  String contextPath = ((HttpServletRequest) getRequest()).getContextPath();
  Authentication currentUser = SecurityContextHolder.getContext()
      .getAuthentication();
  return getPrivilegeEvaluator().isAllowed(contextPath, getUrl(), getMethod(),
      currentUser);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Make an authorization decision based on the URL and HTTP method attributes. True is
 * returned if the user is allowed to access the given URL as defined.
 *
 * @return the result of the authorization decision
 * @throws IOException
 */
public boolean authorizeUsingUrlCheck() throws IOException {
  String contextPath = ((HttpServletRequest) getRequest()).getContextPath();
  Authentication currentUser = SecurityContextHolder.getContext()
      .getAuthentication();
  return getPrivilegeEvaluator().isAllowed(contextPath, getUrl(), getMethod(),
      currentUser);
}

相关文章

WebInvocationPrivilegeEvaluator类方法