2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.policy.pap.xacml.rest.components;
23 import java.io.BufferedWriter;
25 import java.io.FileWriter;
26 import java.io.IOException;
27 import java.io.StringReader;
29 import java.net.URISyntaxException;
30 import java.nio.file.Path;
31 import java.nio.file.Paths;
32 import java.util.HashMap;
34 import java.util.Scanner;
35 import java.util.StringTokenizer;
37 import javax.xml.parsers.ParserConfigurationException;
38 import javax.xml.parsers.SAXParser;
39 import javax.xml.parsers.SAXParserFactory;
41 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
42 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
43 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
44 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
45 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
46 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
47 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
48 import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
49 import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
50 import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
51 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
52 import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
53 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
55 import org.apache.commons.io.FilenameUtils;
56 import org.apache.commons.logging.Log;
57 import org.apache.commons.logging.LogFactory;
58 import org.openecomp.policy.pap.xacml.rest.adapters.PolicyRestAdapter;
59 import org.openecomp.policy.common.logging.eelf.MessageCodes;
60 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
62 import org.xml.sax.ErrorHandler;
63 import org.xml.sax.InputSource;
64 import org.xml.sax.SAXException;
65 import org.xml.sax.SAXParseException;
66 import org.xml.sax.XMLReader;
68 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
69 import com.att.research.xacml.std.IdentifierImpl;
71 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
72 import org.openecomp.policy.common.logging.flexlogger.Logger;
74 public class ConfigPolicy extends Policy {
79 private static final Logger logger = FlexLogger.getLogger(ConfigPolicy.class);
81 public static final String JSON_CONFIG = "JSON";
82 public static final String XML_CONFIG = "XML";
83 public static final String PROPERTIES_CONFIG = "PROPERTIES";
84 public static final String OTHER_CONFIG = "OTHER";
86 private String configBodyData;
88 public ConfigPolicy() {
92 public ConfigPolicy(PolicyRestAdapter policyAdapter){
93 this.policyAdapter = policyAdapter;
96 // Saving the Configurations file at server location for config policy.
97 protected void saveConfigurations(String policyName) {
98 final Path gitPath = Paths.get(policyAdapter.getUserGitPath().toString());
99 String policyDir = policyAdapter.getParentPath().toString();
100 int startIndex = policyDir.indexOf(gitPath.toString()) + gitPath.toString().length() + 1;
101 policyDir = policyDir.substring(startIndex, policyDir.length());
102 logger.info("print the main domain value"+policyDir);
103 String path = policyDir.replace('\\', '.');
104 if(path.contains("/")){
105 path = policyDir.replace('/', '.');
106 logger.info("print the path:" +path);
111 String configFileName = getConfigFile(policyName);
112 if(CONFIG_HOME.contains("\\"))
114 file = new File(CONFIG_HOME + "\\" + path + "."+ configFileName);
118 file = new File(CONFIG_HOME + "/" + path + "."+ configFileName);
121 // if file doesnt exists, then create it
122 if (!file.exists()) {
123 file.createNewFile();
127 File configHomeDir = new File(CONFIG_HOME);
128 File[] listOfFiles = configHomeDir.listFiles();
129 if (listOfFiles != null){
130 for(File eachFile : listOfFiles){
131 if(eachFile.isFile()){
132 String fileNameWithoutExtension = FilenameUtils.removeExtension(eachFile.getName());
133 String configFileNameWithoutExtension = FilenameUtils.removeExtension(path + "." + configFileName);
134 if (fileNameWithoutExtension.equals(configFileNameWithoutExtension)){
142 FileWriter fw = new FileWriter(file.getAbsoluteFile());
143 BufferedWriter bw = new BufferedWriter(fw);
144 bw.write(configBodyData);
146 if (logger.isDebugEnabled()) {
147 logger.debug("Configuration is succesfully saved");
149 } catch (IOException e) {
154 // Here we are adding the extension for the configurations file based on the
155 // config type selection for saving.
156 private String getConfigFile(String filename) {
157 filename = FilenameUtils.removeExtension(filename);
158 if (filename.endsWith(".xml")) {
159 filename = filename.substring(0, filename.length() - 4);
161 String id = policyAdapter.getConfigType();
164 if (id.equalsIgnoreCase(JSON_CONFIG)) {
165 filename = filename + ".json";
167 if (id.equalsIgnoreCase(XML_CONFIG)) {
168 filename = filename + ".xml";
170 if (id.equalsIgnoreCase(PROPERTIES_CONFIG)) {
171 filename = filename + ".properties";
173 if (id.equalsIgnoreCase(OTHER_CONFIG)) {
174 filename = filename + ".txt";
180 // Validations for Config form
182 * FORM VALIDATION WILL BE DONE BY THE PAP-ADMIN before creating JSON object...
183 * BODY VALIDATION WILL BE DONE BY THE PAP-REST after receiving and deserializing the JSON object
185 public boolean validateConfigForm() {
190 * Validate Text Area Body
192 configBodyData = policyAdapter.getConfigBodyData();
193 String id = policyAdapter.getConfigType();
195 if (id.equals(JSON_CONFIG)) {
196 if (!isJSONValid(configBodyData)) {
199 } else if (id.equals(XML_CONFIG)) {
200 if (!isXMLValid(configBodyData)) {
203 } else if (id.equals(PROPERTIES_CONFIG)) {
204 if (!isPropValid(configBodyData)||configBodyData.equals("")) {
207 } else if (id.equals(OTHER_CONFIG)) {
208 if (configBodyData.equals("")) {
217 // Validation for XML.
218 private boolean isXMLValid(String data) {
220 SAXParserFactory factory = SAXParserFactory.newInstance();
221 factory.setValidating(false);
222 factory.setNamespaceAware(true);
224 SAXParser parser = factory.newSAXParser();
225 XMLReader reader = parser.getXMLReader();
226 reader.setErrorHandler(new XMLErrorHandler());
227 reader.parse(new InputSource(new StringReader(data)));
228 } catch (ParserConfigurationException e) {
230 } catch (SAXException e) {
232 } catch (IOException e) {
239 // Validation for Properties file.
240 public boolean isPropValid(String prop) {
242 Scanner scanner = new Scanner(prop);
243 while (scanner.hasNextLine()) {
244 String line = scanner.nextLine();
245 line.replaceAll("\\s+", "");
246 if (line.startsWith("#")) {
249 if (line.contains("=")) {
250 String[] parts = line.split("=");
251 if (parts.length < 2) {
266 public class XMLErrorHandler implements ErrorHandler {
268 public void warning(SAXParseException e) throws SAXException {
269 System.out.println(e.getMessage());
272 public void error(SAXParseException e) throws SAXException {
273 System.out.println(e.getMessage());
276 public void fatalError(SAXParseException e) throws SAXException {
277 System.out.println(e.getMessage());
283 public Map<String, String> savePolicies() throws Exception {
285 Map<String, String> successMap = new HashMap<String,String>();
286 if(isPolicyExists()){
287 successMap.put("EXISTS", "This Policy already exist on the PAP");
291 if(!isPreparedToSave()){
292 //Prep and configure the policy for saving
296 // Until here we prepared the data and here calling the method to create xml.
297 Path newPolicyPath = null;
298 newPolicyPath = Paths.get(policyAdapter.getParentPath().toString(), policyName);
299 successMap = createPolicy(newPolicyPath,getCorrectPolicyDataObject() );
300 if (successMap.containsKey("success")) {
301 Path finalPolicyPath = getFinalPolicyPath();
302 policyAdapter.setFinalPolicyPath(finalPolicyPath.toString());
307 //This is the method for preparing the policy for saving. We have broken it out
308 //separately because the fully configured policy is used for multiple things
310 public boolean prepareToSave() throws Exception{
312 if(isPreparedToSave()){
313 //we have already done this
318 String policyID = policyAdapter.getPolicyID();
320 if (policyAdapter.isEditPolicy()) {
321 version = policyAdapter.getHighestVersion() + 1;
326 // Create the Instance for pojo, PolicyType object is used in marshalling.
327 if (policyAdapter.getPolicyType().equals("Config")) {
328 PolicyType policyConfig = new PolicyType();
330 policyConfig.setVersion(Integer.toString(version));
331 policyConfig.setPolicyId(policyID);
332 policyConfig.setTarget(new TargetType());
333 policyAdapter.setData(policyConfig);
336 if (policyAdapter.getData() != null) {
338 // Save off everything
339 // making ready all the required elements to generate the action policy xml.
340 // Get the uniqueness for policy name.
341 Path newFile = getNextFilename(Paths.get(policyAdapter.getParentPath().toString()), policyAdapter.getPolicyType(), policyAdapter.getPolicyName(), version);
342 if (newFile == null) {
343 //TODO:EELF Cleanup - Remove logger
344 //logger.error("File already exists");
345 PolicyLogger.error("File alrady exists");
346 setPolicyExists(true);
349 policyName = newFile.getFileName().toString();
351 // Body is optional so checking.
352 configBodyData = policyAdapter.getConfigBodyData();
353 if (!configBodyData.equals("")) {
354 // Save the Configurations file with the policy name with extention based on selection.
355 saveConfigurations(policyName);
358 // Make sure the filename ends with an extension
359 if (policyName.endsWith(".xml") == false) {
360 policyName = policyName + ".xml";
364 PolicyType configPolicy = (PolicyType) policyAdapter.getData();
366 configPolicy.setDescription(policyAdapter.getPolicyDescription());
368 configPolicy.setRuleCombiningAlgId(policyAdapter.getRuleCombiningAlgId());
369 AllOfType allOfOne = new AllOfType();
370 final Path gitPath = Paths.get(policyAdapter.getUserGitPath().toString());
371 String policyDir = policyAdapter.getParentPath().toString();
372 int startIndex = policyDir.indexOf(gitPath.toString()) + gitPath.toString().length() + 1;
373 policyDir = policyDir.substring(startIndex, policyDir.length());
374 logger.info("print the main domain value "+policyDir);
375 String path = policyDir.replace('\\', '.');
376 if(path.contains("/")){
377 path = policyDir.replace('/', '.');
378 logger.info("print the path:" +path);
380 String fileName = FilenameUtils.removeExtension(policyName);
381 fileName = path + "." + fileName + ".xml";
382 String name = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
383 if ((name == null) || (name.equals(""))) {
384 name = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length());
386 allOfOne.getMatch().add(createMatch("PolicyName", name));
387 AllOfType allOf = new AllOfType();
389 // Adding the matches to AllOfType element Match for Ecomp
390 allOf.getMatch().add(createMatch("ECOMPName", policyAdapter.getEcompName()));
391 // Match for riskType
392 allOf.getMatch().add(
393 createDynamicMatch("RiskType", policyAdapter.getRiskType()));
394 // Match for riskLevel
395 allOf.getMatch().add(
396 createDynamicMatch("RiskLevel", String.valueOf(policyAdapter.getRiskLevel())));
397 // Match for riskguard
398 allOf.getMatch().add(
399 createDynamicMatch("guard", policyAdapter.getGuard()));
401 allOf.getMatch().add(
402 createDynamicMatch("TTLDate", policyAdapter.getTtlDate()));
403 // Match for ConfigName
404 allOf.getMatch().add(createMatch("ConfigName", policyAdapter.getConfigName()));
406 Map<String, String> dynamicFieldConfigAttributes = policyAdapter.getDynamicFieldConfigAttributes();
408 // If there is any dynamic field create the matches here
409 for (String keyField : dynamicFieldConfigAttributes.keySet()) {
410 String key = keyField;
411 String value = dynamicFieldConfigAttributes.get(key);
412 MatchType dynamicMatch = createDynamicMatch(key, value);
413 allOf.getMatch().add(dynamicMatch);
416 AnyOfType anyOf = new AnyOfType();
417 anyOf.getAllOf().add(allOfOne);
418 anyOf.getAllOf().add(allOf);
420 TargetType target = new TargetType();
421 ((TargetType) target).getAnyOf().add(anyOf);
423 // Adding the target to the policy element
424 configPolicy.setTarget((TargetType) target);
426 RuleType rule = new RuleType();
427 rule.setRuleId(policyAdapter.getRuleID());
429 rule.setEffect(EffectType.PERMIT);
431 // Create Target in Rule
432 AllOfType allOfInRule = new AllOfType();
434 // Creating match for ACCESS in rule target
435 MatchType accessMatch = new MatchType();
436 AttributeValueType accessAttributeValue = new AttributeValueType();
437 accessAttributeValue.setDataType(STRING_DATATYPE);
438 accessAttributeValue.getContent().add("ACCESS");
439 accessMatch.setAttributeValue(accessAttributeValue);
440 AttributeDesignatorType accessAttributeDesignator = new AttributeDesignatorType();
441 URI accessURI = null;
443 accessURI = new URI(ACTION_ID);
444 } catch (URISyntaxException e) {
445 //TODO:EELF Cleanup - Remove logger
446 //logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getStackTrace());
447 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "ConfigPolicy", "Exception creating ACCESS URI");
449 accessAttributeDesignator.setCategory(CATEGORY_ACTION);
450 accessAttributeDesignator.setDataType(STRING_DATATYPE);
451 accessAttributeDesignator.setAttributeId(new IdentifierImpl(accessURI).stringValue());
452 accessMatch.setAttributeDesignator(accessAttributeDesignator);
453 accessMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
455 // Creating Config Match in rule Target
456 MatchType configMatch = new MatchType();
457 AttributeValueType configAttributeValue = new AttributeValueType();
458 configAttributeValue.setDataType(STRING_DATATYPE);
459 configAttributeValue.getContent().add("Config");
460 configMatch.setAttributeValue(configAttributeValue);
461 AttributeDesignatorType configAttributeDesignator = new AttributeDesignatorType();
462 URI configURI = null;
464 configURI = new URI(RESOURCE_ID);
465 } catch (URISyntaxException e) {
466 //TODO:EELF Cleanup - Remove logger
467 //logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getStackTrace());
468 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "ConfigPolicy", "Exception creating Config URI");
470 configAttributeDesignator.setCategory(CATEGORY_RESOURCE);
471 configAttributeDesignator.setDataType(STRING_DATATYPE);
472 configAttributeDesignator.setAttributeId(new IdentifierImpl(configURI).stringValue());
473 configMatch.setAttributeDesignator(configAttributeDesignator);
474 configMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
476 allOfInRule.getMatch().add(accessMatch);
477 allOfInRule.getMatch().add(configMatch);
479 AnyOfType anyOfInRule = new AnyOfType();
480 anyOfInRule.getAllOf().add(allOfInRule);
482 TargetType targetInRule = new TargetType();
483 targetInRule.getAnyOf().add(anyOfInRule);
485 rule.setTarget(targetInRule);
486 rule.setAdviceExpressions(getAdviceExpressions(version, policyName));
488 configPolicy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(rule);
489 policyAdapter.setPolicyData(configPolicy);
492 //TODO:EELF Cleanup - Remove logger
493 //logger.error("Unsupported data object." + policyAdapter.getData().getClass().getCanonicalName());
494 PolicyLogger.error("Unsupported data object." + policyAdapter.getData().getClass().getCanonicalName());
496 setPreparedToSave(true);
500 // Data required for Advice part is setting here.
501 private AdviceExpressionsType getAdviceExpressions(int version, String fileName) {
502 AdviceExpressionsType advices = new AdviceExpressionsType();
503 AdviceExpressionType advice = new AdviceExpressionType();
504 advice.setAdviceId("configID");
505 advice.setAppliesTo(EffectType.PERMIT);
508 AttributeAssignmentExpressionType assignment1 = new AttributeAssignmentExpressionType();
509 assignment1.setAttributeId("type");
510 assignment1.setCategory(CATEGORY_RESOURCE);
511 assignment1.setIssuer("");
513 AttributeValueType configNameAttributeValue = new AttributeValueType();
514 configNameAttributeValue.setDataType(STRING_DATATYPE);
515 configNameAttributeValue.getContent().add("Configuration");
516 assignment1.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue));
518 advice.getAttributeAssignmentExpression().add(assignment1);
519 final Path gitPath = Paths.get(policyAdapter.getUserGitPath().toString());
521 // For Config file Url if configurations are provided.
522 if (policyAdapter.getConfigType() != null) {
523 AttributeAssignmentExpressionType assignment2 = new AttributeAssignmentExpressionType();
524 assignment2.setAttributeId("URLID");
525 assignment2.setCategory(CATEGORY_RESOURCE);
526 assignment2.setIssuer("");
528 AttributeValueType AttributeValue = new AttributeValueType();
529 AttributeValue.setDataType(URI_DATATYPE);
530 String policyDir1 = policyAdapter.getParentPath().toString();
531 int startIndex1 = policyDir1.indexOf(gitPath.toString()) + gitPath.toString().length() + 1;
532 policyDir1 = policyDir1.substring(startIndex1, policyDir1.length());
533 logger.info("print the main domain value"+policyDir1);
534 String path = policyDir1.replace('\\', '.');
535 if(path.contains("/")){
536 path = policyDir1.replace('/', '.');
537 logger.info("print the path:" +path);
540 String content = "$URL" + "/Config/" + path + "." + getConfigFile(policyName);
541 System.out.println("URL value :" + content);
542 AttributeValue.getContent().add(content);
543 assignment2.setExpression(new ObjectFactory().createAttributeValue(AttributeValue));
545 advice.getAttributeAssignmentExpression().add(assignment2);
546 AttributeAssignmentExpressionType assignment3 = new AttributeAssignmentExpressionType();
547 assignment3.setAttributeId("PolicyName");
548 assignment3.setCategory(CATEGORY_RESOURCE);
549 assignment3.setIssuer("");
551 AttributeValueType attributeValue3 = new AttributeValueType();
552 attributeValue3.setDataType(STRING_DATATYPE);
553 String policyDir = policyAdapter.getParentPath().toString();
554 int startIndex = policyDir.indexOf(gitPath.toString()) + gitPath.toString().length() + 1;
555 policyDir = policyDir.substring(startIndex, policyDir.length());
556 StringTokenizer tokenizer = null;
557 StringBuffer buffer = new StringBuffer();
558 if (policyDir.contains("\\")) {
559 tokenizer = new StringTokenizer(policyDir, "\\");
561 tokenizer = new StringTokenizer(policyDir, "/");
563 if (tokenizer != null) {
564 while (tokenizer.hasMoreElements()) {
565 String value = tokenizer.nextToken();
566 buffer.append(value);
570 fileName = FilenameUtils.removeExtension(fileName);
571 fileName = buffer.toString() + fileName + ".xml";
572 String name = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
573 if ((name == null) || (name.equals(""))) {
574 name = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length());
576 attributeValue3.getContent().add(name);
577 assignment3.setExpression(new ObjectFactory().createAttributeValue(attributeValue3));
578 advice.getAttributeAssignmentExpression().add(assignment3);
580 AttributeAssignmentExpressionType assignment4 = new AttributeAssignmentExpressionType();
581 assignment4.setAttributeId("VersionNumber");
582 assignment4.setCategory(CATEGORY_RESOURCE);
583 assignment4.setIssuer("");
585 AttributeValueType configNameAttributeValue4 = new AttributeValueType();
586 configNameAttributeValue4.setDataType(STRING_DATATYPE);
587 configNameAttributeValue4.getContent().add(Integer.toString(version));
588 assignment4.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue4));
590 advice.getAttributeAssignmentExpression().add(assignment4);
592 AttributeAssignmentExpressionType assignment5 = new AttributeAssignmentExpressionType();
593 assignment5.setAttributeId("matching:" + this.ECOMPID);
594 assignment5.setCategory(CATEGORY_RESOURCE);
595 assignment5.setIssuer("");
597 AttributeValueType configNameAttributeValue5 = new AttributeValueType();
598 configNameAttributeValue5.setDataType(STRING_DATATYPE);
599 configNameAttributeValue5.getContent().add(policyAdapter.getEcompName());
600 assignment5.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue5));
602 advice.getAttributeAssignmentExpression().add(assignment5);
604 AttributeAssignmentExpressionType assignment6 = new AttributeAssignmentExpressionType();
605 assignment6.setAttributeId("matching:" + this.CONFIGID);
606 assignment6.setCategory(CATEGORY_RESOURCE);
607 assignment6.setIssuer("");
609 AttributeValueType configNameAttributeValue6 = new AttributeValueType();
610 configNameAttributeValue6.setDataType(STRING_DATATYPE);
611 configNameAttributeValue6.getContent().add(policyAdapter.getConfigName());
612 assignment6.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue6));
614 advice.getAttributeAssignmentExpression().add(assignment6);
616 Map<String, String> dynamicFieldConfigAttributes = policyAdapter.getDynamicFieldConfigAttributes();
617 for (String keyField : dynamicFieldConfigAttributes.keySet()) {
618 String key = keyField;
619 String value = dynamicFieldConfigAttributes.get(key);
620 AttributeAssignmentExpressionType assignment7 = new AttributeAssignmentExpressionType();
621 assignment7.setAttributeId("matching:" + key);
622 assignment7.setCategory(CATEGORY_RESOURCE);
623 assignment7.setIssuer("");
625 AttributeValueType configNameAttributeValue7 = new AttributeValueType();
626 configNameAttributeValue7.setDataType(STRING_DATATYPE);
627 configNameAttributeValue7.getContent().add(value);
628 assignment7.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue7));
630 advice.getAttributeAssignmentExpression().add(assignment7);
635 AttributeAssignmentExpressionType assignment8 = new AttributeAssignmentExpressionType();
636 assignment8.setAttributeId("RiskType");
637 assignment8.setCategory(CATEGORY_RESOURCE);
638 assignment8.setIssuer("");
640 AttributeValueType configNameAttributeValue8 = new AttributeValueType();
641 configNameAttributeValue8.setDataType(STRING_DATATYPE);
642 configNameAttributeValue8.getContent().add(policyAdapter.getRiskType());
643 assignment8.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue8));
645 advice.getAttributeAssignmentExpression().add(assignment8);
647 AttributeAssignmentExpressionType assignment9 = new AttributeAssignmentExpressionType();
648 assignment9.setAttributeId("RiskLevel");
649 assignment9.setCategory(CATEGORY_RESOURCE);
650 assignment9.setIssuer("");
652 AttributeValueType configNameAttributeValue9 = new AttributeValueType();
653 configNameAttributeValue9.setDataType(STRING_DATATYPE);
654 configNameAttributeValue9.getContent().add(policyAdapter.getRiskLevel());
655 assignment9.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue9));
657 advice.getAttributeAssignmentExpression().add(assignment9);
659 AttributeAssignmentExpressionType assignment10 = new AttributeAssignmentExpressionType();
660 assignment10.setAttributeId("guard");
661 assignment10.setCategory(CATEGORY_RESOURCE);
662 assignment10.setIssuer("");
664 AttributeValueType configNameAttributeValue10 = new AttributeValueType();
665 configNameAttributeValue10.setDataType(STRING_DATATYPE);
666 configNameAttributeValue10.getContent().add(policyAdapter.getGuard());
667 assignment10.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue10));
669 advice.getAttributeAssignmentExpression().add(assignment10);
671 AttributeAssignmentExpressionType assignment11 = new AttributeAssignmentExpressionType();
672 assignment11.setAttributeId("TTLDate");
673 assignment11.setCategory(CATEGORY_RESOURCE);
674 assignment11.setIssuer("");
676 AttributeValueType configNameAttributeValue11 = new AttributeValueType();
677 configNameAttributeValue11.setDataType(STRING_DATATYPE);
678 configNameAttributeValue11.getContent().add(policyAdapter.getTtlDate());
679 assignment11.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue11));
681 advice.getAttributeAssignmentExpression().add(assignment11);
684 advices.getAdviceExpression().add(advice);
689 public Object getCorrectPolicyDataObject() {
690 return policyAdapter.getPolicyData();