summaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
diff options
context:
space:
mode:
authorRodriguez, Cuauhtemoctzin (cr056n) <cr056n@us.att.com>2017-08-04 16:02:20 -0500
committerTemoc Rodriguez <cr056n@att.com>2017-08-14 18:26:18 +0000
commit59e3ddb0f0698965962a7d5879a6e39a80744648 (patch)
treea5315a4d0bb39574ecea01d376019073005b0809 /ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
parent827a2016429bc377e28d2a414b6bcbdf8b6dc924 (diff)
Add fix for SQL injection.
Add fix for SQL injection by passing parameters into getDataByQuery method and binding parameters. Add junit test file. Override equals and hashcode methods for more thorough testing on ActionBodyEntity, ConfigurationDataEntity, PolicyEntity, PolicyVersion, WatchPolicyNotificationTable classes. Issue-Id: [POLICY-158] Change-Id: Icebe1ca1ff01c8ea7435729967f4d349a1026054 Signed-off-by: ITSERVICES\cr056n <cr056n@att.com>
Diffstat (limited to 'ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
index d098ee5a2..bc6ad99fd 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
@@ -24,6 +24,7 @@ import java.io.Serializable;
//import java.sql.Clob;
import java.sql.Timestamp;
import java.util.Date;
+import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -178,6 +179,38 @@ public class PolicyVersion implements Serializable {
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, policyName, activeVersion, higherVersion, createdDate,
+ createdBy, modifiedDate, modifiedBy);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(obj == null){
+ return false;
+ }
+ if(obj == this){
+ return true;
+ }
+ if(!(obj instanceof PolicyVersion)){
+ return false;
+ }
+
+ PolicyVersion p = (PolicyVersion) obj;
+
+ return (
+ id == p.id &&
+ policyName.equals(p.policyName) &&
+ activeVersion == p.activeVersion &&
+ higherVersion == p.higherVersion &&
+ createdDate.equals(p.createdDate) &&
+ createdBy.equals(p.createdBy) &&
+ modifiedDate.equals(p.modifiedDate) &&
+ modifiedBy.equals(p.modifiedBy)
+ );
+ }
}