aboutsummaryrefslogtreecommitdiffstats
path: root/applications/common/src/main
AgeCommit message (Collapse)AuthorFilesLines
2021-06-23Use protected methods vs privatePamela Dragosh2-8/+9
Application and common code in xacml-pdp is meant to be available for developers to re-use and/or extend as desired. Private methods are unnecessary at this time, but could be re-visited in a later release. For Honolulu, simply moving to protected to keep functionality the same. Possibly for Istanbul we can make more changes to support mixing of ONAP application with custom applications during runtime. Issue-ID: POLICY-3305 Change-Id: I6db23bda3c81fdbbf86e39cc2cd2e706d8bee63d Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2021-02-19Fix junit for "native" on WindowsJim Hahn1-2/+12
Windows doesn't like file names containing ":". Added code to replace ":" with "_", but only when the JVM is run on a Windows OS. Issue-ID: POLICY-3085 Change-Id: I1d3b6819bf564571eddda69e4c5fbd2bb807a3aa Signed-off-by: Jim Hahn <jrh3@att.com>
2021-02-18Utilize time extensionsPamela Dragosh1-3/+29
Switched to using the new Time Extensions released in XACML from github v3.0. Added more thorough tests for it as well as the flexibility of specifying the current time etc. More syntax checking on the inputs from the policy. Issue-ID: POLICY-2810 Change-Id: I1b4ec885c706e37949e5dabe14c63b0d7456cd4f Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2021-01-04Changed identifiers to concept identifiersliamfallon5-28/+32
The policy models tosca classes ToscaPolicyIdentifier and ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA concept, not just TOSCA policies so they are renamed to ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion respectively. The class ToscaPolicyTypeIdentifier is redundant and is replaced by ToscaConceptIdentifier. Issue-ID: POLICY-2900 Change-Id: Id614bbed34ed8897e7e882b70147b98ffe90bf57 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-04Fix sonar issues with visibilityPamela Dragosh3-4/+4
S5993 Change the visibility of this constructor to "protected". Issue-ID: POLICY-2912 Change-Id: I2fd9fcd3162c8bf28ba0315939ef259356f442db Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-11-30ToscaEntityType renamed ToscaSchemaDefinitionliamfallon9-42/+55
The TOSCA class ToscaEntityType is renamed to ToscaSchemaDefinition becasue keys as well as entities can have schemas, so the class has more usages than just for entity schemas. Issue-ID: POLICY-2900 Change-Id: I7a1a3a1262078c47eeea1820538ecb6153f5e652 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-10-02Remove duplicated codePamela Dragosh1-3/+9
Initially, just moving the applicationName and actions as protected fields got rid of the sonar issue. I included also the supportedPolicyTypes also. But that triggered another sonar duplicate code, so I had to rename a few private fields to rid that. Seems like a very sensitive sonar detection that results in kludgy code. Issue-ID: POLICY-2681 Change-Id: Ie79a95786cdb80381cbce4b182e9e66a2776e0dd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-09-16Remove base64 encoding of password from xacmlRam Krishna Verma1-8/+1
Issue-ID: POLICY-2550 Change-Id: I05d9af99401991ea867e7ab8d697692c9020b3b7 Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
2020-06-19Changes for Checkstyle 8.32Taka Cho4-9/+2
Issue-ID: POLICY-2188 Change-Id: I64a115240a71e5014db9cfb66747887e156afb50 Signed-off-by: Taka Cho <takamune.cho@att.com>
2020-06-02Merge "Use OperationsHistory from models"Pamela Dragosh4-88/+8
2020-06-01Use OperationsHistory from modelsJim Hahn4-88/+8
Deleted Dbao and replaced it with the shared class in policy-models. Also had to update the queries and the persistence.xml accordingly. Issue-ID: POLICY-2581 Change-Id: I59dfa2f37c272796ccebc0f578c9f4e8e1b9c8ab Signed-off-by: Jim Hahn <jrh3@att.com>
2020-05-29Use default serialization providerJim Hahn1-2/+0
The default provider has been changed to gson, so the provider property no longer has to be set. Issue-ID: POLICY-1527 Change-Id: I21f5a3af2bc1d7fc10dc41f58e6e62a04f4bda77 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-05-27Merge "Change CLC logic for updated OPHist DB entries."Pamela Dragosh1-17/+19
2020-05-26Change CLC logic for updated OPHist DB entries.pramod.jamkhedkar1-17/+19
Change the CLC policy logic to match the udpate Operations History DB rules. Now if a record has outcome = Started, it is considered to be in progress. Else it is considered to be complete. Issue-ID: POLICY-2583 Change-Id: If3f626bfec2d0656e43a26929107f68ff27af020 Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
2020-05-21Add secondary indices to operationshistory tableJim Hahn1-4/+5
Queries to the operationshistory table will degrade substantially as more records are added to the DB. The Dbao class should be moved to policy-models, but for now we'll just update it in both places (i.e., drools-apps and xacml-pdp). Issue-ID: POLICY-2581 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Icc4529e56968ceda4d9b63a8ccea6ba219250506 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-05-19Change CLC granularity to CL level.pramod.jamkhedkar1-5/+3
Change CLC granularity from target level to CL level. Remove the target matching for the db query at PIP level. Issue-ID: POLICY-2573 Change-Id: If9ba1a4d22c3b8bc5dfce0632f7037ad085f6ea6 Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
2020-04-13Fix integer converted to doublePamela Dragosh1-2/+5
Use policy/common map double converter to ensure integers saved in policy content do not get converted to doubles. Issue-ID: POLICY-2486 Change-Id: I887c6b5c337e2594c425b645af4b2668d06715bd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-20use shutdown to clear handle leakPamela Dragosh6-4/+47
The XACML github was released with a new method to allow context factories and PIP engines to release any handles before releasing the PDP engine. This review includes that artifact and adds tests to support it. In addition, added more tests to get code coverage over 90% for both PIPs in ONAP. Some cleanup in the Matchable types based on last review. Issue-ID: POLICY-2242 Change-Id: I312f06380ff4d2e16bcfd25b6d1f36ce5dd030e6 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-19Re-factor matchable to reduce complexityPamela Dragosh14-457/+1116
This solution is much cleaner than what is in StdMatchableTranslator. Over 90% code coverage on it - utilizes a callback to retrieve DataType and PolicyTypes. Support for missing timestamp TOSCA type. Also can do a better job differentiating between a property contained in the policy vs a schema. Changed StdMatchableTranslator to utilize these classes. And removed the old spaghetti. Added some JUnit coverage for ToscaPolicyTranslatorUtils. Removed duplicate code in the XACML Native Exception classes. Issue-ID: POLICY-2242 Change-Id: I18f898d9e65f6da28e3b27517d40f8d389de18a0 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-16Missing support for PolicySetTypePamela Dragosh6-15/+42
Adds support for PolicySetType specifically for Native policies. When/If the other applications change to support they can easily do so. Adding some more code coverage for Native application and translator. Issue-ID: POLICY-2433 Change-Id: I463ca9f04928d759624a2176598b463057d386bd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-12Better error handling for decisionsPamela Dragosh5-18/+20
Throw exceptions when requests cannot be created and return error information back. Consolidated some code to avoid sonar duplication issues. Companion review to https://gerrit.onap.org/r/c/policy/models/+/103548 Issue-ID: POLICY-2242 Change-Id: Ic873af933dab82e3aeef6335f55939666be20385 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-11Fix sonar logging bugsPamela Dragosh6-12/+12
These did not show up locally - sonarqube must have a new version or rules to pick these up. Issue-ID: POLICY-2242 Change-Id: I3df5aee84f696cde6b07c68913bbd55e95c8ba3b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-10Misc XACML code coveragePamela Dragosh4-127/+35
Removed duplicate code from operations history classes. added code coverage to other classes. cleared sonar in main for args Issue-ID: POLICY-2242 Change-Id: Ief548c96a180c132a3f17681d9cbc018c62e42ac Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-10Fix optimization bug add coverage plusPamela Dragosh4-14/+55
Fix a NPE bug and add more code coverage. Also is missing returning of context details for subscriber policies. This code is a bit ad-hoc and there is a separate JIRA POLICY-2147 to support re-factoring this codebase. Added scanning for advice to be returned. For optimization, because of the need for some changes in XACML github dependency, we are stuck with a little narly code to get it to fully work. POLICY-2417 is created to address this in Guilen. Upgraded to released XACML artifact - this has been tested locally for a few weeks with naming, guard and this optimzation code. It removed Jackson in lieu of Json, cleaned up some security fixes, upgraded dependencies, and added more code coverage. Issue-ID: POLICY-2066 Change-Id: I3cae99de265c815200ec2ce71e471338772bdb5b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-09Updates to support fixed guard policy typesPamela Dragosh3-8/+81
Because the new TOSCA compliant policy types support required fields, we can simplify the guard translator to utilize Match in the target vs the previous complicated Condition usage. Added test coverage to bump above 90% specifically for the guard and coordination code. Added a sonar exclusion for the test module. Issue-ID: POLICY-2244 Change-Id: Ia90d117bd7b86d28a2268fd5ab8315dce7bf0c12 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-02-19Use datatype in matchable translatorPamela Dragosh2-177/+372
With the new changes to models/api, the full policy template will be retrieved along with inherited policy types and datatypes. Changed api caller to return tosca template instead of individual policy type so all policy types and data types are available. Changed stdmatchabletranslator to be able to flexibly go deep with list/map of datatypes of attributes. NOTE: This should be re-factored at a later date as its a bit messy. The naming application was used to test this code, but it was determined by the CCSDK team that they will not do filtering this release. Instead, switched to combined results policy type to return the full policy type. Issue-ID: POLICY-1740 Change-Id: Ieb4e46e7fb2c639a1155be3bc07f5587c4f7b09a Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-12-23Add optimization subscriber requestPamela Dragosh3-3/+18
Adding support for a preliminary request to pull subscriber details. The returned decision adds scope attributes for the original request. Fixed some checkstyle issues due to new checkstyle requirements. Issue-ID: POLICY-2066 Change-Id: Ief02d896ce33e4864bb20e9185b0d0f5eb254bfd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-12-17Add SDNC naming applicationPamela Dragosh1-3/+61
Requires changes to StdMatchableTranslator to go deeper when searching for matchable attributes. NOTE: will re-visit the StdMatchableTranslator at a later date in order to support more robust Policy Types. And document best practices for defining matchables. Issue-ID: POLICY-1740 Change-Id: I291cf1c2e6eba0a677a3312dd11f0e56178a805b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-11-13Merge "Implement closest match algorithm"Jorge Hernandez5-98/+533
2019-11-12Implement closest match algorithmPamela Dragosh5-98/+533
Needed to add more obligations, which make it easier to scan through obligations and be able to pull information about the policy. Adding weight as an obligation for Optimization policies in order to implement "closest match" algorithm. Moved Obligation to a support class. Added JUnit code coverage on the translator classes. Split some methods up to reduce complexity via sonar. Issue-ID: POLICY-2066 Change-Id: Ibb13d2dc0a63ab2a6d585b0697a0c1d129fa8f7b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-11-12Added support to return status and error if pdp-x failed to load policyAli Hockla2-5/+3
Issue-ID: POLICY-2175 Change-Id: I32d2fe78846f58d6e700100dd523732817f1f04d Signed-off-by: Ali Hockla <ah999m@att.com>
2019-11-04More examples of optimization policies and cleanupPamela Dragosh1-28/+33
Fixed a couple of sonar issues - log exception and do not nest more 3 if-else-try. Cleaned up the JUnit test to make debugging a bit easier. Added more examples for testing optimization tests. Moved the target back into the Policy and kept the Condition on the Rule. Works exactly the same, just a bit cleaner and one less rule to deal with. Issue-ID: POLICY-2066 Change-Id: Ife28dc2ce959dcf1fb8ca72061ebc5dca862a7f4 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-10-28Optimization improvements and test casesPamela Dragosh3-46/+284
* StdBaseTranslator added helpful support methods and can now add obligations to either rule, policy or policy sets. * StdMatchablePolicyRequest improved to support optional policy-type as part of the request to refine the output results. * Added more tests to ensure that the decision is returning the appropriate results. * Added more Javadoc for code. * Added some sonar fix for either log or throw exception. Issue-ID: POLICY-2066 Change-Id: I90d6d90c2cdbb627e96cfce1d2632b2439a1e477 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-10-24Fix sonar and coveragePamela Dragosh1-30/+36
Turns out cyclomatic complexity is there in one method. The other JUnits in the applications cover the rest of the class, when time permits I will add that in there for completeness. Issue-ID: POLICY-2066 Change-Id: I31fd43625883bd569d4078bbd684554f6f3fbf53 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-10-23Consolidate common translatable code some sonarPamela Dragosh5-319/+210
There is duplicate code for some common translation of policy decision responses and for scanning obligations. Removed some TODO items (left others because I want to look at them more closely). Stored System.lineSeparator into a static var so that I can remove some unnecessary ifs. There's still one left that I am not worried about. Gson as a static variable. Issue-ID: POLICY-2066 Change-Id: I9c8162d5ad1c5f884be347dd94631fa74ca76f85 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-10-21Use yaml policies in models-examplesPamela Dragosh1-4/+5
Now that yaml is supported, use those policies that are stored in the models-examples that are preloaded into the api. Fixed a minor checkstyle issue. Not sure why it was missed. Issue-ID: POLICY-2066 Change-Id: I2f4384a310bfa818555de5dacb477daf82fac6de Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-10-18Modified Decision API to accept query parameters and abbreviate Monitor ↵HOCKLA2-4/+6
decision results Issue-ID: POLICY-2126 Change-Id: I18d50a8746ede792ec9507ab98125383c5914ba1 Signed-off-by: HOCKLA <ah999m@att.com>
2019-10-09Sonar xacml-pdp issuesPamela Dragosh3-85/+99
Either log or re-throw exception Refactor to not nest more than 3 statements Refactor to throw at most one exception Move variable to comply with Java Code conventions String literal on LHS Issue-ID: POLICY-2079 Change-Id: Iac33623ef4694cf38c4a69c8f0b9040d8439998e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-10-02Removed TestUtils from common and into a 'xacml-test' projectAli Hockla1-89/+0
Issue-ID: POLICY-2090 Change-Id: Id688e305f878f56e374e6bd9047d9d6c75fbe0c6 Signed-off-by: Ali Hockla <ah999m@att.com>
2019-09-13Upgrade to Tosca derivedFrom fixPamela Dragosh3-11/+4
Upgrade to models fix for derivedFrom() append of 0.0.0 And some sonar fixes for: Exceptions should be either logged or rethrown but not both Preconditions" and logging arguments should not require evaluation Reduced cognitive complexity Issue-ID: POLICY-2079 Change-Id: Ied8630020e8a737c33b1484db953df133c89398f Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-09-12Add yaml support to xacml-pdp rest serverJim Hahn2-8/+3
Also modified code to use StandardYamlCoder. Change-Id: I0596c8b054339ac68ef8c4250cd25b9ff88d47e4 Issue-ID: POLICY-2085 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-09Integrate using Policy Type to find MatchablePamela Dragosh6-92/+410
Utilize's Jim's helper class to pull from API policy types definitions so that Xacml PDP can determine which properties are "matchable". Override initialize to set translator parameters. Utilize the metadata section of ToscaProperties to store the matchable field. Updated Matchable Request to be dynamic with respect to the incoming resource attributes. Stored the policy types as JSON. Issue-ID: POLICY-1899 Change-Id: Icff3605495b0a34ebfcdfa54346095ce2d8468a4 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-08-30Get policy type from policy-apiJim Hahn3-0/+187
Added a class to retrieve a policy type from the policy-api. Updated property files to include parameters that are needed to configure it. Updates per review comments: - change PolicyApi to PolicyApiCaller - use HttpClientFactory - removed superfluous constructors from exception classes - changed parameters to use RestServerParameters instead of BusTopicParams Change-Id: I8aad6ca5a733c8ad9cc983496e745ebe7400dd17 Issue-ID: POLICY-1911 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-23Add more junit coverage to xacml-pdp (round #2)Jim Hahn5-81/+47
Also removed unused methods. Also extracted constants. Change-Id: I8d2cff05a365f145f2080369e9ea52d08be7e508 Issue-ID: POLICY-1772 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-03Fix xacml decision policy-typePamela Dragosh2-5/+6
Wrong attribute id was being used. Added info logging statement to assist in debugging. Added JUnit to support this. Issue-ID: POLICY-1843 Change-Id: I11d83574f91751804a45281d2e0c9cd3150e30eb Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-05-16Change to fix SQLInvalidAuthorizationSpecExceptionMichael Mokry2-0/+18
Added code to decode password and set property Change-Id: Ied806fcceeaa44d53ca39af636da620fb824e41d Issue-ID: POLICY-1760 Signed-off-by: Michael Mokry <michael.mokry@att.com>
2019-05-08Change debug to info logsPamela Dragosh6-34/+34
A lot of debug should really be info for logs. To assist with debugging but also really need to be there for auditing. Issue-ID: POLICY-1730 Change-Id: I5c41e056775c24797d257504e9c6495fa3127e45 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-05-03Decision should return dictionaryPamela Dragosh2-31/+39
When scanning obligation, should return a map of policy id as dictionary. Issue-ID: POLICY-1735 Change-Id: I46375d761e04c3cc8bd2d428a9d843b3f24478ca Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-04-15Fix a couple of sonar issues one blockerMichael Mokry1-1/+1
1. fixed nullpointer blocker issue in CoordinationGuardTranslator.java 2. fixed "log or rethrow exception" critical issue 3. throw exceptions instead of returning null values Change-Id: I2d567fe566c6f761ec2699016c4a868f203c9a01 Issue-ID: POLICY-1451 Signed-off-by: Michael Mokry <michael.mokry@att.com> Signed-off-by: Joshua Reich <jreich@research.att.com>
2019-04-12Add statistics and sonar cleanup and blacklistPamela Dragosh8-12/+52
* Adding in the statistics for decisions and errors. * Cleaned up sonar issues and added code coverage. * Sped up JUnit tests * Fix JUnit issues with not finding application path * Fix TestDecision not finding persistence.xml * Fix for lingering statistics from previous runs. That needs to be addressed at a later time. * Changed persistence to use properties for configuration of database rather than hard coding the persistence.xml * Fix for Josh's comment to use else-if * Changed to use apache Pair * Added blacklist guard policy Issue-ID: POLICY-1440 Change-Id: I56af8c3dcc82463f7381f1eaea7f1440b76200bd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>