Java tutorial
/* * Copyright 2014 nateriver. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package be.bittich.quote.vo; import java.util.Objects; import org.codehaus.jackson.annotate.JsonIgnore; import org.springframework.security.core.token.Token; /** * * @author nateriver */ public class SecurityToken implements Token { private static final long serialVersionUID = -3965351101468053593L; private String key; private long keyCreationTime; private String extendedInformation; private String ipAddress; public SecurityToken() { } public SecurityToken(String key, long keyCreationTime, String extendedInformation, String ipAddress) { this.key = key; this.keyCreationTime = keyCreationTime; this.extendedInformation = extendedInformation; this.ipAddress = ipAddress; } @Override public boolean equals(Object obj) { if (Objects.isNull(obj) || !(obj instanceof SecurityToken)) { return false; } SecurityToken tk = (SecurityToken) obj; return (Objects.equals(this.getKey(), tk.getKey()) && Objects.equals(this.getExtendedInformation(), tk.getExtendedInformation()) && Objects.equals(this.getKeyCreationTime(), this.getKeyCreationTime())); } @Override public int hashCode() { return Objects.hash(this.getExtendedInformation(), this.getKey(), this.getKeyCreationTime()); } public void setKeyCreationTime(long keyCreationTime) { this.keyCreationTime = keyCreationTime; } public void setExtendedInformation(String extendedInformation) { this.extendedInformation = extendedInformation; } public void setKey(String key) { this.key = key; } @Override public String getExtendedInformation() { return extendedInformation; } @Override public String getKey() { return key; } @Override public long getKeyCreationTime() { return keyCreationTime; } @JsonIgnore public String getIpAddress() { return ipAddress; } public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; } }