summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src
AgeCommit message (Collapse)AuthorFilesLines
2019-11-01Add common Jersey versionliamfallon3-14/+18
Add a common version of Jersey for all Policy Framework components. Issue-ID: POLICY-2209 Change-Id: I8554a97e9f13887418118966bfe1043b65d9a179 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-10-29Cleanup eclipse warnings in commonJim Hahn1-1/+1
Issue-ID: POLICY-2204 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If55ea1a804997ab751f15813e6b643572d4f189f
2019-09-16Eliminate constructors with side-effectsJim Hahn4-2/+7
Several of the Gson and Jackson handlers take a GsonBuilder, which they then configure with additional adapters prior to create a Gson object that they subsequently use. The code has been modified so that the constructors no longer take a GsonBuilder, thus eliminating the side-effects that they had on the builders. Instead, a configBuilder() method has been added to the handler classes that makes it clear tht they modify the GsonBuilder. This also has the advantage that classes that want a Gson object configured per a given handler need only call that handler's configBuilder() method; previously, they had to constructor the handler and then retrieve its gson object. Also updated a few tests to specify the HTTP "Accept" header to ensure that return results are in yaml format. Change-Id: I2ef98198041ff9f73913d01ee6ee14ecf20ba617 Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-13Extract YamlJsonTranslator from StandardYamlCoderJim Hahn8-34/+263
Refactored StandardYamlCoder, extracting a new class, YamlJsonTranslator, from it. This facilitates performing yaml translation when not using a standard "gson" coder. Added YamlJacksonHandler which supports YAML translation layered on top of a JacksonHandler instead of a GsonMessageBodyHandler. Also added junit tests to complete coverage of StandardCoder. Also added public APPLICATION_YAML to YamlMessageBodyHandler. Change-Id: Ia470fa194661fbf1aebeaf0f18b57f2a984cb64b Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-13Changes to accomodate to version of jettyJim Hahn1-6/+7
With a newer version of jetty being used, a couple of methods have been deprecated. Modified the code to use the facilities appropriate to the new jetty version. Change-Id: Idcaef11836841480c24b1721c06ed642d3d4394a Issue-ID: POLICY-2100 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-12Report bad-request for invalid YAMLJim Hahn8-61/+232
Added classes and modified code to report bad-request when a servlet attempts to read invalid YAML. Change-Id: Iacddee92a448fb69d5c778a3c3f3f2b5528983f7 Issue-ID: POLICY-2085 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-11Create StandardYamlCoderJim Hahn7-20/+522
Created StandardYamlCoder which is like a StandardCoder, except that the original converts to/from JSON, while the new class converts to/from YAML. Also added YamlMessageBodyHandler and incorporated it into the http server so that it supports a media type of */yaml. Change-Id: Ibd83a9f6d355a330f63e435f2bb41affcf1947c2 Issue-ID: POLICY-2065 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-08-23Rest servers should return 400 for bad syntax JSONJim Hahn4-2/+207
Modified common RestServer to inject an exception handler into the list of providers so that it returns 400 instead of 500 for JSON parsing errors. Change-Id: I7c77625e3531e26413d72cc386296a709946cda2 Issue-ID: POLICY-1725 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-08-14Add ApiUtils to facilitate looping over featuresJim Hahn2-24/+12
A number of places in the code (common & drools-pdp) loop over features, giving each provider a chance to act on something. Created a common method in a new ApiUtils class to faciliate it. Renamed to FeatureApiUtils per review comment. Change-Id: I0c2cf0f33854cb5b6921b394f64de498a6234909 Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-31Remove ParameterUtilsJim Hahn4-243/+3
Removed ParameterUtils. Also made RestServer.getServerProperties() protected so it can be overridden. Also fixed issue in TopicParameterGroupTest to prevent it from validating static fields. Change-Id: Icb4580f5802b9edca489a38896d61ad24aece449 Issue-ID: POLICY-1953 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-30Fix managed noop topic sourceJim Hahn4-15/+24
NOOP topic sources configured via TopicParameterGroup are left unmanaged. Removed a new override method, as it did not pass the "managed" flag down, while the method that already existed in the superclass already works correctly. Also restored "null" lists to TopicParameterGroup so-as not to break the behavior of its validate() method. Change-Id: Id392a3263c3bd1c8f278461715b441719817c47c Issue-ID: POLICY-1953 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-30Merge "Passing the updated topic parameters to policy-endpoints"Jorge Hernandez5-32/+127
2019-07-30Passing the updated topic parameters to policy-endpointsa.sreekumar5-32/+127
Changes to pass the updated parameters from BusTopicParams to PolicyEndpoints. Change-Id: I49d3b9d30a2a4c6b2337d0ab76a61583eb9ef04a Issue-ID: POLICY-1744 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
2019-07-29Add addTopic(List<TopicParams>)Jim Hahn14-45/+370
New services are typically configured using TopicParameters. These are converted into Properties before being passed to TopicEndpoint.addTopic(), which then converts them into BusTopicParams before configuring a given topic. Added TopicEndpoint.addTopic(List<TopicParams>), which makes it possible to configure the topics without going into the intermediate Properties. Furthermore, because TopicParams is a subclass of BusTopicParams, no conversion is needed for that either, so the TopicParams can be passed directly into the configuration classes. Incorporated changes from review. Change-Id: Id87e2c6812e36ae1a3ac680e6b35208667971782 Issue-ID: POLICY-1953 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-27Default TopicParams.isManaged to trueJim Hahn2-2/+15
Modified TopicParams to set "managed" to true by default. Change-Id: Ia21caba2b882199f1a63d40b0fed1167ccb93142 Issue-ID: POLICY-1744 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-25Changes to add missing topic parametersa.sreekumar7-107/+162
Changes to support parameters which would be critical to run in a secure environment. Change-Id: Ia7df174261041b35e57b9f1f2be7552e5dcd2cec Issue-ID: POLICY-1744 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
2019-07-17Copy PapRestServer to policy/commonJim Hahn3-0/+369
Copied and renamed the class to RestServer. Also modified it to derive from ServiceManagerContainer. Added getName() method to HttpServletServer, which facilitated the refactoring. Renamed "controllers" to "providers". Change-Id: I905166e41063e3fe84e356fd6c4a91ca9d4cb8a6 Issue-ID: POLICY-1652 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-08Merge "Fix sonar issues in policy/endpoints"Jim Hahn53-430/+794
2019-07-05Fix sonar issues in policy/endpointsJim Hahn53-430/+794
Sonar fixes, other than code coverage. These changes are disruptive and will likely cause breakage in a number of policy repos. Renamed constants. Moved constants/factories from interfaces to classes. Change-Id: I182d50320aa6b53e383081af806c60dd2f806cbe Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-05Fix sonar issue in common/utilsJim Hahn1-1/+2
Renamed a constant. Change-Id: I5e1f2fb6de8445a8f667ea48a595773173c6beae Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-03Remove ToStringTester from utilsramverma1-1/+1
Finally, removing the ToStringTester from utils module. All repos are moved to use it from utils-test. Change-Id: I79c7db0b39b5d300a850279c46858c719aa1faab Issue-ID: POLICY-1746 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-06-27Making the topic property utility method more generic - addressing Jorge's ↵a.sreekumar3-9/+40
review comment Making the method to update topic properties object more generic so that it can be used by other components such as drools if needed. Change-Id: I29c0f8fde5f4e1dd464072a9b06f2d93cc15b137 Issue-ID: POLICY-1744 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
2019-06-26Merge "Adding Topic and REST parameters to policy-endpoints"Pamela Dragosh12-0/+628
2019-06-26Fix some sonar issues in policy-endpointsJim Hahn34-886/+909
Refactored various classes to reduce cyclomatic complexity. Introduced some endpoint utility classes to facilitate extraction and conversion of property values, and populating of common "builder" values. Change-Id: Ie1c91cd94cb54700dc9127f72780b4d94b82ec39 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-26Adding Topic and REST parameters to policy-endpointsa.sreekumar12-0/+628
1) Adding Topic parameters and REST parameters into policy-endpoints module as these are used by other modules such as PAP, APEX and XACML PDPs. 2) ParameterUtils class is also added which can contain related utility methods Change-Id: I5421fbf2234259305e3626ec0859aee0f36ed9b1 Issue-ID: POLICY-1744 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
2019-06-14Change getCanonicalName() to getName() in commonJim Hahn3-28/+28
Per javadocs, getName() should generally be used instead of Class.getCanonicalName(). This change only applies to classes; it does not apply to File objects. Change-Id: Iea0995d1167f4837607f194d35f0193eeedeacd7 Issue-ID: POLICY-1646 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-13More sonar fixes in policy/commonJim Hahn1-61/+33
Note: this does not increase code coverage, but should fix other code issues. Resolved cyclomatic complexity issue in ParameterValidationResult. Refactored duplicate code in GroupValidationResult. Removed IOException from NetworkUtil "throws". Replaced null/empty string tests with StringUtils.isBlank(). Added @FunctionalInterface where needed. Replaced anonymous classes with lambda expressions. Replaced duplicate strings with a constant. Added private constructors for utility classes. Removed sleep() from tests. Removed unused parameter from method call. Made some protected methods private. Compute integrity monitor's state-transition table once. Use for-loop instead of iterator. Moved constructors. Fixed some checkstyle issues (tabs => spaces, trailing spaces). Change-Id: I9a962ca45c4ff3f212c6014da799d06f07b232ef Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-12Apply simple sonar fixesJim Hahn18-230/+263
Note: A number of these were identified, by SonarLint, in the Test classes, which are not typically scanned by Sonar. Removed unnecessary imports. Removed unneeded "throws Xxx". Replaced lambda with method references. Replaced duplicate strings with constants. Replaced try-fail-catch with assert-j methods to eliminate sonar complaints about duplicate failure messages. Added missing @Override annotations. Use map.computeIfAbsent() where appropriate. Also fixed some minor checkstyle issues. Removed unneeded "volatile" declarations. Replaced some if-else constructs with "?:" construct, per sonar. Replaced Object.wait() with CountDownLatch.await(); according to sonar (and javadocs), Object.wait() can return due to "spurious wakeups". Fixed issue whereby CryptoUtilsTest wouldn't run in my Eclipse. Change-Id: Ib6b71ed65662cfd6209400dac57ed69279bf29ec Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-12Set jetty.dump to tracePamela Dragosh1-11/+11
Makes Junit debugging more simple. Issue-ID: POLICY-1641 Change-Id: I5835f608e468e90e11d923973d726b0313e91189 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-04-09Add more logging to message dispatcherJim Hahn1-3/+10
Change-Id: I889cb9397b4b834ab273ec8f8ddc1af2b3c3c05e Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-19Add method to support configure all topics at onceJorge Hernandez3-0/+27
regardless of type (source or sink) Change-Id: Idaebae611746e364364d35375519173a7461ae61 Issue-ID: POLICY-1608 Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
2019-03-19Merge "TopicSinkClient support for unmanaged topics"Pamela Dragosh2-34/+43
2019-03-18TopicSinkClient support for unmanaged topicsJorge Hernandez2-34/+43
Change-Id: I6b92dcc0f225aa712b34adb9a1f9ab47df412c81 Issue-ID: POLICY-1608 Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
2019-03-13Add Network Logging FeatureDaniel Cruz10-28/+513
This is part 1 of introducing the mdc filter feature. Network logging has to have interception points in order to pre/post process messages coming in from a network endpoint. The OrderedService interface and OrderedServiceImpl of the drools-pdp project have now been migrated to common but is also left in drools-pdp to mitigate disruption to existing features. However for features that need to use common's OrderedServiceImpl and drools-pdp version of OrderedServiceImpl there will be a conflict with getSequenceNumber(). So a migration of the other features is suggested. Network logging is moved to its own util class so that feature hooks can be invoked any time an event is being logged by a network logger. This util class will also be accessible to drools-applications in the case where drools-applications would like to invoke network logging features for REST events. Change-Id: I83d7c46e5abb351486f841c3be4d9009f7992476 Issue-ID: POLICY-1499 Signed-off-by: Daniel Cruz <dc443y@att.com>
2019-03-11Add ServiceManager classJim Hahn1-3/+0
Added ServiceManager class to start a list of services, in order, and stop them in reverse order. Also addressed minor checkstyle issue in TopicSinkClient. Enabled logging from tests. Updated some comments. Updated license date. Added state checks and support for multi-threading. Change-Id: Ie7f053d9884766fe199895691a57eb5a51b1d155 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-08Merge "Add code to allocate server ports"Jorge Hernandez1-30/+9
2019-03-08Add code to allocate server portsJim Hahn1-30/+9
Added code to find available server ports. Also added a trust manager that always trusts certificates. Made trust manager private so we can allocate new ones in the future, if we decide it isn't safe to re-use the same one over and over. Modified test code to allocate a port rather than assuming 8180 was not in use. Also modified retry parameters in other tests. Added another allocPort() that takes an IP address and then modified the other two to use that so the code does not have to be duplicated, while providing more functionality. Change-Id: I08cf18d923af46b1310d8496498bb1d4a0690b6e Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-06Adding client class for sending message to topicramverma4-0/+340
1) Adding TopicSinkClient class for sending messages to topic. The same class will be used for PAP->PDP & PDP->PAP communication. 2) Once this review is through, will raise another one to remove PdpClient from policy/pap. Change-Id: I7253683d9e88885cfbe2ac9041d01da239b9321b Issue-ID: POLICY-1443 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-03-04Fix new sonar issue in listenerJim Hahn1-0/+1
Change-Id: I0d718ace3099bfa33508b11beece58447c0943ff Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-01Add various listener classesJim Hahn9-0/+1256
Added various listener classes to support dispatch by message type and request id. The listeners are intended to form a pipeline: TopicSource => MessageTypeDispatcher => RequestIdDispatcher => TypedMessageListener Removed "PAP" from license. Changed "handler" to "listener" in most places. Simplified a test case. Verified that no error message logged on success cases. Removed println from test. Updated some comments. Change-Id: Ife265d14a6c5c8531601d9ce1343b88c1f8986a8 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-21Support for lab contextual topic names.Jorge Hernandez31-53/+209
This work allows a drools application, with its drl template to refer to the topic name by its invariable canonical name, ie. POLICY-CL-MGT. Since the drl is a design time artifact, it is desired to know topics by its canonical non-changeable name. The actual per lab environment topic name may change on a per deployment basis, for example POLICY-CL-MGT-WINDRIVER or POLICY-CL-MGT-TLAB. The template can still use POLICY-CL-MGT without modification but the actual installation configuration would use the "effectiveTopic" property to point to the right topic on a per lab basis. This also helps with installation (long story) since the canonical topics will be known ahead of time. Change-Id: I8322bf7e427569c37a76eea5ce6d5b9547cb2ff3 Issue-ID: POLICY-1534 Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
2019-02-15Merge "Remove erroneous comments"Liam Fallon2-8/+0
2019-02-15Remove unneeded jackson referencesJim Hahn1-1/+0
Removed some jackson references that are no longer needed. Others remain; those must remain in place until they are no longer needed by other policy repos. Change-Id: Ica6624baf17be118714bb566c8db3ffce2c3587c Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-15Remove erroneous commentsJim Hahn2-8/+0
Some comments still said that including the maven artifact, jersey-media-json-jackson, could override gson behavior, but that is no longer true. The comments have been removed. Change-Id: I9b6477b76f835b96c52ccb9777b80791fc6b1d77 Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-13Add gson handler and testsJim Hahn25-16/+292
Added JacksonHandler which provides jackson behavior in gson. Also added classes to facilitate testing of gson serializations. Added compareGson(xxx, Class). Removed trailing spaces from some files. Updated license dates. Replaced incorrect constant with ${xxx} in json test file. Fixed typo in test method name. Change-Id: If05b654d76a4ffc88646f03334be82b32506f28f Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-11Merge "Add superclasses for gson-jackson migration"Liam Fallon3-285/+1
2019-02-08Add superclasses for gson-jackson migrationJim Hahn3-285/+1
Added common classes needed by other gson-jackson code. Modified some logic to make it more maintainable or perform better. Updated comments and spacing. Fix another comment. Moved gson classes from utils to a separate gson project. Added GsonXxx annotations to mirror jackson annotations. Removed unneeded dependencies from gson pom. Removed old GsonMessage class from policy-endpoints. Removed trailing spaces. Updated licenses. Removed more trailing spaces. Removed unneeded checkstyle suppression file from utils. Change-Id: I1a285500faeb0a0b6a1467d09b92ecd3cded713e Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-08Return true only if thread has been really startedKrzysztof Opasiak1-1/+2
Accortding to doc start() should return true if start operation was successful. Unfortunately value of this.alive may change between end of synchronized block and return for example when other thread executes stop() in parallel. Change-Id: I4103f0f4c65620c47b4acf2d276f104937b91187 Issue-ID: POLICY-1387 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2019-01-31Fix potential race conditionKrzysztof Opasiak1-1/+1
init() is currently called outside of synhronized block. This is may lead to race condition as init() creates new bus consumer (this.consumer) which is the copied and nulled in stop() synchronized block. This may lead to race condition if: Thread #1 Thread #2 this.alive = true; this.alive = false consumerCopy = this.consumer; this.consumer = new Consumer(); // false if(consumerCopy != null) { consumerCopy.close(); } else { log.warn(); } As a result, new BusConsumers are being created but they are never close(). Issue-ID: POLICY-1387 Change-Id: I2eadb12ef1c4b07b9e47dc6ebc096acc713299a0 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2019-01-31Exteract common paramsKrzysztof Opasiak1-36/+21
Most of parameters used to initialize consumers are repeated in every branch. Instead of having 3 copies of the same code let's extract all common values and then add only those which are specific to given consumer type. Change-Id: I5884f6dd77a7e2f1a7f7614c909c1cad4826d4f1 Issue-ID: POLICY-1387 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>