HtmlProcessor extends SimpleCallback { public HtmlProcessor(File policyFile, Object policyObject) { if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); } if (policyFile == null) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Null Policy File"); throw new IllegalArgumentException("Null Policy File"); } if (!policyFile.exists() || !policyFile.canRead()) { String msg = "Can't access " + policyFile.getAbsolutePath(); LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + msg); throw new IllegalArgumentException(msg); } if ((!(policyObject instanceof PolicySetType) && !(policyObject instanceof PolicyType))) { String msg = "Invalid unmarshalled object: " + policyObject; LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + msg); throw new IllegalArgumentException(msg); } this.policyName = FilenameUtils.removeExtension(policyFile.getName()); this.rootPolicyObject = policyObject; String version = "-"; if (policyObject instanceof PolicyType) { PolicyType policy = (PolicyType) policyObject; version = policy.getVersion(); htmlOut.println("<h1>Policy: " + policyName + " (version " + version + ") </h1>"); } else { PolicySetType policySet = (PolicySetType) policyObject; version = policySet.getVersion(); htmlOut.println("<h1>Policy Set: " + policyName + " (v" + version + ") </h1>"); } htmlOut.println("<h3><b>Location: </b>" + policyFile.getPath() + "</h3>"); htmlOut.println("<hr>"); if (rootPolicyObject instanceof PolicySetType) { if (policyName.startsWith("Config_")) { htmlOut.println("<p>This is a <b>config</b> policy set.</p>"); } else if (policyName.startsWith("Action_")) { htmlOut.println("<p>This is an <b>action</b> policy set.</p>"); } htmlOut.println("<dl>"); } else { if (policyName.startsWith("Config_")) { htmlOut.println("<p>This is a <b>config</b> policy.</p>"); } else if (policyName.startsWith("Action_")) { htmlOut.println("<p>This is an <b>action</b> policy.</p>"); } htmlOut.println("<ol>"); } } HtmlProcessor(File policyFile, Object policyObject); Map<String, AttributeIdentifiers> getAttributeIdentifiersMap(); @Override void onFinishScan(Object root); @Override CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet); @Override CallbackResult onPostVisitPolicySet(PolicySetType parent, PolicySetType policySet); void policySet(PolicySetType policySet, String htmlListElement); @Override CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy); @Override CallbackResult onPostVisitPolicy(PolicySetType parent, PolicyType policy); void policy(PolicyType policy); @Override CallbackResult onPreVisitRule(PolicyType parent, RuleType rule); @Override CallbackResult onPostVisitRule(PolicyType parent, RuleType rule); void rule(RuleType rule); void target(List<AnyOfType> anyOfList); String html();  }
@Test(expected = IllegalArgumentException.class) public void testHtmlProcessor() throws IOException { File tempFile = File.createTempFile("testFile", ".tmp"); tempFile.delete(); processor = new HtmlProcessor(tempFile, null); }