當前位置: 首頁>>代碼示例>>Java>>正文


Java FilterInvocation類代碼示例

本文整理匯總了Java中org.springframework.security.web.FilterInvocation的典型用法代碼示例。如果您正苦於以下問題:Java FilterInvocation類的具體用法?Java FilterInvocation怎麽用?Java FilterInvocation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FilterInvocation類屬於org.springframework.security.web包,在下文中一共展示了FilterInvocation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAttributes

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
@Override
public Collection<ConfigAttribute> getAttributes(Object o) throws IllegalArgumentException {
    String url = ((FilterInvocation) o).getRequestUrl();

    logger.debug("request url is  " + url);

    if (resourceMap == null) {
        resourceMap = loadResourceMatchAuthority();
    }

    for (String resURL : resourceMap.keySet()) {
        if (pathMatcher.match(resURL, url)) {
            return resourceMap.get(resURL);
        }
    }
    return resourceMap.get(url);
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:18,代碼來源:CustomerSecurityMetadataSource.java

示例2: getAttributes

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
@Override
public Collection<ConfigAttribute> getAttributes(Object o) throws IllegalArgumentException {
    String url = ((FilterInvocation) o).getRequestUrl();

    if (!url.contains("/js/") && !url.contains("/html/") && !url.contains("/css/") && !url.contains("/images/")) {
        logger.debug("request url is  " + url);
    }

    if (resourceMap == null) {
        resourceMap = loadResourceMatchAuthority();
    }

    for (String resURL : resourceMap.keySet()) {
        if (pathMatcher.match(resURL, url)) {
            return resourceMap.get(resURL);
        }
    }
    return resourceMap.get(url);
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:20,代碼來源:CustomerSecurityMetadataSource.java

示例3: getAttributes

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
@Override
public Collection<ConfigAttribute> getAttributes(Object object)
		throws IllegalArgumentException {
	// ObjectΪһ��URL,���û������URL
	String url = ((FilterInvocation)object).getRequestUrl();
	//����
	System.out.println("該用戶請求的url為:" + url);
	int firstQuestionMarkIndex = url.indexOf("?");
	if(firstQuestionMarkIndex != -1){
		url = url.substring(0, firstQuestionMarkIndex);
	}
	Iterator<String> ite =  resourceMap.keySet().iterator();
	while(ite.hasNext()){
		String resultURL = ite.next();
		if(urlMatcher.pathMatchesUrl(url, resultURL)){
			//����
		System.out.println("該url匹配的權限為:"+ resourceMap.get(resultURL));
			return resourceMap.get(resultURL);
		}
	}
	//����
	//System.out.println("該url沒有匹配的權限");
	return null;
}
 
開發者ID:wanliyang10010,項目名稱:Shop,代碼行數:25,代碼來源:MyInvocationSecurityMetadataSourceService.java

示例4: addSecurityConfig

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
private void addSecurityConfig(FilterInvocation filterInvocation, Collection<ConfigAttribute> guiConfigAttr,
                   String url, DisplayableValue<String>[] actions) {

     AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
     if (!matcher.matches(filterInvocation.getRequest()) || actions == null) {
         return;
     }
     
     for (DisplayableValue<String> action : actions) {
         String actionUri = action.getValue();
         if (StringUtils.isBlank(actionUri)) {
             continue;
         }

         //all users has permission to access these resources
         if (action.equals(AuthorizationConstants.AUTZ_UI_PERMIT_ALL_URL)) {
             return;
         }

         SecurityConfig config = new SecurityConfig(actionUri);
if (!guiConfigAttr.contains(config)) {
	guiConfigAttr.add(config);
}
     }
 }
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:26,代碼來源:MidPointGuiAuthorizationEvaluator.java

示例5: getAttributes

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
/**
 * 根據路徑獲取訪問權限的集合接口
 *
 * @param object
 * @return
 * @throws IllegalArgumentException
 */
@Override
public Collection<ConfigAttribute> getAttributes(Object object)
        throws IllegalArgumentException {
    HttpServletRequest request = ((FilterInvocation) object).getHttpRequest();
    List<ConfigAttribute> attrs = new ArrayList<>();
    try {
        List<Permission> permissions = permissionService.findAll();
        for (Permission p : permissions) {
            AntPathRequestMatcher matcher = new AntPathRequestMatcher(p.getUrl());
            if (matcher.matches(request)) {
                attrs.add(new SecurityConfig(p.getCode()));
            }
        }
    } catch (ExecutionException e) {
        e.printStackTrace();
    }

    return attrs;
}
 
開發者ID:microacup,項目名稱:microbbs,代碼行數:27,代碼來源:MyInvocationSecurityMetadataSource.java

示例6: decide

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
@Override
public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config) throws IOException, ServletException {
    if ((invocation == null) || (config == null)) {
        throw new IllegalArgumentException("Nulls cannot be provided");
    }

    for (ConfigAttribute attribute : config) {
        if (supports(attribute)) {
            if (invocation.getHttpRequest().getHeader("X-Forwarded-Proto") != null
                    && "https".equalsIgnoreCase(invocation.getHttpRequest().getHeader("X-Forwarded-Proto"))) {
                //We can't rely entirely on "!invocation.getHttpRequest().isSecure()" because many times, 
                //when SSL terminates somewhere else, the proxied request will not be secure.
                //In this case, someone may have gone to a secured page, and then tried to go back to an unsecured page.
                getEntryPoint().commence(invocation.getRequest(), invocation.getResponse());
            } else if (invocation.getHttpRequest().getHeader("X-Forwarded-Proto") != null
                    && "http".equalsIgnoreCase(invocation.getHttpRequest().getHeader("X-Forwarded-Proto"))) {
                return;
            } else if (!invocation.getHttpRequest().isSecure()) {
                return;
            } else {
                getEntryPoint().commence(invocation.getRequest(), invocation.getResponse());
            }
        }
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:26,代碼來源:ProtoInsecureChannelProcessor.java

示例7: decide

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
@Override
public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config) throws IOException, ServletException {
    Assert.isTrue((invocation != null) && (config != null), "Nulls cannot be provided");

    for (ConfigAttribute attribute : config) {
        if (supports(attribute)) {
            if (invocation.getHttpRequest().getHeader("X-Forwarded-Proto") != null
                    && "https".equalsIgnoreCase(invocation.getHttpRequest().getHeader("X-Forwarded-Proto"))) {
                return;
            } else if (invocation.getHttpRequest().isSecure()) {
                return;
            } else {
                getEntryPoint().commence(invocation.getRequest(), invocation.getResponse());
            }
        }
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:18,代碼來源:ProtoSecureChannelProcessor.java

示例8: vote

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
public int vote(Authentication authentication, FilterInvocation fi,
		Collection<ConfigAttribute> attributes) {
	assert authentication != null;
	assert fi != null;
	assert attributes != null;

	CodeSecurityConfig codeConfig = findConfigAttribute(attributes);

	if (codeConfig == null) {
		return ACCESS_ABSTAIN;
	}

	EvaluationContext ctx = expressionHandler.createEvaluationContext(authentication,
			fi);

	return ExpressionUtils.evaluateAsBoolean(codeConfig.getAuthorizeExpression(), ctx) ? ACCESS_GRANTED
			: ACCESS_DENIED;
}
 
開發者ID:wayshall,項目名稱:onetwo,代碼行數:19,代碼來源:MultiWebExpressionVoter.java

示例9: getAttributes

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
	// object是一個URL,被用戶請求的url
	String requestUrl = ((FilterInvocation) object).getRequestUrl();
	System.out.println("requestUrl is " + requestUrl);

	int firstQuestionMarkIndex = requestUrl.indexOf("?");

	if (firstQuestionMarkIndex != -1) {
		requestUrl = requestUrl.substring(0, firstQuestionMarkIndex);
	}

	if (resourceMap == null) {
		loadResourceDefine();
	}
	//
	Iterator<String> ite = resourceMap.keySet().iterator();

	while (ite.hasNext()) {
		String resURL = ite.next();

		if (resURL.equals(requestUrl)) {
			return resourceMap.get(resURL);
		}
	}
	return null;
}
 
開發者ID:8090boy,項目名稱:gomall.la,代碼行數:27,代碼來源:InvocationSecurityMetadataSourceService.java

示例10: createConfigAttribute

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
private String createConfigAttribute(Authentication authentication, Object object) {
	
	try{
		FilterInvocation fi = (FilterInvocation)object;
		if(fi.getHttpRequest() == null || fi.getHttpResponse() == null){
			return NavigationAccessor.DEFAULT_ACCESS;
		}
		
        Navigation navigation = navigationFactory.resolveNavigation(fi.getHttpRequest());
		NavigationAccessor accessor = new NavigationAccessor(authentication, fi);
		navigation.travel(accessor);
		fi.getHttpRequest().setAttribute(Navigation.OBJECT_NAME, navigation);

		return accessor.getAttribute();
	}catch(Exception e){
        logger.warn("createConfigAttribute : ", e);
		return NavigationAccessor.DEFAULT_ACCESS;
	}
}
 
開發者ID:u2ware,項目名稱:springfield,代碼行數:20,代碼來源:AccessDecisionManager.java

示例11: vote

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
public int vote(Authentication authentication, FilterInvocation fi, Collection<ConfigAttribute> attributes) {
    assert authentication != null;
    assert fi != null;
    assert attributes != null;

    AuthorityAttribute attr = findAccessAttribute(attributes);
  
    if (attr == null) {
        return ACCESS_ABSTAIN;
    }
    
    AuthorityExpressionRoot sec = new AuthorityExpressionRoot(authentication, fi);
    int vote = sec.evaluateAsBoolean(attr) ? ACCESS_GRANTED : ACCESS_DENIED;
    
    
    return vote;
}
 
開發者ID:u2ware,項目名稱:springfield,代碼行數:18,代碼來源:AuthorityAttributeVoter.java

示例12: addSecurityConfig

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
private void addSecurityConfig(FilterInvocation filterInvocation, List<String> requiredActions,
                   String url, DisplayableValue<String>[] actions) {

     AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
     if (!matcher.matches(filterInvocation.getRequest()) || actions == null) {
         return;
     }
     
     for (DisplayableValue<String> action : actions) {
         String actionUri = action.getValue();
         if (StringUtils.isBlank(actionUri)) {
             continue;
         }

if (!requiredActions.contains(actionUri)) {
	requiredActions.add(actionUri);
}
     }
 }
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:20,代碼來源:MidPointGuiAuthorizationEvaluator.java

示例13: invoke

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
public void invoke(FilterInvocation fi) throws IOException,
		ServletException {
	if ((fi.getRequest() != null) && (fi.getRequest().getAttribute(FILTER_APPLIED) != null) && observeOncePerRequest) {
		fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
	} else {
		if (fi.getRequest() != null) {
			fi.getRequest().setAttribute(FILTER_APPLIED, Boolean.TRUE);
		}
		InterceptorStatusToken token = super.beforeInvocation(fi);
		try {
			fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
		} finally {
			super.finallyInvocation(token);
		}
		super.afterInvocation(token, null);
	}
}
 
開發者ID:xiaolongzuo,項目名稱:zxl,代碼行數:18,代碼來源:ResourceSecurityFilter.java

示例14: vote

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
@Override
public int vote(Authentication authentication, FilterInvocation filterInvocation,
		Collection<ConfigAttribute> attributes)
{
	String requestUrl = filterInvocation.getRequestUrl();

	Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl);
	if (pluginMatcher.matches())
	{
		String pluginId = pluginMatcher.group(1);
		return getMolgenisPermissionService().hasPermissionOnPlugin(pluginId,
				Permission.READ) ? ACCESS_GRANTED : ACCESS_DENIED;
	}

	Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl);
	if (menuMatcher.matches())
	{
		String menuId = menuMatcher.group(1);
		UiMenu menu = getMolgenisUi().getMenu(menuId);
		return menu != null ? ACCESS_GRANTED : ACCESS_DENIED;
	}

	return ACCESS_DENIED;
}
 
開發者ID:molgenis,項目名稱:molgenis,代碼行數:25,代碼來源:MolgenisAccessDecisionVoter.java

示例15: invoke

import org.springframework.security.web.FilterInvocation; //導入依賴的package包/類
private void invoke(FilterInvocation fi) throws IOException, ServletException {
    InterceptorStatusToken token = super.beforeInvocation(fi);
    try {
        fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
    } catch (Exception e) {
        logger.error(e.getMessage());
    } finally {
        super.afterInvocation(token, null);
    }
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:11,代碼來源:CustomerFilterSecurityInterceptor.java


注:本文中的org.springframework.security.web.FilterInvocation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。