summaryrefslogtreecommitdiffstats
path: root/security-util-lib/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'security-util-lib/src/main/java/org/onap')
-rw-r--r--security-util-lib/src/main/java/org/onap/sdc/security/AuthenticationCookie.java34
-rw-r--r--security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/HttpResponse.java40
-rw-r--r--security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/LoggerFactory.java18
3 files changed, 21 insertions, 71 deletions
diff --git a/security-util-lib/src/main/java/org/onap/sdc/security/AuthenticationCookie.java b/security-util-lib/src/main/java/org/onap/sdc/security/AuthenticationCookie.java
index 9440eea..b8f3afa 100644
--- a/security-util-lib/src/main/java/org/onap/sdc/security/AuthenticationCookie.java
+++ b/security-util-lib/src/main/java/org/onap/sdc/security/AuthenticationCookie.java
@@ -21,9 +21,13 @@
package org.onap.sdc.security;
import java.util.Set;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
+import lombok.ToString;
+@EqualsAndHashCode
+@ToString
public class AuthenticationCookie {
@Getter @Setter
@@ -72,35 +76,5 @@ public class AuthenticationCookie {
this.lastName = lastName;
}
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof AuthenticationCookie)) return false;
- AuthenticationCookie that = (AuthenticationCookie) o;
-
- if (getMaxSessionTime() != that.getMaxSessionTime()) return false;
- if (getCurrentSessionTime() != that.getCurrentSessionTime()) return false;
- if (getUserID() != null ? !getUserID().equals(that.getUserID()) : that.getUserID() != null) return false;
- return getRoles() != null ? getRoles().containsAll(that.getRoles()) : that.getRoles() == null;
- }
-
- @Override
- public int hashCode() {
- int result = getUserID() != null ? getUserID().hashCode() : 0;
- result = 31 * result + (getRoles() != null ? getRoles().hashCode() : 0);
- result = 31 * result + (int) (getMaxSessionTime() ^ (getMaxSessionTime() >>> 32));
- result = 31 * result + (int) (getCurrentSessionTime() ^ (getCurrentSessionTime() >>> 32));
- return result;
- }
-
- @Override
- public String toString() {
- return "AuthenticationCookie{" +
- "userID='" + userID + '\'' +
- ", roles=" + roles +
- ", maxSessionTime=" + maxSessionTime +
- ", currentSessionTime=" + currentSessionTime +
- '}';
- }
}
diff --git a/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/HttpResponse.java b/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/HttpResponse.java
index 57aaf3c..61f440c 100644
--- a/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/HttpResponse.java
+++ b/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/HttpResponse.java
@@ -20,11 +20,19 @@
package org.onap.sdc.security.logging.elements;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
+@ToString
+@AllArgsConstructor
public class HttpResponse<T> {
+ @Getter
private final T response;
+ @Getter
private final int statusCode;
+ @Getter
private final String description;
public HttpResponse(T response, int statusCode) {
@@ -32,37 +40,5 @@ public class HttpResponse<T> {
this.statusCode = statusCode;
this.description = StringUtils.EMPTY;
}
-
- public HttpResponse(T response, int statusCode, String description) {
- this.response = response;
- this.statusCode = statusCode;
- this.description = description;
- }
-
- public T getResponse() {
- return response;
- }
- public int getStatusCode() {
- return statusCode;
- }
-
- public String getDescription() {
- return description;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("HttpResponse [response=");
- builder.append(response);
- builder.append(", statusCode=");
- builder.append(statusCode);
- builder.append(", description=");
- builder.append(description);
- builder.append("]");
- return builder.toString();
- }
-
-
}
diff --git a/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/LoggerFactory.java b/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/LoggerFactory.java
index fe67de1..67645d7 100644
--- a/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/LoggerFactory.java
+++ b/security-util-lib/src/main/java/org/onap/sdc/security/logging/elements/LoggerFactory.java
@@ -30,19 +30,19 @@ public class LoggerFactory {
@SuppressWarnings("unchecked")
public static <T, V> V getLogger(Class<T> type, Logger logger) {
- if (type.getName().equals(LoggerAudit.class.getName())) {
+ if (type.isAssignableFrom(LoggerAudit.class) ) {
return (V) new LoggerAudit(new LogFieldsMdcHandler(), logger);
}
- if (type.getName().equals(LoggerDebug.class.getName())) {
+ if (type.isAssignableFrom(LoggerDebug.class)) {
return (V) new LoggerDebug(new LogFieldsMdcHandler(), logger);
}
- if (type.getName().equals(LoggerMetric.class.getName())) {
+ if (type.isAssignableFrom(LoggerMetric.class)) {
return (V) new LoggerMetric(new LogFieldsMdcHandler(), logger);
}
- if (type.getName().equals(LoggerError.class.getName())) {
+ if (type.isAssignableFrom(LoggerError.class)) {
return (V) new LoggerError(new LogFieldsMdcHandler(), logger);
}
@@ -52,23 +52,23 @@ public class LoggerFactory {
@SuppressWarnings("unchecked")
public static <T, V> V getMdcLogger(Class<T> type, Logger logger) {
- if (type.getName().equals(LoggerAudit.class.getName())) {
+ if (type.isAssignableFrom(LoggerAudit.class)) {
return (V) new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger);
}
- if (type.getName().equals(LoggerDebug.class.getName())) {
+ if (type.isAssignableFrom(LoggerDebug.class)) {
return (V) new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger);
}
- if (type.getName().equals(LoggerMetric.class.getName())) {
+ if (type.isAssignableFrom(LoggerMetric.class)) {
return (V) new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger);
}
- if (type.getName().equals(LoggerError.class.getName())) {
+ if (type.isAssignableFrom(LoggerError.class)) {
return (V) new LoggerError(LogFieldsMdcHandler.getInstance(), logger);
}
- if (type.getName().equals(LoggerSupportability.class.getName())) {
+ if (type.isAssignableFrom(LoggerSupportability.class)) {
return (V) new LoggerSupportability(LogFieldsMdcHandler.getInstance(), logger);
}