From 93693295a56548bd40af031ab0df364f0a8dd5dc Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 4 Jul 2013 10:19:36 +0200 Subject: =?UTF-8?q?Datenbankteile=20f=C3=BCr=20SSO:=20=20-alte=20SSO=20Ses?= =?UTF-8?q?sion=20IDs=20=20-angemeldete=20OAs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moa/id/storage/AssertionStorage.java | 2 +- .../id/storage/AuthenticationSessionStoreage.java | 12 +- .../moa/id/commons/db/dao/AssertionStore.java | 77 ------------ .../id/commons/db/dao/session/AssertionStore.java | 77 ++++++++++++ .../db/dao/session/AuthenticatedSessionStore.java | 136 +++++++++++++++++++++ .../id/commons/db/dao/session/OASessionStore.java | 88 +++++++++++++ .../db/dao/session/OldSSOSessionIDStore.java | 73 +++++++++++ 7 files changed, 381 insertions(+), 84 deletions(-) delete mode 100644 id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/AssertionStore.java create mode 100644 id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java create mode 100644 id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AuthenticatedSessionStore.java create mode 100644 id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java create mode 100644 id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OldSSOSessionIDStore.java (limited to 'id') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java index adb0b15ab..b5de788af 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java @@ -12,7 +12,7 @@ import org.hibernate.Query; import org.hibernate.Session; import at.gv.egovernment.moa.id.commons.db.HibernateUtil; -import at.gv.egovernment.moa.id.commons.db.dao.AssertionStore; +import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.MiscUtil; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java index 5664b3b08..70156deb7 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java @@ -18,8 +18,8 @@ import at.gv.egovernment.moa.id.AuthenticationException; import at.gv.egovernment.moa.id.MOAIDException; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.commons.db.HibernateUtil; -import at.gv.egovernment.moa.id.commons.db.dao.AssertionStore; -import at.gv.egovernment.moa.id.commons.db.dao.AuthenticatedSessionStore; +import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore; +import at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.util.Random; import at.gv.egovernment.moa.logging.Logger; @@ -199,11 +199,11 @@ public class AuthenticationSessionStoreage { for(AuthenticatedSessionStore result : results) { try { HibernateUtil.delete(result); - Logger.info("Remove Assertion with Artifact=" + result.getSessionid() - + " after assertion timeout."); + Logger.info("Authenticated session with sessionID=" + result.getSessionid() + + " after session timeout."); } catch (HibernateException e){ - Logger.warn("Assertion with Artifact=" + result.getSessionid() + Logger.warn("Authenticated session with sessionID=" + result.getSessionid() + " not removed after timeout! (Error during Database communication)", e); } @@ -213,7 +213,7 @@ public class AuthenticationSessionStoreage { @SuppressWarnings("rawtypes") private static AuthenticatedSessionStore searchInDatabase(String sessionID) throws MOADatabaseException { - MiscUtil.assertNotNull(sessionID, "artifact"); + MiscUtil.assertNotNull(sessionID, "moasessionID"); Logger.trace("Get authenticated session with sessionID " + sessionID + " from database."); Session session = HibernateUtil.getCurrentSession(); diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/AssertionStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/AssertionStore.java deleted file mode 100644 index b7b8c24f6..000000000 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/AssertionStore.java +++ /dev/null @@ -1,77 +0,0 @@ -package at.gv.egovernment.moa.id.commons.db.dao; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.Table; - -import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.NamedQueries; -import org.hibernate.annotations.NamedQuery; - - -@Entity -@DynamicUpdate(value=true) -@Table(name = "assertionstore") -@NamedQueries({ - @NamedQuery(name="getAssertionWithArtifact", query = "select assertionstore from AssertionStore assertionstore where assertionstore.artifact = :artifact"), - @NamedQuery(name="getAssertionWithTimeOut", query = "select assertionstore from AssertionStore assertionstore where assertionstore.timestamp < :timeout") -}) - -public class AssertionStore implements Serializable{ - - private static final long serialVersionUID = 1L; - - @Id - @Column(name = "artifact", unique=true, nullable=false) - private String artifact; - - @Column(name = "type", nullable=false) - private String type; - - @Column(name = "assertion", nullable=false) - @Lob private byte [] assertion; - - @Column(name = "timestamp", nullable=false) - Date timestamp; - - - - public String getArtifact() { - return artifact; - } - - public void setArtifact(String artifact) { - this.artifact = artifact; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public byte[] getAssertion() { - return assertion; - } - - public void setAssertion(byte[] assertion) { - this.assertion = assertion; - } - - public Date getDatatime() { - return timestamp; - } - - public void setDatatime(Date datatime) { - this.timestamp = datatime; - } - - -} diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java new file mode 100644 index 000000000..a0898efc1 --- /dev/null +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java @@ -0,0 +1,77 @@ +package at.gv.egovernment.moa.id.commons.db.dao.session; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.Table; + +import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.NamedQueries; +import org.hibernate.annotations.NamedQuery; + + +@Entity +@DynamicUpdate(value=true) +@Table(name = "assertionstore") +@NamedQueries({ + @NamedQuery(name="getAssertionWithArtifact", query = "select assertionstore from AssertionStore assertionstore where assertionstore.artifact = :artifact"), + @NamedQuery(name="getAssertionWithTimeOut", query = "select assertionstore from AssertionStore assertionstore where assertionstore.timestamp < :timeout") +}) + +public class AssertionStore implements Serializable{ + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "artifact", unique=true, nullable=false) + private String artifact; + + @Column(name = "type", nullable=false) + private String type; + + @Column(name = "assertion", nullable=false) + @Lob private byte [] assertion; + + @Column(name = "timestamp", nullable=false) + Date timestamp; + + + + public String getArtifact() { + return artifact; + } + + public void setArtifact(String artifact) { + this.artifact = artifact; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public byte[] getAssertion() { + return assertion; + } + + public void setAssertion(byte[] assertion) { + this.assertion = assertion; + } + + public Date getDatatime() { + return timestamp; + } + + public void setDatatime(Date datatime) { + this.timestamp = datatime; + } + + +} diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AuthenticatedSessionStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AuthenticatedSessionStore.java new file mode 100644 index 000000000..01c18062c --- /dev/null +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AuthenticatedSessionStore.java @@ -0,0 +1,136 @@ +package at.gv.egovernment.moa.id.commons.db.dao.session; + +import java.io.Serializable; +import java.util.Date; +import java.util.Set; + +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 org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.NamedQueries; +import org.hibernate.annotations.NamedQuery; + +@Entity +@DynamicUpdate(value=true) +@Table(name = "authenticatedsessionstore") +@NamedQueries({ + @NamedQuery(name="getSessionWithID", query = "select authenticatedsessionstore from AuthenticatedSessionStore authenticatedsessionstore where authenticatedsessionstore.sessionid = :sessionid"), + @NamedQuery(name="getMOAISessionsWithTimeOut", query = "select authenticatedsessionstore from AuthenticatedSessionStore authenticatedsessionstore where authenticatedsessionstore.created < :timeout") +}) + +public class AuthenticatedSessionStore implements Serializable{ + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name = "id", unique=true, nullable=false) + private int id = 0; + + @Column(name = "sessionid", unique=true, nullable=false) + private String sessionid; + + @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; + + @OneToMany(mappedBy="ssoidentifier") + private Set activeOAsessions; + + @OneToMany(mappedBy="ssoidentifier") + private Set oldssosessionids; + + @Column(name = "created", updatable=false, nullable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "updated") + @Temporal(TemporalType.TIMESTAMP) + private Date updated; + + @PrePersist + protected void created() { + this.updated = this.created = new Date(); + } + + @PreUpdate + protected void lastUpdate() { + this.updated = new Date(); + } + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSessionid() { + return sessionid; + } + + public void setSessionid(String sessionid) { + this.sessionid = sessionid; + } + + 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 Date getCreated() { + return created; + } + + public Date getUpdated() { + return updated; + } + + public void setCreated(Date created) { + this.created = created; + } + + public void setUpdated(Date updated) { + this.updated = updated; + } + + public boolean isSSOSession() { + return isSSOSession; + } + + public void setSSOSession(boolean isSSOSession) { + this.isSSOSession = isSSOSession; + } + + + +} diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java new file mode 100644 index 000000000..597c275b7 --- /dev/null +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java @@ -0,0 +1,88 @@ +package at.gv.egovernment.moa.id.commons.db.dao.session; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.NamedQueries; +import org.hibernate.annotations.NamedQuery; + +@Entity +@DynamicUpdate(value=true) +@Table(name = "oasessionstore") + +@NamedQueries({ + @NamedQuery(name="getOAsWithSSOID", query = "select oasessionstore from OASessionStore oasessionstore where oasessionstore.ssoidentifier = :ssoidentifier") +}) + +public class OASessionStore implements Serializable{ + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name = "idOASession", unique=true, nullable=false) + private int idOASession = 0; + + @ManyToOne + @JoinColumn(name = "id") + private AuthenticatedSessionStore ssoidentifier; + + @Column(name = "oaurlprefix", unique=false, nullable=false) + private String oaurlprefix; + + @Column(name = "created", updatable=false, nullable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @PrePersist + protected void created() { + this.created = new Date(); + } + + public int getId() { + return idOASession; + } + + public void setId(int id) { + this.idOASession = id; + } + + public AuthenticatedSessionStore getSsoidentifier() { + return ssoidentifier; + } + + public void setSsoidentifier(AuthenticatedSessionStore ssoidentifier) { + this.ssoidentifier = ssoidentifier; + } + + public String getOaurlprefix() { + return oaurlprefix; + } + + public void setOaurlprefix(String oaurlprefix) { + this.oaurlprefix = oaurlprefix; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + +} + diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OldSSOSessionIDStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OldSSOSessionIDStore.java new file mode 100644 index 000000000..571acd094 --- /dev/null +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OldSSOSessionIDStore.java @@ -0,0 +1,73 @@ +package at.gv.egovernment.moa.id.commons.db.dao.session; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.NamedQueries; +import org.hibernate.annotations.NamedQuery; + +@Entity +@DynamicUpdate(value=true) +@Table(name = "oldssosessionid") + +@NamedQueries({ + @NamedQuery(name="getSSOSessionWithOldSessionID", query = "select oldssosessionid from OldSSOSessionIDStore oldssosessionid where oldssosessionid.oldsessionid = :sessionid") +}) + +public class OldSSOSessionIDStore implements Serializable{ + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name = "idOldSSOSession", unique=true, nullable=false) + private int idOldSSOSession = 0; + + @ManyToOne + @JoinColumn(name = "id") + private AuthenticatedSessionStore ssoidentifier; + + @Column(name = "oldsessionid", unique=true, nullable=false) + private String oldsessionid; + + public int getId() { + return idOldSSOSession; + } + + public void setId(int id) { + this.idOldSSOSession = id; + } + + public AuthenticatedSessionStore getSsoidentifier() { + return ssoidentifier; + } + + public void setSsoidentifier(AuthenticatedSessionStore ssoidentifier) { + this.ssoidentifier = ssoidentifier; + } + + public String getOldsessionid() { + return oldsessionid; + } + + public void setOldsessionid(String oldsessionid) { + this.oldsessionid = oldsessionid; + } + + public String getSessionid() { + return oldsessionid; + } + + public void setSessionid(String oldsessionid) { + this.oldsessionid = oldsessionid; + } +} -- cgit v1.2.3