aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons')
-rw-r--r--id/server/moa-id-commons/.classpath37
-rw-r--r--id/server/moa-id-commons/.project36
-rw-r--r--id/server/moa-id-commons/pom.xml112
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/DBUtils.java33
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/HibernateUtil.java166
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AssertionStore.java77
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AuthenticatedSessionStore.java136
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java88
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OldSSOSessionIDStore.java73
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ex/MOADatabaseException.java22
-rw-r--r--id/server/moa-id-commons/src/main/resources/hibernate.cfg.xml14
11 files changed, 794 insertions, 0 deletions
diff --git a/id/server/moa-id-commons/.classpath b/id/server/moa-id-commons/.classpath
new file mode 100644
index 000000000..3cb77b9e0
--- /dev/null
+++ b/id/server/moa-id-commons/.classpath
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.nondependency" value=""/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/id/server/moa-id-commons/.project b/id/server/moa-id-commons/.project
new file mode 100644
index 000000000..d109c42c5
--- /dev/null
+++ b/id/server/moa-id-commons/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>moa-id-commons</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
diff --git a/id/server/moa-id-commons/pom.xml b/id/server/moa-id-commons/pom.xml
new file mode 100644
index 000000000..0abd80602
--- /dev/null
+++ b/id/server/moa-id-commons/pom.xml
@@ -0,0 +1,112 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>MOA.id</groupId>
+ <artifactId>moa-id</artifactId>
+ <version>1.5.2</version>
+ </parent>
+ <artifactId>moa-id-commons</artifactId>
+ <name>moa-id-commons</name>
+ <groupId>MOA.id.server</groupId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>4.2.1.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>MOA</groupId>
+ <artifactId>moa-common</artifactId>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-c3p0</artifactId>
+ <version>4.2.1.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.25</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ <archive>
+ <addMavenDescriptor>false</addMavenDescriptor>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <charset>UTF-8</charset>
+ <docencoding>UTF-8</docencoding>
+ <quiet>true</quiet>
+ <author>false</author>
+ <version>false</version>
+ <use>true</use>
+ <excludePackageNames>at.gv.egovernment.moa.spss.server.*;at.gv.egovernment.moa.spss.api.impl.*;at.gv.egovernment.moa.spss.impl.*</excludePackageNames>
+ <tags>
+ <tag>
+ <name>pre</name>
+ <placement>a</placement>
+ <head>Preconditions:</head>
+ </tag>
+ <tag>
+ <name>post</name>
+ <placement>a</placement>
+ <head>Postconditions:</head>
+ </tag>
+ </tags>
+ <links>
+ <link>http://java.sun.com/j2se/1.4/docs/api/</link>
+ <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
+ <link>http://logging.apache.org/log4j/docs/api/</link>
+ </links>
+ <target>1.5</target>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-javadoc</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <version>1.5.2</version>
+</project> \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/DBUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/DBUtils.java
new file mode 100644
index 000000000..d60c5ef45
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/DBUtils.java
@@ -0,0 +1,33 @@
+package at.gv.egovernment.moa.id.commons.db;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+public class DBUtils {
+
+// @SuppressWarnings("rawtypes")
+// public static AssertionStore getAssertion(String artifact) {
+// MiscUtil.assertNotNull(artifact, "artifact");
+// Logger.trace("Getting Assertion with Artifact " + artifact + " from database.");
+//
+// Session session = HibernateUtil.getCurrentSession();
+// session.beginTransaction();
+// Query query = session.getNamedQuery("getAssertionWithArtifact");
+// query.setString("artifact", artifact);
+// List result = query.list();
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return (AssertionStore) result.get(0);
+// }
+
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/HibernateUtil.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/HibernateUtil.java
new file mode 100644
index 000000000..1fa5a20fd
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/HibernateUtil.java
@@ -0,0 +1,166 @@
+package at.gv.egovernment.moa.id.commons.db;
+
+import java.util.Properties;
+
+import org.apache.commons.lang3.StringUtils;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistry;
+import org.hibernate.service.ServiceRegistryBuilder;
+
+import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
+import at.gv.egovernment.moa.logging.Logger;
+
+public final class HibernateUtil {
+
+ private static SessionFactory sessionFactory;
+ private static ServiceRegistry serviceRegistry;
+
+ @SuppressWarnings("rawtypes")
+ private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();
+ private static boolean automaticSessionHandling = false;
+
+ private static final String[] AUTOMATIC_SESSION_HANDLING_VALUES = new String[] { "jta", "thread" };
+ private static final String SESSION_HANDLING_KEY = "hibernate.current_session_context_class";
+
+ private static Configuration configuration;
+
+ protected HibernateUtil() { }
+
+ public static void initHibernate(Configuration config, Properties hibernateProperties) {
+
+ String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY));
+ if (scm != null) {
+ automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1 || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1;
+ }
+ Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\".");
+ if (automaticSessionHandling) {
+ Logger.info("Hibernate is automatically handling session context management.");
+ } else {
+ Logger.info("Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling.");
+ }
+ try {
+ //Create the SessionFactory
+ Logger.debug("Creating initial session factory...");
+
+ config.configure();
+ serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
+ sessionFactory = config.buildSessionFactory(serviceRegistry);
+ Logger.debug("Initial session factory successfully created.");
+
+ } catch (Throwable ex) {
+ Logger.error("Initial session factory creation failed: " + ex.getMessage());
+ throw new ExceptionInInitializerError(ex);
+ }
+ }
+
+ /**
+ * Checks if a session factory is currently available. If necessary a new
+ * session factory is created.
+ *
+ * @return current (or new) session factory
+ * @throws HibernateException
+ * thrown if a hibernate error occurs
+ */
+ public static Session getCurrentSession() {
+ if (automaticSessionHandling) {
+ return sessionFactory.getCurrentSession();
+ }
+ Session session = (Session) THREAD_LOCAL.get();
+ // Open a new Session, if this Thread has none yet
+ if (session == null || !session.isConnected()) {
+ session = getNewSession();
+ }
+ return session;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Session getNewSession() {
+ if (automaticSessionHandling) {
+ Logger.warn("Session is being automatically handled by hibernate. Therefore this session maybe not being newly created. Use HibernateUtil.getCurrentSession() instead.");
+ return sessionFactory.getCurrentSession();
+ }
+ Session session = (Session) THREAD_LOCAL.get();
+ if (session != null) {
+ Logger.warn("Previous session has not been closed; closing session now.");
+ closeSession();
+ }
+ Logger.debug("Opening new hibernate session...");
+ try {
+ session = sessionFactory.openSession();
+ THREAD_LOCAL.set(session);
+ } catch (HibernateException hex) {
+ Logger.error(hex.getMessage());
+ }
+ return session;
+ }
+
+ /**
+ * Closes the current session.
+ *
+ * @throws HibernateException
+ * thrown if session is already closed or a hibernate error
+ * occurs.
+ */
+ @SuppressWarnings("unchecked")
+ public static void closeSession() {
+ if (automaticSessionHandling) {
+ Logger.warn("Session is being automatically handled by hibernate. Therefore the current session cannot be closed on demand.");
+ return;
+ }
+ Logger.debug("Closing current hibernate session...");
+ Session session = (Session) THREAD_LOCAL.get();
+ THREAD_LOCAL.set(null);
+ if (session != null) {
+ try {
+ session.close();
+
+ } catch (HibernateException hex) {
+ Logger.error(hex.getMessage());
+ }
+ }
+ }
+
+ public static boolean saveOrUpdate(Object dbo) throws MOADatabaseException {
+ Transaction tx = null;
+ try {
+ Session session = HibernateUtil.getCurrentSession();
+
+ synchronized (session) {
+ tx = session.beginTransaction();
+ session.saveOrUpdate(dbo);
+ tx.commit();
+ }
+ return true;
+
+ } catch(HibernateException e) {
+ Logger.warn("Error during database saveOrUpdate. Rollback.", e);
+ tx.rollback();
+ throw new MOADatabaseException(e);
+ }
+ }
+
+ public static boolean delete(Object dbo) {
+ Transaction tx = null;
+ try {
+ Session session = HibernateUtil.getCurrentSession();
+
+ synchronized (session) {
+ tx = session.beginTransaction();
+ session.delete(dbo);
+ tx.commit();
+ }
+
+ return true;
+
+ } catch(HibernateException e) {
+ Logger.warn("Error during database delete. Rollback.", e);
+ tx.rollback();
+ return false;
+ }
+ }
+
+}
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<OASessionStore> activeOAsessions;
+
+ @OneToMany(mappedBy="ssoidentifier")
+ private Set<OldSSOSessionIDStore> 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;
+ }
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ex/MOADatabaseException.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ex/MOADatabaseException.java
new file mode 100644
index 000000000..169d31aac
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ex/MOADatabaseException.java
@@ -0,0 +1,22 @@
+package at.gv.egovernment.moa.id.commons.db.ex;
+
+public class MOADatabaseException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public MOADatabaseException() {
+ super();
+ }
+
+ public MOADatabaseException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MOADatabaseException(String message) {
+ super(message);
+ }
+
+ public MOADatabaseException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/id/server/moa-id-commons/src/main/resources/hibernate.cfg.xml b/id/server/moa-id-commons/src/main/resources/hibernate.cfg.xml
new file mode 100644
index 000000000..4841481b6
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/resources/hibernate.cfg.xml
@@ -0,0 +1,14 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE hibernate-configuration PUBLIC
+"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+ <!-- MOA Session handling mapping files -->
+ <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore"/>
+ <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore"/>
+ <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.OASessionStore"/>
+ <mapping class="at.gv.egovernment.moa.id.commons.db.dao.session.OldSSOSessionIDStore"/>
+ </session-factory>
+</hibernate-configuration> \ No newline at end of file