package at.gv.egovernment.moa.id.commons.db.dao.session; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.OneToMany; import javax.persistence.PrePersist; import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import org.hibernate.annotations.DynamicUpdate; @Entity @DynamicUpdate(value=true) @Table(name = "authenticatedsessionstore") @NamedQueries({ @NamedQuery(name="getSessionWithID", query = "select authenticatedsessionstore from AuthenticatedSessionStore authenticatedsessionstore where authenticatedsessionstore.sessionid = :sessionid"), @NamedQuery(name="getSessionWithSSOID", query = "select authenticatedsessionstore from AuthenticatedSessionStore authenticatedsessionstore where authenticatedsessionstore.SSOsessionid = :sessionid"), @NamedQuery(name="getSessionWithPendingRequestID", query = "select authenticatedsessionstore from AuthenticatedSessionStore authenticatedsessionstore where authenticatedsessionstore.pendingRequestID = :sessionid"), @NamedQuery(name="getMOAISessionsWithTimeOut", query = "select authenticatedsessionstore from AuthenticatedSessionStore authenticatedsessionstore where authenticatedsessionstore.created < :timeoutcreate or authenticatedsessionstore.updated < :timeoutupdate") }) public class AuthenticatedSessionStore implements Serializable{ private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", unique=true, nullable=false) private long id; @Column(name = "sessionid", unique=true, nullable=false) private String sessionid; @Column(name = "SSOsessionid") private String SSOsessionid; @Column(name = "session", nullable=false) @Lob private byte [] session; @Column(name = "isAuthenticated", nullable=false) private boolean isAuthenticated = false; @Column(name = "isSSOSession", nullable=false) private boolean isSSOSession = false; @Column(name = "pendingRequestID", nullable=false) private String pendingRequestID = ""; @Column(name = "created", updatable=false, nullable=false) @Temporal(TemporalType.TIMESTAMP) private Date created; @Column(name = "updated") @Temporal(TemporalType.TIMESTAMP) private Date updated; @OneToMany(mappedBy="moasession", cascade=CascadeType.ALL) private List activeOAsessions = null; @OneToMany(mappedBy="moasession", cascade=CascadeType.ALL) private List oldssosessionids = null; @PrePersist protected void created() { this.updated = this.created = new Date(); } @PreUpdate protected void lastUpdate() { this.updated = new Date(); } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getSessionid() { return sessionid; } public void setSessionid(String sessionid) { this.sessionid = sessionid; } public String getSSOsessionid() { return SSOsessionid; } public void setSSOsessionid(String sSOsessionid) { SSOsessionid = sSOsessionid; } public byte[] getSession() { return session; } public void setSession(byte[] session) { this.session = session; } public boolean isAuthenticated() { return isAuthenticated; } public void setAuthenticated(boolean isAuthenticated) { this.isAuthenticated = isAuthenticated; } public boolean isSSOSession() { return isSSOSession; } public void setSSOSession(boolean isSSOSession) { this.isSSOSession = isSSOSession; } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; } public Date getUpdated() { return updated; } public void setUpdated(Date updated) { this.updated = updated; } public List getActiveOAsessions() { return activeOAsessions; } public void setActiveOAsessions(List activeOAsessions) { if (activeOAsessions == null) { this.activeOAsessions = new ArrayList(); } this.activeOAsessions = activeOAsessions; } public List getOldssosessionids() { return oldssosessionids; } public void setOldssosessionids(List oldssosessionids) { this.oldssosessionids = oldssosessionids; } /** * @return the pendingRequestID */ public String getPendingRequestID() { return pendingRequestID; } /** * @param pendingRequestID the pendingRequestID to set */ public void setPendingRequestID(String pendingRequestID) { this.pendingRequestID = pendingRequestID; } }