/** * Init the policy with the pgt url regex pattern that * will determine the urls allowed to receive the pgt. * The matching by default is done in a case insensitive manner. * * @param pgtUrlPattern the pgt url pattern */ @JsonCreator public RegexMatchingRegisteredServiceProxyPolicy(@JsonProperty("pattern") final String pgtUrlPattern) { if (RegexUtils.isValidRegex(pgtUrlPattern)) { this.pattern = pgtUrlPattern; } else { LOGGER.warn("Pattern specified [{}] is not a valid regular expression", pgtUrlPattern); this.pattern = RegexUtils.MATCH_NOTHING_PATTERN.pattern(); } }
/** * Search for property. * * @param name the name * @return the response entity */ @ReadOperation public List<ConfigurationMetadataSearchResult> search(@Selector final String name) { val allProps = repository.getRepository().getAllProperties(); if (StringUtils.isNotBlank(name) && RegexUtils.isValidRegex(name)) { val names = StreamSupport.stream(RelaxedPropertyNames.forCamelCase(name).spliterator(), false) .map(Object::toString) .collect(Collectors.joining("|")); val pattern = RegexUtils.createPattern(names); return allProps.entrySet() .stream() .filter(propEntry -> RegexUtils.find(pattern, propEntry.getKey())) .map(propEntry -> new ConfigurationMetadataSearchResult(propEntry.getValue(), repository)) .sorted() .collect(Collectors.toList()); } return new ArrayList<>(); } }
private static void buildPredicateFilterIfNeeded(final SamlRegisteredService service, final List<MetadataFilter> metadataFilterList) { if (StringUtils.isNotBlank(service.getMetadataCriteriaDirection()) && StringUtils.isNotBlank(service.getMetadataCriteriaPattern()) && RegexUtils.isValidRegex(service.getMetadataCriteriaPattern())) { val dir = PredicateFilter.Direction.valueOf(service.getMetadataCriteriaDirection()); LOGGER.debug("Metadata predicate filter configuring with direction [{}] and pattern [{}]", service.getMetadataCriteriaDirection(), service.getMetadataCriteriaPattern()); val filter = new PredicateFilter(dir, entityDescriptor -> StringUtils.isNotBlank(entityDescriptor.getEntityID()) && entityDescriptor.getEntityID().matches(service.getMetadataCriteriaPattern())); metadataFilterList.add(filter); LOGGER.debug("Added metadata predicate filter with direction [{}] and pattern [{}]", service.getMetadataCriteriaDirection(), service.getMetadataCriteriaPattern()); } }