@Test public void allowedPropertiesTest() { assertTrue(HandlerOfResources.allowedProperties(null,null)); assertTrue(HandlerOfResources.allowedProperties(new Properties(),null)); assertTrue(HandlerOfResources.allowedProperties(new Properties(), new ArrayList<String>())); Properties props = new Properties(); props.setProperty("king", "kong"); props.setProperty("barbie", "doll"); assertFalse(HandlerOfResources.allowedProperties(props, singletonList("bar"))); assertTrue( HandlerOfResources.allowedProperties(props, singletonList("bark"))); assertTrue(HandlerOfResources.allowedProperties(props, HandlerOfResources.DISALLOWED_SHARED_UPDATES)); props.setProperty("solr.host", "me"); props.setProperty("solr.port", "233"); assertTrue(HandlerOfResources.allowedProperties(props, HandlerOfResources.DISALLOWED_SHARED_UPDATES)); props.setProperty("alfresco.identifier.property.0", "xy"); assertFalse(HandlerOfResources.allowedProperties(props, HandlerOfResources.DISALLOWED_SHARED_UPDATES)); props.remove("alfresco.identifier.property.0"); props.setProperty("alfresco.suggestable.property.1", "xy"); assertFalse(HandlerOfResources.allowedProperties(props, HandlerOfResources.DISALLOWED_SHARED_UPDATES)); props.remove("alfresco.suggestable.property.1"); props.setProperty("alfresco.cross.locale.property.0", "xy"); assertFalse(HandlerOfResources.allowedProperties(props, HandlerOfResources.DISALLOWED_SHARED_UPDATES)); props.remove("alfresco.cross.locale.property.0"); props.setProperty("alfresco.cross.locale.datatype.2", "xy"); assertFalse(HandlerOfResources.allowedProperties(props, HandlerOfResources.DISALLOWED_SHARED_UPDATES)); props.remove("alfresco.cross.locale.datatype.2"); }
public static boolean allowedProperties(Properties toCheck, List<String> disallowed) { if (toCheck == null || toCheck.isEmpty() || disallowed == null || disallowed.isEmpty()) return true; for (Object key: toCheck.keySet()) { for (String prop :disallowed) { if (key.toString().startsWith(prop)) return false; } } return true; }
HandlerOfResources { public static boolean allowedProperties(Properties toCheck, List<String> disallowed) { if (toCheck == null || toCheck.isEmpty() || disallowed == null || disallowed.isEmpty()) return true; for (Object key: toCheck.keySet()) { for (String prop :disallowed) { if (key.toString().startsWith(prop)) return false; } } return true; } }
HandlerOfResources { public static boolean allowedProperties(Properties toCheck, List<String> disallowed) { if (toCheck == null || toCheck.isEmpty() || disallowed == null || disallowed.isEmpty()) return true; for (Object key: toCheck.keySet()) { for (String prop :disallowed) { if (key.toString().startsWith(prop)) return false; } } return true; }  }
HandlerOfResources { public static boolean allowedProperties(Properties toCheck, List<String> disallowed) { if (toCheck == null || toCheck.isEmpty() || disallowed == null || disallowed.isEmpty()) return true; for (Object key: toCheck.keySet()) { for (String prop :disallowed) { if (key.toString().startsWith(prop)) return false; } } return true; }  static InputStream openResource(String solrHome, String resource); static void updateSharedProperties(SolrParams params, File config, boolean disallow); static void updatePropertiesFile(SolrParams params, File config, List<String> disallowed); static boolean allowedProperties(Properties toCheck, List<String> disallowed); static Properties extractCustomProperties(SolrParams params); static boolean getSafeBoolean(SolrParams params, String paramName); static Long getSafeLong(SolrParams params, String paramName); }
HandlerOfResources { public static boolean allowedProperties(Properties toCheck, List<String> disallowed) { if (toCheck == null || toCheck.isEmpty() || disallowed == null || disallowed.isEmpty()) return true; for (Object key: toCheck.keySet()) { for (String prop :disallowed) { if (key.toString().startsWith(prop)) return false; } } return true; }  static InputStream openResource(String solrHome, String resource); static void updateSharedProperties(SolrParams params, File config, boolean disallow); static void updatePropertiesFile(SolrParams params, File config, List<String> disallowed); static boolean allowedProperties(Properties toCheck, List<String> disallowed); static Properties extractCustomProperties(SolrParams params); static boolean getSafeBoolean(SolrParams params, String paramName); static Long getSafeLong(SolrParams params, String paramName);  }