be.personify.iam.model.authentication.AccessToken Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of personify-model Show documentation
Show all versions of personify-model Show documentation
a possible model for personify
package be.personify.iam.model.authentication;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import be.personify.iam.model.util.Persisted;
import be.personify.util.generator.MetaInfo;
@Entity
@MetaInfo( name="AccessToken", group="authentication", frontendGroup = "Authentication",
description="A access token that is linked to a session",
iconClass="unlock-alt", number=3, addable = false, editable = false,
showInMenu = true,
showEditButtonOnSearchResult = false,
showDeleteButtonOnSearchResult = false
)
@Table(name="access_token",
indexes = {
//@Index(name = "idx_token", columnList = "token")
}
)
public class AccessToken extends Persisted implements Serializable {
private static final long serialVersionUID = 760905762851636074L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonIgnore(false)
@MetaInfo(name="id", description="The id of the object", showInSearchResultGrid = false)
private long id;
@MetaInfo(name="token", description="The token")
@Lob
@Column(length = 20971520)
private String token;
@MetaInfo(name="validFrom", description="The date from which the token is valid")
private Date validFrom;
@MetaInfo(name="validTo", description="The date untill the token is valid")
private Date validTo;
@MetaInfo(name="session", description="The session linked to the access token : see session_", searchable = false, showInSearchResultGrid = false)
@OneToOne(fetch = FetchType.LAZY, cascade=CascadeType.ALL)
@JoinColumn(name = "session_id")
private Session session;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Date getValidFrom() {
return validFrom;
}
public void setValidFrom(Date validFrom) {
this.validFrom = validFrom;
}
public Date getValidTo() {
return validTo;
}
public void setValidTo(Date validTo) {
this.validTo = validTo;
}
public Session getSession() {
return session;
}
public void setSession(Session session) {
this.session = session;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + ((session == null) ? 0 : session.hashCode());
result = prime * result + ((token == null) ? 0 : token.hashCode());
result = prime * result + ((validFrom == null) ? 0 : validFrom.hashCode());
result = prime * result + ((validTo == null) ? 0 : validTo.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
AccessToken other = (AccessToken) obj;
if (id != other.id)
return false;
if (session == null) {
if (other.session != null)
return false;
} else if (!session.equals(other.session))
return false;
if (token == null) {
if (other.token != null)
return false;
} else if (!token.equals(other.token))
return false;
if (validFrom == null) {
if (other.validFrom != null)
return false;
} else if (!validFrom.equals(other.validFrom))
return false;
if (validTo == null) {
if (other.validTo != null)
return false;
} else if (!validTo.equals(other.validTo))
return false;
return true;
}
}