private void validateAnnotations(EndpointConfig epConfig, Errors.Collector collector) { .annotations(EndpointConfig.AnnotationScope.values());
for (Class<? extends Annotation> annotation : annotations) { List<? extends Annotation> list = epConfig .combineAnnotations(annotation, EndpointConfig.AnnotationScope.values()); annotationConfig.addAll(list);
private void validateAnnotations(EndpointConfig epConfig, Errors.Collector collector) { .annotations(EndpointConfig.AnnotationScope.values());
RoleConfig.Builder builder = RoleConfig.builder(); for (EndpointConfig.AnnotationScope value : EndpointConfig.AnnotationScope.values()) {
for (Class<? extends Annotation> annotation : annotations) { List<? extends Annotation> list = epConfig .combineAnnotations(annotation, EndpointConfig.AnnotationScope.values()); annotationConfig.addAll(list);
@Override public TimeConfig fromAnnotations(EndpointConfig endpointConfig) { TimeConfig.Builder builder = TimeConfig.builder(); for (EndpointConfig.AnnotationScope value : EndpointConfig.AnnotationScope.values()) { List<Annotation> annotations = new ArrayList<>(); for (Class<? extends Annotation> annotation : supportedAnnotations()) { List<? extends Annotation> list = endpointConfig.combineAnnotations(annotation, value); annotations.addAll(list); } for (Annotation annotation : annotations) { if (annotation instanceof DaysOfWeek) { DaysOfWeek daw = (DaysOfWeek) annotation; for (DayOfWeek dayOfWeek : daw.value()) { builder.addDaysOfWeek(dayOfWeek); } } else if (annotation instanceof TimesOfDay) { TimesOfDay tods = (TimesOfDay) annotation; for (TimeOfDay tod : tods.value()) { builder.addBetween(LocalTime.parse(tod.from()), LocalTime.parse(tod.to())); } } else if (annotation instanceof TimeOfDay) { TimeOfDay tod = (TimeOfDay) annotation; builder.addBetween(LocalTime.parse(tod.from()), LocalTime.parse(tod.to())); } } } return builder.build(); }
@Override public PolicyConfig fromAnnotations(EndpointConfig endpointConfig) { PolicyConfig.Builder resultBuilder = PolicyConfig.builder(); for (EndpointConfig.AnnotationScope value : EndpointConfig.AnnotationScope.values()) { List<Annotation> annotations = new ArrayList<>(); for (Class<? extends Annotation> annotation : supportedAnnotations()) { List<? extends Annotation> list = endpointConfig.combineAnnotations(annotation, value); annotations.addAll(list); } for (Annotation annotation : annotations) { if (annotation instanceof PolicyStatement) { PolicyStatement statement = (PolicyStatement) annotation; resultBuilder.from(PolicyConfig.builder().from(statement).build()); } } } return resultBuilder.build(); }
@Override public ScopesConfig fromAnnotations(EndpointConfig endpointConfig) { List<Scope> scopes = new ArrayList<>(); for (EndpointConfig.AnnotationScope value : EndpointConfig.AnnotationScope.values()) { List<Annotation> annotations = new ArrayList<>(); for (Class<? extends Annotation> annotation : supportedAnnotations()) { List<? extends Annotation> list = endpointConfig.combineAnnotations(annotation, value); annotations.addAll(list); } for (Annotation annot : annotations) { if (annot instanceof Scopes) { scopes.addAll(Arrays.asList(((Scopes) annot).value())); } else if (annot instanceof Scope) { scopes.add((Scope) annot); } } } return ScopesConfig.create(scopes); }
private Set<String> expectedScopes(ProviderRequest request) { List<ScopeValidator.Scopes> expectedScopes = request.endpointConfig() .combineAnnotations(ScopeValidator.Scopes.class, EndpointConfig.AnnotationScope.values()); Set<String> result = new HashSet<>(); expectedScopes.stream() .map(ScopeValidator.Scopes::value) .map(Arrays::asList) .map(List::stream) .forEach(stream -> stream.map(ScopeValidator.Scope::value) .forEach(result::add)); return result; }