1 package org.openecomp.sdc.securityutil;
6 public class AuthenticationCookie {
9 private Set<String> roles;
10 private long maxSessionTime;
11 private long currentSessionTime;
13 public AuthenticationCookie(){ }
15 public AuthenticationCookie(AuthenticationCookie authenticationCookie){
16 this.userID = authenticationCookie.userID;
17 this.roles = authenticationCookie.roles;
18 this.maxSessionTime = authenticationCookie.maxSessionTime;
19 this.currentSessionTime = authenticationCookie.currentSessionTime;
23 * Create new cookie with max_session_time and current_session_time started with same value
26 public AuthenticationCookie(String userId) {
28 long currentTimeMilliSec = System.currentTimeMillis();
29 this.maxSessionTime = currentTimeMilliSec;
30 this.currentSessionTime = currentTimeMilliSec;
33 public String getUserID() {
37 public void setUserID(String userID) {
41 public Set getRoles() {
45 public void setRoles(Set<String> roles) {
49 public long getMaxSessionTime() {
50 return maxSessionTime;
53 public void setMaxSessionTime(long maxSessionTime) {
54 this.maxSessionTime = maxSessionTime;
58 public long getCurrentSessionTime() {
59 return currentSessionTime;
62 public void setCurrentSessionTime(long currentSessionTime) {
63 this.currentSessionTime = currentSessionTime;
67 public boolean equals(Object o) {
68 if (this == o) return true;
69 if (!(o instanceof AuthenticationCookie)) return false;
71 AuthenticationCookie that = (AuthenticationCookie) o;
73 if (getMaxSessionTime() != that.getMaxSessionTime()) return false;
74 if (getCurrentSessionTime() != that.getCurrentSessionTime()) return false;
75 if (getUserID() != null ? !getUserID().equals(that.getUserID()) : that.getUserID() != null) return false;
76 return getRoles() != null ? getRoles().containsAll(that.getRoles()) : that.getRoles() == null;
80 public int hashCode() {
81 int result = getUserID() != null ? getUserID().hashCode() : 0;
82 result = 31 * result + (getRoles() != null ? getRoles().hashCode() : 0);
83 result = 31 * result + (int) (getMaxSessionTime() ^ (getMaxSessionTime() >>> 32));
84 result = 31 * result + (int) (getCurrentSessionTime() ^ (getCurrentSessionTime() >>> 32));
89 public String toString() {
90 return "AuthenticationCookie{" +
91 "userID='" + userID + '\'' +
93 ", maxSessionTime=" + maxSessionTime +
94 ", currentSessionTime=" + currentSessionTime +