/** * Reads the XACML XML policy file in and returns the version contained in the root Policy/PolicySet element. * * @param policy - The policy file. * @return - The version string from the file (uninterpreted) * @throws IOException */ public static String getVersion(Path policy) throws IOException { Object data = null; try (InputStream is = Files.newInputStream(policy)) { data = XACMLPolicyScanner.readPolicy(is); } catch (IOException e) { logger.error("Failed to read policy", e); throw e; } if (data == null) { logger.warn("Version is null."); return null; } return getVersion(data); }
/** * Saves the given callback object then calls the scan() method. * * @param cb * @return */ public Object scan(Callback cb) { this.callback = cb; return this.scan(); }
if (this.scanTarget(policySet, policySet.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanObligations(policySet, policySet.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanAdvice(policySet, policySet.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; for (JAXBElement<?> element: list) { if (element.getName().getLocalPart().equals("PolicySet")) { if (this.scanPolicySet(policySet, (PolicySetType)element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanPolicy(policySet, (PolicyType)element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP;
if (this.scanTarget(policy, policy.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanVariables(policy, policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanObligations(policy, policy.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanAdvice(policy, policy.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanTarget(rule, rule.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanConditions(rule, rule.getCondition()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanObligations(rule, rule.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanAdvice(rule, rule.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP;
/** * * This begins the scanning of the contained object. * * @return - The PolicySet/Policy that was scanned. */ public Object scan() { if (this.policyObject == null) { return null; } if (this.callback != null) { if (this.callback.onBeginScan(this.policyObject) == CallbackResult.STOP) { return this.policyObject; } } if (this.policyObject instanceof PolicyType) { this.scanPolicy(null, (PolicyType) this.policyObject); } else if (this.policyObject instanceof PolicySetType) { this.scanPolicySet(null, (PolicySetType) this.policyObject); } else { logger.error("Unknown class type: " + this.policyObject.getClass().getCanonicalName()); } if (this.callback != null) { this.callback.onFinishScan(this.policyObject); } return this.policyObject; }
public XACMLPolicyScanner(Path filename, Callback callback) { try (InputStream is = Files.newInputStream(filename)) { this.policyObject = XACMLPolicyScanner.readPolicy(is); } catch (IOException e) { logger.error("Failed to read policy", e); } this.callback = callback; }
if (this.scanTarget(policySet, policySet.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanObligations(policySet, policySet.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanAdvice(policySet, policySet.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; for (JAXBElement<?> element: list) { if (element.getName().getLocalPart().equals("PolicySet")) { if (this.scanPolicySet(policySet, (PolicySetType)element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanPolicy(policySet, (PolicyType)element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP;
if (this.scanTarget(policy, policy.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanVariables(policy, policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanObligations(policy, policy.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanAdvice(policy, policy.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanTarget(rule, rule.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanConditions(rule, rule.getCondition()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanObligations(rule, rule.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; if (this.scanAdvice(rule, rule.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP;
/** * * This begins the scanning of the contained object. * * @return - The PolicySet/Policy that was scanned. */ public Object scan() { if (this.policyObject == null) { return null; } if (this.callback != null) { if (this.callback.onBeginScan(this.policyObject) == CallbackResult.STOP) { return this.policyObject; } } if (this.policyObject instanceof PolicyType) { this.scanPolicy(null, (PolicyType) this.policyObject); } else if (this.policyObject instanceof PolicySetType) { this.scanPolicySet(null, (PolicySetType) this.policyObject); } else { logger.error("Unknown class type: " + this.policyObject.getClass().getCanonicalName()); } if (this.callback != null) { this.callback.onFinishScan(this.policyObject); } return this.policyObject; }
public XACMLPolicyScanner(Path filename, Callback callback) { try (InputStream is = Files.newInputStream(filename)) { this.policyObject = XACMLPolicyScanner.readPolicy(is); } catch (IOException e) { logger.error("Failed to read policy", e); } this.callback = callback; }
/** * Reads the XACML XML policy file in and returns the version contained in the root Policy/PolicySet element. * * @param policy - The policy file. * @return - The version string from the file (uninterpreted) * @throws IOException */ public static String getVersion(Path policy) throws IOException { Object data = null; try (InputStream is = Files.newInputStream(policy)) { data = XACMLPolicyScanner.readPolicy(is); } catch (IOException e) { logger.error("Failed to read policy", e); throw e; } if (data == null) { logger.warn("Version is null."); return null; } return getVersion(data); }
/** * Saves the given callback object then calls the scan() method. * * @param cb * @return */ public Object scan(Callback cb) { this.callback = cb; return this.scan(); }
Object rootElement = XACMLPolicyScanner.readPolicy(url.openStream()); if (rootElement == null || this.isValid = false; } else { this.version = versionStringToArray(XACMLPolicyScanner.getVersion(rootElement)); if (rootElement instanceof PolicySetType) { this.policyId = ((PolicySetType)rootElement).getPolicySetId();
Object rootElement = XACMLPolicyScanner.readPolicy(url.openStream()); if (rootElement == null || this.isValid = false; } else { this.version = versionStringToArray(XACMLPolicyScanner.getVersion(rootElement)); if (rootElement instanceof PolicySetType) { this.policyId = ((PolicySetType)rootElement).getPolicySetId();