Load policies from a source

@param source        source
@param forcedContext Context to require for all policies parsed

@return policies

@throws IOException
972856
public static PolicyCollection policiesFromSource(
            final YamlSource source,
            final Set<Attribute> forcedContext
    )
            throws IOException
    {
        return policiesFromSource(source, forcedContext, null);
    }
118886
public static cacheglobal_cachepolicy_binding[] get(nitro_service service) throws Exception{
		cacheglobal_cachepolicy_binding obj = new cacheglobal_cachepolicy_binding();
		cacheglobal_cachepolicy_binding response[] = (cacheglobal_cachepolicy_binding[]) obj.get_resources(service);
		return response;
	}
953240
protected void doLoadFromClasspath(String policyImpl, IAsyncResultHandler<IPolicy> handler) {
        IPolicy rval;
        String classname = policyImpl.substring(6);
        Class<?> c = null;

        // First try a simple Class.forName()
        try { c = Class.forName(classname); } catch (ClassNotFoundException e) { }
        // Didn't work?  Try using this class's classloader.
        if (c == null) {
            try { c = getClass().getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }
        // Still didn't work?  Try the thread's context classloader.
        if (c == null) {
            try { c = Thread.currentThread().getContextClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }

        if (c == null) {
            handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(classname)));
            return;
        }

        try {
            rval = (IPolicy) c.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(policyImpl, e)));
            return;
        }
        policyCache.put(policyImpl, rval);
        handler.handle(AsyncResultImpl.create(rval));
        return;
    }
1371706
def _loadSources(self):
        
        self.confstems = {}
        self.sourceDict = newtrigdict.Trigdict()
        for fName in self.authorityFiles:
            self._loadOneSource(fName)
        # We want to allow naked bibstems in references, too
        for stem in self.sourceDict.values():
            cleanStem = stem.replace(".", "").upper()
            self._addPub(stem, cleanStem)
1263424
public static ImmutableListMultimap<String, File> loadStringToFileListMultimap(
      final CharSource source) throws IOException {
    return loadMultimap(source, Functions.<String>identity(), FileFunction.INSTANCE,
        IsCommentLine.INSTANCE);
  }
1278350
public static ImmutableList<String> loadStringList(final CharSource source) throws IOException {
    return FluentIterable.from(source.readLines())
        .filter(not(IsCommentLine.INSTANCE))
        .toList();
  }
953294
public static cachepolicy_binding get(nitro_service service, String policyname) throws Exception{
		cachepolicy_binding obj = new cachepolicy_binding();
		obj.set_policyname(policyname);
		cachepolicy_binding response = (cachepolicy_binding) obj.get_resource(service);
		return response;
	}
1084490
@Nullable
    public CorsPolicy getPolicy(String origin, PathMappingContext pathMappingContext) {
        requireNonNull(origin, "origin");
        if (isAnyOriginSupported()) {
            return Iterables.getFirst(policies, null);
        }
        final String lowerCaseOrigin = Ascii.toLowerCase(origin);
        final boolean isNullOrigin = CorsService.NULL_ORIGIN.equals(lowerCaseOrigin);
        for (final CorsPolicy policy : policies) {
            if (isNullOrigin && policy.isNullOriginAllowed() &&
                isPathMatched(policy, pathMappingContext)) {
                return policy;
            } else if (!isNullOrigin && policy.origins().contains(lowerCaseOrigin) &&
                       isPathMatched(policy, pathMappingContext)) {
                return policy;
            }
        }
        return null;
    }
924388
public List<PolicyInformation> get(String name) throws IOException {
        if (name.equalsIgnoreCase(POLICIES)) {
            //XXXX May want to consider cloning this
            return certPolicies;
        } else {
          throw new IOException("Attribute name [" + name +
                                "] not recognized by " +
                                "CertAttrSet:CertificatePoliciesExtension.");
        }
    }
510894
private <T> void load(YamlSourceLoader<T> loader, YamlPolicyCreator<T> creator)
            throws IOException
    {
        int index = 1;
        try (final YamlSourceLoader<T> loader1 = loader) {
            for (T yamlDoc : loader1.loadAll()) {
                String ident = identity + "[" + index + "]";
                if (null == yamlDoc) {
                    continue;
                }
                try {
                    Policy yamlPolicy = creator.createYamlPolicy(
                            yamlDoc,
                            identity + "[" + index + "]",
                            index
                    );
                    all.add(yamlPolicy);
                    ruleSet.addAll(yamlPolicy.getRuleSet().getRules());
                } catch (AclPolicySyntaxException e) {
                    validationError(ident, e.getMessage());
                    logger.debug(
                            "ERROR parsing a policy in file: " +
                            identity +
                            "[" +
                            index +
                            "]. Reason: " +
                            e.getMessage(), e
                    );
                }
                index++;
            }

        }
    }
1165973
public static ns_conf_download_policy[] get_filtered(nitro_service service, String filter) throws Exception
	{
		ns_conf_download_policy obj = new ns_conf_download_policy();
		options option = new options();
		option.set_filter(filter);
		ns_conf_download_policy[] response = (ns_conf_download_policy[]) obj.getfiltered(service, option);
		return response;
	}
531955
public static cspolicy_binding get(nitro_service service, String policyname) throws Exception{
		cspolicy_binding obj = new cspolicy_binding();
		obj.set_policyname(policyname);
		cspolicy_binding response = (cspolicy_binding) obj.get_resource(service);
		return response;
	}
403317
public static PoliciesCache fromSources(final Iterable<CacheableYamlSource> sources) {
        return fromSourceProvider(
                new SourceProvider() {
                    @Override
                    public Iterator<CacheableYamlSource> getSourceIterator() {
                        return sources.iterator();
                    }
                }
        );
    }
569143
@Override
    public void refresh() {
        FileReader fr = null;
        if (file != null) {
            try {
                fr = new FileReader(file);
            } catch (Exception e) {
                System.err.println("Unable to read policy file " + file + ": " + e.getMessage());
            }
        }
        loadPolicy(fr, skipDefaultPolicies);
    }
714145
public static appfwglobal_appfwpolicy_binding[] get_filtered(nitro_service service, String filter) throws Exception{
		appfwglobal_appfwpolicy_binding obj = new appfwglobal_appfwpolicy_binding();
		options option = new options();
		option.set_filter(filter);
		appfwglobal_appfwpolicy_binding[] response = (appfwglobal_appfwpolicy_binding[]) obj.getfiltered(service, option);
		return response;
	}
1137919
private static List<Policy> createPolicies(final String property) {
		if (property == null || property.isEmpty()) {
			return Collections.<Policy>singletonList(new StartupPolicy(null));
		} else {
			ServiceLoader<Policy> loader = new ServiceLoader<Policy>(Policy.class, String.class);
			List<Policy> policies = new ArrayList<Policy>();
			for (String entry : property.split(",")) {
				int separator = entry.indexOf(':');
				if (separator == -1) {
					policies.add(loader.create(entry, (String) null));
				} else {
					String name = entry.substring(0, separator).trim();
					String argument = entry.substring(separator + 1).trim();
					policies.add(loader.create(name, argument));
				}
			}
			return policies;
		}
	}
262955
@Override
    protected synchronized void loadConfiguration() throws IOException {
        LOGGER.info("Loading list of allowed external content locations from {}", configPath);
        try (final Stream<String> stream = Files.lines(Paths.get(configPath))) {
            allowedList = stream.map(line -> normalizePath(line.trim().toLowerCase()))
                    .filter(line -> isAllowanceValid(line))
                    .collect(Collectors.toList());
        }
    }