aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common
AgeCommit message (Collapse)AuthorFilesLines
2023-09-29Fix security vulnerabilitiesadheli.tavares2-15/+15
- iq nexus vulnerabilities - sonar security hotspots and code smell Issue-ID: POLICY-4761 Issue-ID: POLICY-4833 Change-Id: Iab2e07d2ee7b90031bc5a30210ce7d3f5a47b3fd Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2023-09-21Java 17 Upgradeadheli.tavares7-7/+14
Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2023-02-20Clean up dependencies for London Releaseliamfallon1-1/+6
Issue-ID: POLICY-4482 Change-Id: Ibc0833313bf8eb5330c414ff00a31313500959e6 Signed-off-by: liamfallon <liam.fallon@est.tech>
2022-02-08add constants for policy execution latency metricjhh1-0/+12
Issue-ID: POLICY-3761 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ib4885e8f412c540796de37d18fc553da0a04f46c
2022-02-07add global constant for policy execution metricRashmi Pujar1-1/+28
Issue-ID: POLICY-3845 Signed-off-by: Rashmi Pujar <rashmi.pujar1@bell.ca> Change-Id: Ib72691a80aa56249532058dac9c9e59936254fff
2022-02-02add global constants for prometheus usagejhh1-0/+68
Issue-ID: POLICY-3761 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I3f11d2fdb49d5b38d51add86ab6989e5d93584e9
2021-09-02Create methods for creating temp filesJim Hahn3-14/+102
Created utility methods to create temp files and set default permissions. These can be used in other repos to satisfy sonar. Also added code to close streams and clean up temp files created by some junit tests. Modified to use IOUtils to read a stream. Issue-ID: POLICY-3289 Change-Id: Ic83e4f4d7745be7b37ebb42bf1d81e303d8dadc9 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-08-23Merge "Prevent deadlock in ServiceManager"Ram Krishna Verma1-9/+10
2021-08-23Prevent deadlock in ServiceManagerJim Hahn1-9/+10
Modified the ServiceManager code so that isAlive() can be invoked without requiring synchronization, thus eliminating one potential area of deadlock. Issue-ID: POLICY-3531 Change-Id: I27d060c3a7cfad8dab20a197d1e42c4ee607a1e2 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-08-20Fix sonars and java warnings in commonJim Hahn1-27/+4
Issue-ID: POLICY-3284 Change-Id: I13fc28c6ae681871be8bb9cf3d222d7c65459a44 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-08-04refactor slf4j logger to common utilTaka Cho2-0/+225
avoid EELF lib dependency, was suggested to move to common util instead Issue-ID: POLICY-3087 Change-Id: I79a2f5ba32fd3fc496ef3f72a02f4696b766f9c7 Signed-off-by: Taka Cho <takamune.cho@att.com>
2021-06-25Add name generator for PAP and PDPsJim Hahn1-0/+12
Added a method that PAPs and PDPs can use to generate a unique name or identifier to be used in PAP-PDP messages. Issue-ID: POLICY-3410 Change-Id: I22b075b123f79ba05e0884f743296c4bc64842b9 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-06-17Use lombok in policy-common utilsJim Hahn19-216/+101
Issue-ID: POLICY-3394 Change-Id: I42a18c115c3ca7110f37fc0ae8aeea3f2bbffb37 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-05-27Fix sonar issues in commonJim Hahn1-1/+1
Fixed sonar issue: - class should not be abstract Issue-ID: POLICY-3284 Change-Id: I9c4aa149b7321cbcaff8dce5e2999315a06f19b0 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-05-21Enhance toString methods in factory classesJim Hahn1-11/+2
The factory classes in policy-endpoints have toString() methods that return "[]" for their list contents. Updated the code to provide a list of the keys rather than just an empty list. Also replaced some toString() methods with lombok. Also replace StringBuilder with concatenation in some cases. Issue-ID: POLICY-3298 Change-Id: I64fca21a4b009f7e09fcc482b5d156753fb7e680 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-05-07Change java.util.regex to re2jJim Hahn2-2/+2
Sonar complains about java.util.regex. Thought I used re2j when creating all of the patterns, but apparently not. Fixed that oversight. Issue-ID: POLICY-3284 Change-Id: Idbec112ab0d4c3b477ce357f8a556d95e4dea083 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-05-06Fix sonars in policy-commonJim Hahn15-98/+101
Fixed sonars: - use "var" instead of actual type name - re-interrupt threads - use rej2 split() instead of String split() Issue-ID: POLICY-3285 Change-Id: I82261e0b8a53ee5c5264556fbf5cec37454f014e Signed-off-by: Jim Hahn <jrh3@att.com>
2021-04-13Merge "Revert "Modify StandardCoder to handle empty source""Pamela Dragosh1-22/+5
2021-04-13Revert "Modify StandardCoder to handle empty source"Jim Hahn1-22/+5
This reverts commit 04623fef95f2b164d79ad48de2ef3708d02eda80. Reason for revert: prefer consistency with gson Issue-ID: POLICY-3172 Change-Id: Ic2501abcc68ec1186142a7e520e7985c43fd3315 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-04-13Add command line handleradheli.tavares2-0/+327
Added a Handler for command line classes to share common strucutures. Issue-ID: POLICY-3128 Change-Id: I662911c467faf5c39b8db018bb1a564fba7587a6 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2021-04-07Modify StandardCoder to handle empty sourceJim Hahn1-5/+22
Currently, if the source string or source file is empty, the StandardCoder just returns null. Modified it to throw an exception in those cases. However, if the string reference is null, it will still return null. Issue-ID: POLICY-3172 Change-Id: Ie7d5e1b0328a24d94a75af8d18a341faebbe5d5f Signed-off-by: Jim Hahn <jrh3@att.com>
2021-01-16Add policy-clamp to policy Message constantsliamfallon1-0/+1
policy-clamp is now a valid component inthe policy framework and should be added to the message constants in policy common. Issue-ID: POLICY-2971 Change-Id: Iead3d4f854057c8e968d62928026b74c41bc1346 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-14Convert YAML Double to Integer/LongJim Hahn2-3/+28
When a YAML number is decoded directly to type Object.class using the decode() or fromJson() methods of the StandardYamlCoder, the number is left as a Double. It should be converted to an Integer or Long, where possible. Issue-ID: POLICY-2900 Change-Id: I7707ac5c54167cbc3a4b23985c6e5fa1a507324e Signed-off-by: Jim Hahn <jrh3@att.com>
2020-11-06Fix upcoming checkstyle issuesPamela Dragosh1-8/+8
When we upgrade to oparent, these will fail as oparent upgrades to 8.37 of puppycrawl which fixes a few bugs that should have flagged these previously. Issue-ID: POLICY-2887 Change-Id: I5618ce67d84e94321f884ed6d929c05fc33a0b3d Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-10-29Fix sonar security issue in CryptoUtilsJim Hahn1-4/+6
Sonar reports that CryptoUtils is using AES with CBC, which is known to be insecure. Switched to "AES/GCM/NoPadding". Note: values in any property files using encryption or the "enc:" prefix will have to be re-encrypted. Issue-ID: POLICY-2801 Change-Id: I41f00d4f3ee67a00b92135150120d1faa621655a Signed-off-by: Jim Hahn <jrh3@att.com>
2020-08-14Adding common success/failure messages for policy componentsa.sreekumar1-0/+41
Change-Id: Ic1b0a3b467fd9e4f65b2e12d9f6ed33e38e4f44d Issue-ID: POLICY-2755 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
2020-06-30Fix sonar about always-trust-managerJim Hahn1-25/+2
This trust manager is not secure and should be avoided. However, it is only used when the configuration explicitly says to allow self-signed certificates. Modified the code to use an apache trust manager, thus avoid the sonar complaint. Issue-ID: POLICY-2650 Change-Id: Iaf4c72689916ed5ed5e6864666f3f54b2c5e0f12 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-06-18Changes for checkstyle 8.32liamfallon4-7/+5
Issue-ID: POLICY-2188 Change-Id: I00843c61a6567001fc35c3ebb77b6843a1eb7da2 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-06-17Cleanup various sonar issues in policy-commonJim Hahn2-10/+8
Addressed the following issues: - unused imports - unused method parameters - use assertEquals, assertSame instead of assertTrue - provide the parametrized type for this generic Also fixed some checkstyle issues: - removed blank lines between "import" groups Issue-ID: POLICY-2650 Change-Id: I004bb650ac10c49ccd0fc405f6959896fec39f9b Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-07Update licenses on sonar fixes in commonJim Hahn1-1/+1
Forgot to update licenses on some of the files that were modified as part of addressing sonar issues. Updated. Issue-ID: POLICY-2305 Change-Id: I9858bfb54be5b8eb42406e944361ec100ae238ff Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-06More sonar issues in commonJim Hahn1-2/+10
Fixed additional sonar issues: - infinit loop; while the issue is bogus, it was easy enough to modify the code to satisfy sonar - doesn't like "volatile"; again, the issue is bogus, but easy enough to modify the code Disabled a couple of sonars in NetworkUtil, as they are not actually an issue. Issue-ID: POLICY-2305 Change-Id: I5500183e3fe4060696994cff55bdae4ba7e138c7 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-06Address sonar issues in commonJim Hahn10-114/+82
Addressed the following sonar issues: - missing assertion in junit test case - disable sonars about setAccessible() as it's required for jackson emulation - sleep in junit - don't use wild-cards (e.g., "*") with java.util Pattern - use re2j instead of java.util Pattern - use String methods (e.g., startsWith()) - duplicate method bodies - duplicate code in Coder classes - string concatenation in logger calls - UTF-8 encoding - return primitive instead of boxed primitive - add assertion to tests - renamed support methods from doTestXxx to verifyXxx - cognitive complexity - use AtomicRef instead of volatile - use specific Functionals (e.g., IntConsumer) - function always returns the same value - serializable vs transient Issue-ID: POLICY-2305 Change-Id: I08eb7aa495a80bdc1d26827ba17a7946c83b9828 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-03-24Sonar and eclipse warnings commonPamela Dragosh1-8/+6
Unused imports Not enough arguments Issue-ID: POLICY-2204 Change-Id: I6405cb697ea976096b1276e2291b1c73617d33b5 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-12Move code from drools-apps to commonJim Hahn1-0/+243
Extracted code from ControlLoopUtils to create a new class in common, PropertyObjectUtils. Fixed a deprecated method invocation in a junit. Fixed an object casting (i.e., sonar) issue in SCO. Issue-ID: POLICY-2305 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I331a47297f67097ea6986be125ef93cd1954b5ff
2020-03-03Add gson adapters for special field typesJim Hahn2-1/+126
Added type adapters for Instant, LocalDateTime, and ZonedDateTime. UUID seems to work already. Added new Coder that offers an alternative encoding for Instant. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I5230fa7fe955d78c5f2da1316cb1504b5875ea84
2020-02-17Add convert() to CoderJim Hahn2-1/+66
This addresses Liam's review comment about moving the "translate" method from the actor Util class into policy-common. Added a method to Coder to convert from one object type to another (e.g., from a Map to a POJO, or vice versa). Issue-ID: POLICY-2363 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I2a0b5ab4ce4b0eeda216a57cbe23a8bb64f64940
2020-02-08Add enhancements to standard coderJim Hahn1-13/+57
Added support for array indices in StandardCoderObject getString(). Also made it Serializable. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ia514aed96fdfe7f635c5a6dc3e1f90939654d383
2020-01-31Add pretty() method to CoderJim Hahn4-8/+67
"Pretty" JSON is often needed, so added Coder.pretty() to facilitate that. Incorporated review comment(s): - changed pretty() to encode(object, pretty) Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I180fa6de416836008bf1c410132ae30f4dde9271
2020-01-29Convert double to int when decoding JSONJim Hahn1-1/+3
When decoding straight into a List or Map class, StandardCoder was not applying the double-to-int conversion. Fixed it. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I939e3378645d45ac98d2bca6b2a4076870a05626
2020-01-27Schema validation extension to StandardCoderjhh2-6/+115
Issue-ID: POLICY-2331 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ic3e8d21715d17a61ea5d07740dd9f4dd0dbb8641 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2020-01-22Create path to text file being createdliamfallon1-0/+4
If you try and write to a file where part of the pat does not exist, that path should be created. Issue-ID: POLICY-1581 Change-Id: Ifb7a4ff4e1804814b6679956f0c58d5ac026c4a4 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-01-14Sonar cleanup overrides and fixesPamela Dragosh1-9/+9
Removal of UTF-8 because its already set capabilities doesn't generate any code, no need to include override false positives for passwords etc. override for logging and exception throw that we want add synchronized to overrides that are synchronized ignore checking of some conditions adding synchronized to match set* methods Issue-ID: POLICY-2321 Change-Id: I26d9ca22a0cdd67fdaae9c44b718b8dc103f190e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-01-13Add method to return resource directory contentsliamfallon1-3/+102
In order to avoid hard coding the policy types and policies that are in the example directories into unit test cases, and in order to automatically pick up added and removed policy types and policies, it would be good to read the contents of resource directories at run time in unit tests. This change brings in that functionality into ResourceUtils. Issue-ID: POLICY-2315 Change-Id: I601718828aad0f065dbbaa1f5af8d0a0f133f44d Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-10-29Fix new sonar issues in commonJim Hahn1-3/+3
Issue-ID: POLICY-2204 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If0a11913f614e038ecd3e8c3f0b56d3ac78b03ec Signed-off-by: Jim Hahn <jrh3@att.com>
2019-10-29Merge "Cleanup eclipse warnings in common"Jorge Hernandez1-4/+0
2019-10-29Cleanup eclipse warnings in commonJim Hahn1-4/+0
Issue-ID: POLICY-2204 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If55ea1a804997ab751f15813e6b643572d4f189f
2019-10-29Disable HTML escaping in gson codersJim Hahn1-4/+4
Issue-ID: POLICY-1869 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ic757d3a8e7e0e3537ecba979a919b9ea3c1aa797 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-10-24Integrate CryptoUtils into ONAP commonChou, Joseph (jc2555)1-0/+139
Update junit to add test cases Change-Id: If3236853138a05faac5f51a859b935265c14f0d6 Issue-ID: POLICY-1945 Signed-off-by: Chou, Joseph (jc2555) <jc2555@att.com>
2019-10-21Add CryptoCoder interfacejhh2-7/+43
This is to allow multiple supporting implementations. Issue-ID: POLICY-1945 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I42491e5671f561fe320f034bf8ffe03848dff43f Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2019-10-16Removed unthrown checked exceptions from CryptoUtils.jhh1-10/+3
additional minor javadoc clean up Issue-ID: POLICY-1945 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I23927b8c4dd63ed658e8062c87b4884ea1d31825