From 501ee00e742a6f56a16ace66f4a64eb7ec9e854b Mon Sep 17 00:00:00 2001 From: "pramod.jamkhedkar" Date: Thu, 27 Feb 2020 12:55:59 -0500 Subject: XACML pdp support for clc. Added policies for SON and PCI to support each blocking the other, with test cases and appropriate requests Issue-ID: POLICY-2163 Change-Id: I8153f9cd973a7cd6824fcd6c9787628a74148d46 Signed-off-by: pramod.jamkhedkar --- .../guard/CoordinationGuardTranslator.java | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'applications/guard/src/main') diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java index eb86486d..60fac498 100644 --- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java +++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,12 +94,20 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { } } + /** + * This function is not used for CLC instead + * the one in LegacyGuardTranslator is used. + */ @Override public Request convertRequest(DecisionRequest request) { LOGGER.info("this convertRequest shouldn't be used"); return null; } + /** + * This function is not used for CLC instead + * the one in LegacyGuardTranslator is used. + */ @Override public DecisionResponse convertResponse(Response xacmlResponse) { LOGGER.info("this convertResponse shouldn't be used"); @@ -112,13 +120,15 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { * @param directiveFilename yaml directive file to load * @return the CoordinationDirective */ - public static CoordinationDirective loadCoordinationDirectiveFromFile(String directiveFilename) { + public static CoordinationDirective loadCoordinationDirectiveFromFile( + String directiveFilename) { try (InputStream is = new FileInputStream(new File(directiveFilename))) { String contents = IOUtils.toString(is, StandardCharsets.UTF_8); // // Read the yaml into our Java Object // - CoordinationDirective obj = new StandardYamlCoder().decode(contents, CoordinationDirective.class); + CoordinationDirective obj = + new StandardYamlCoder().decode(contents, CoordinationDirective.class); LOGGER.debug(contents); return obj; } catch (IOException | CoderException e) { @@ -135,11 +145,12 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { * @return the generated Xacml policy */ public static String generateXacmlFromCoordinationDirective(CoordinationDirective cd, - String protoDir) throws ToscaPolicyConversionException { + String protoDir) throws ToscaPolicyConversionException { /* * Determine file names */ - String xacmlProtoFilename = protoDir + File.separator + cd.getCoordinationFunction() + ".xml"; + String xacmlProtoFilename = + protoDir + File.separator + cd.getCoordinationFunction() + ".xml"; LOGGER.debug("xacmlProtoFilename={}", xacmlProtoFilename); /* * Values to be used for placeholders @@ -156,8 +167,8 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { .map(s -> s.replace("CONTROL_LOOP_TWO", cLTwo)) .collect(Collectors.joining(XacmlPolicyUtils.LINE_SEPARATOR)); } catch (IOException e) { - throw new - ToscaPolicyConversionException("Error while generating XACML policy for coordination directive", e); + throw new ToscaPolicyConversionException( + "Error while generating XACML policy for coordination directive", e); } } -- cgit 1.2.3-korg