public boolean matches(String toMatch) { return this.toString().equals(toMatch) || "*".equals(toMatch); } }
protected AuthzDecision checkPermissions(URIPolicyRule uriPolicyRule, RequestContext reqCtx) { RequestType reqType = reqCtx.requestType(); boolean reqTypeMatches = false; for (String currentReqType : uriPolicyRule.getRequestTypes()) { if (reqType.matches(currentReqType)) { reqTypeMatches = true; break; } } if (reqTypeMatches) { return uriPolicyRule.getRolesContainer().isRequestAllowed(reqCtx); } else { return AuthzDecision.IGNORE; } }
private List<Interceptor> getInterceptors(String chainName, ResourceRequest request) { List<Interceptor> result = new LinkedList<>(); List<InterceptorConfigEntry> chainConfigEntries = interceptorsConfig.get().getChainConfig(chainName); for (InterceptorConfigEntry configEntry : chainConfigEntries) { String interceptorName = configEntry.getInterceptorName(); Interceptor interceptor = interceptors.get(interceptorName); if (interceptor == null) { log.warnf("No interceptor under key '%s'", interceptorName); continue; } // Verify resourcePath matches if (configEntry.getResourcePathMapping() != null && request != null) { ResourcePath interceptorResPath = new ResourcePath(configEntry.getResourcePathMapping()); if (!interceptorResPath.isParentOf(request.resourcePath())) { continue; } } // Verify requestType matches if (configEntry.getRequestTypeMapping() != null && request != null) { if (!request.requestType().matches(configEntry.getRequestTypeMapping())) { continue; } } result.add(interceptor); } return result; }