MCPcopy Create free account
hub / github.com/grpc/grpc-java / parsePermission

Method parsePermission

xds/src/main/java/io/grpc/xds/RbacFilter.java:220–253  ·  view source on GitHub ↗
(Permission permission)

Source from the content-addressed store, hash-verified

218 }
219
220 private static Matcher parsePermission(Permission permission) {
221 switch (permission.getRuleCase()) {
222 case AND_RULES:
223 List<Matcher> andMatch = new ArrayList<>();
224 for (Permission p : permission.getAndRules().getRulesList()) {
225 andMatch.add(parsePermission(p));
226 }
227 return AndMatcher.create(andMatch);
228 case OR_RULES:
229 return parsePermissionList(permission.getOrRules().getRulesList());
230 case ANY:
231 return AlwaysTrueMatcher.INSTANCE;
232 case HEADER:
233 return parseHeaderMatcher(permission.getHeader());
234 case URL_PATH:
235 return parsePathMatcher(permission.getUrlPath());
236 case DESTINATION_IP:
237 return createDestinationIpMatcher(permission.getDestinationIp());
238 case DESTINATION_PORT:
239 return createDestinationPortMatcher(permission.getDestinationPort());
240 case DESTINATION_PORT_RANGE:
241 return parseDestinationPortRangeMatcher(permission.getDestinationPortRange());
242 case NOT_RULE:
243 return InvertMatcher.create(parsePermission(permission.getNotRule()));
244 case METADATA: // hard coded, never match.
245 return InvertMatcher.create(AlwaysTrueMatcher.INSTANCE);
246 case REQUESTED_SERVER_NAME:
247 return parseRequestedServerNameMatcher(permission.getRequestedServerName());
248 case RULE_NOT_SET:
249 default:
250 throw new IllegalArgumentException(
251 "Unknown permission rule case: " + permission.getRuleCase());
252 }
253 }
254
255 private static OrMatcher parsePrincipalList(List<Principal> principals) {
256 List<Matcher> anyMatch = new ArrayList<>();

Callers 1

parsePermissionListMethod · 0.95

Calls 14

createMethod · 0.95
parsePermissionListMethod · 0.95
parseHeaderMatcherMethod · 0.95
parsePathMatcherMethod · 0.95
createMethod · 0.95
getHeaderMethod · 0.80
getDestinationIpMethod · 0.80
getDestinationPortMethod · 0.80

Tested by

no test coverage detected