001/* 002 * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nelson Silva <[email protected]> 018 */ 019package org.nuxeo.ecm.tokenauth.io; 020 021import java.util.Calendar; 022 023/** 024 * @since 8.3 025 */ 026public class AuthenticationToken { 027 028 protected String token; 029 030 protected String userName; 031 032 protected String applicationName; 033 034 protected String deviceId; 035 036 protected String deviceDescription; 037 038 protected String permission; 039 040 private Calendar creationDate; 041 042 public AuthenticationToken(String token, String userName, String applicationName, String deviceId, 043 String deviceDescription, String permission) { 044 this.token = token; 045 this.userName = userName; 046 this.applicationName = applicationName; 047 this.deviceId = deviceId; 048 this.deviceDescription = deviceDescription; 049 this.permission = permission; 050 } 051 052 public String getToken() { 053 return token; 054 } 055 056 public String getUserName() { 057 return userName; 058 } 059 060 public String getApplicationName() { 061 return applicationName; 062 } 063 064 public String getDeviceId() { 065 return deviceId; 066 } 067 068 public String getDeviceDescription() { 069 return deviceDescription; 070 } 071 072 public String getPermission() { 073 return permission; 074 } 075 076 public Calendar getCreationDate() { 077 return creationDate; 078 } 079 080 public void setCreationDate(Calendar creationDate) { 081 this.creationDate = creationDate; 082 } 083 084 @Override 085 public boolean equals(Object o) { 086 if (this == o) 087 return true; 088 if (o == null || getClass() != o.getClass()) 089 return false; 090 091 AuthenticationToken that = (AuthenticationToken) o; 092 093 if (!getToken().equals(that.getToken())) 094 return false; 095 if (!getUserName().equals(that.getUserName())) 096 return false; 097 if (!getApplicationName().equals(that.getApplicationName())) 098 return false; 099 if (!getDeviceId().equals(that.getDeviceId())) 100 return false; 101 if (getDeviceDescription() != null ? 102 !getDeviceDescription().equals(that.getDeviceDescription()) : 103 that.getDeviceDescription() != null) 104 return false; 105 return getPermission().equals(that.getPermission()); 106 } 107 108 @Override 109 public int hashCode() { 110 int result = getToken().hashCode(); 111 result = 31 * result + getUserName().hashCode(); 112 result = 31 * result + getApplicationName().hashCode(); 113 result = 31 * result + getDeviceId().hashCode(); 114 result = 31 * result + getPermission().hashCode(); 115 return result; 116 } 117 118 @Override 119 public String toString() { 120 return "AuthenticationToken{" + 121 "token='" + token + '\'' + 122 ", userName='" + userName + '\'' + 123 ", applicationName='" + applicationName + '\'' + 124 ", deviceId='" + deviceId + '\'' + 125 ", deviceDescription='" + deviceDescription + '\'' + 126 ", permission='" + permission + '\'' + 127 ", creationDate=" + creationDate + 128 '}'; 129 } 130}