/** * Put all the policy files together into a single properties instance. * @param policyDir The source directory where to read the policy files from. * @return An {@link NonEscapedProperties} instance containing all the properties read from the policy files found * @throws IOException When an IO error occurs reading any of the policy files */ public NonEscapedProperties readPolicyProperties(Path policyDir) throws IOException { NonEscapedProperties properties = new NonEscapedProperties(); Files.list(policyDir) .filter(this::isPolicyFile) .forEach(path -> loadPolicyFile(properties, path)); return properties; }
NonEscapedProperties entries = new NonEscapedProperties(); marshaller.write(policy, entries);
@Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { try { checkNotNull("file", file); checkNotNull("attrs", attrs); if (isPolicyFile(file)) { String content = ioService.readAllString(file); NonEscapedProperties props = new NonEscapedProperties(); props.load(new StringReader(content)); marshaller.read(builder, props); } } catch (final Exception e) { logger.error("Authz policy file VFS read error: " + file.getFileName(), e); return FileVisitResult.TERMINATE; } return FileVisitResult.CONTINUE; } });
NonEscapedProperties props = new NonEscapedProperties(); props.load(new StringReader(content)); marshaller.read(builder,
URL fileURL = Thread.currentThread().getContextClassLoader().getResource("WEB-INF/classes/security-policy.properties"); Path policyPath = Paths.get(fileURL.toURI()); NonEscapedProperties input = new NonEscapedProperties(); input.load(Files.newBufferedReader(policyPath)); marshaller.read(builder,
URL fileURL = Thread.currentThread().getContextClassLoader().getResource("WEB-INF/classes/security-policy.properties"); Path policyPath = Paths.get(fileURL.toURI()); NonEscapedProperties input = new NonEscapedProperties(); input.load(Files.newBufferedReader(policyPath)); marshaller.read(builder,