aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/at')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java10
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java263
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/AuthenticatedSessionStore.java20
3 files changed, 287 insertions, 6 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
index dc0e493d1..4bb0a08ea 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
@@ -23,7 +23,7 @@ public final class ConfigurationDBUtils {
protected ConfigurationDBUtils() { }
- public static void initHibernate(Properties props) {
+ public static void initHibernate(Properties props) throws MOADatabaseException {
try {
@@ -44,13 +44,15 @@ public final class ConfigurationDBUtils {
entitymanagerfactory =
Persistence.createEntityManagerFactory("at.gv.egovernment.moa.id.commons.db.dao.config",
props);
+
+
Logger.debug("Initial session factory successfully created.");
} catch (Throwable ex) {
Logger.error("Initial session factory creation failed: " + ex.getMessage());
- throw new ExceptionInInitializerError(ex);
+ throw new MOADatabaseException("Initialization of Configuration Hibernate session factory failed.",ex);
}
}
@@ -71,7 +73,7 @@ public final class ConfigurationDBUtils {
EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
// Open a new Session, if this Thread has none yet
- if (session == null) {
+ if (session == null || !session.isOpen()) {
session = getNewSession();
}
return session;
@@ -85,7 +87,7 @@ public final class ConfigurationDBUtils {
return entitymanagerfactory.createEntityManager();
}
EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
- if (session != null) {
+ if (session != null ) {
Logger.warn("Previous session has not been closed; closing session now.");
closeSession();
}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java
new file mode 100644
index 000000000..d1887bfa6
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java
@@ -0,0 +1,263 @@
+package at.gv.egovernment.moa.id.commons.db.dao.config;
+
+import java.io.Serializable;
+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.OneToMany;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.hibernate.annotations.DynamicUpdate;
+
+import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
+
+
+@Entity
+@DynamicUpdate(value=true)
+@Table(name = "userdatabase")
+public class UserDatabase implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id", unique=true, nullable=false)
+ private long id;
+
+ @Column(name = "givenname", nullable=false)
+ private String givenname;
+
+ @Column(name = "familyname", nullable=false)
+ private String familyname;
+
+ @Column(name = "institut", nullable=false)
+ private String institut;
+
+ @Column(name = "mail", nullable=false)
+ private String mail;
+
+ @Column(name = "phone", nullable=false)
+ private String phone;
+
+ @Column(name = "username", unique=true, nullable=false)
+ private String username;
+
+ @Column(name = "password", nullable=false)
+ private String password;
+
+ @Column(name = "bpk", unique=true, nullable=false)
+ private String bpk;
+
+ @Column(name = "isadmin", nullable=false)
+ private boolean isadmin;
+
+ @Column(name = "isactive", nullable=false)
+ private boolean isactive;
+
+ @OneToMany(mappedBy="hjid", cascade=CascadeType.REFRESH)
+ private List<OnlineApplication> registratedOAs = null;
+
+ @Column(name = "lastlogin")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date lastlogin;
+
+ @PreUpdate
+ protected void lastUpdate() {
+ this.lastlogin = new Date();
+ }
+
+ /**
+ * @return the id
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the givenname
+ */
+ public String getGivenname() {
+ return givenname;
+ }
+
+ /**
+ * @param givenname the givenname to set
+ */
+ public void setGivenname(String givenname) {
+ this.givenname = givenname;
+ }
+
+ /**
+ * @return the familyname
+ */
+ public String getFamilyname() {
+ return familyname;
+ }
+
+ /**
+ * @param familyname the familyname to set
+ */
+ public void setFamilyname(String familyname) {
+ this.familyname = familyname;
+ }
+
+ /**
+ * @return the institut
+ */
+ public String getInstitut() {
+ return institut;
+ }
+
+ /**
+ * @param institut the institut to set
+ */
+ public void setInstitut(String institut) {
+ this.institut = institut;
+ }
+
+ /**
+ * @return the mail
+ */
+ public String getMail() {
+ return mail;
+ }
+
+ /**
+ * @param mail the mail to set
+ */
+ public void setMail(String mail) {
+ this.mail = mail;
+ }
+
+ /**
+ * @return the phone
+ */
+ public String getPhone() {
+ return phone;
+ }
+
+ /**
+ * @param phone the phone to set
+ */
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the bpk
+ */
+ public String getBpk() {
+ return bpk;
+ }
+
+ /**
+ * @param bpk the bpk to set
+ */
+ public void setBpk(String bpk) {
+ this.bpk = bpk;
+ }
+
+ /**
+ * @return the isadmin
+ */
+ public boolean isIsadmin() {
+ return isadmin;
+ }
+
+ /**
+ * @param isadmin the isadmin to set
+ */
+ public void setIsadmin(boolean isadmin) {
+ this.isadmin = isadmin;
+ }
+
+ /**
+ * @return the isactive
+ */
+ public boolean isIsactive() {
+ return isactive;
+ }
+
+ /**
+ * @param isactive the isactive to set
+ */
+ public void setIsactive(boolean isactive) {
+ this.isactive = isactive;
+ }
+
+ /**
+ * @return the registratedOAs
+ */
+ public List<OnlineApplication> getRegistratedOAs() {
+ return registratedOAs;
+ }
+
+ /**
+ * @param registratedOAs the registratedOAs to set
+ */
+ public void setRegistratedOAs(List<OnlineApplication> registratedOAs) {
+ this.registratedOAs = registratedOAs;
+ }
+
+ /**
+ * @return the lastlogin
+ */
+ public Date getLastlogin() {
+ return lastlogin;
+ }
+
+ /**
+ * @param lastlogin the lastlogin to set
+ */
+ public void setLastlogin(Date lastlogin) {
+ this.lastlogin = lastlogin;
+ }
+
+
+}
+
+
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
index c08fe1bb2..ed865d70f 100644
--- 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
@@ -30,6 +30,7 @@ import org.hibernate.annotations.DynamicUpdate;
@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")
})
@@ -57,6 +58,9 @@ public class AuthenticatedSessionStore implements Serializable{
@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;
@@ -165,7 +169,19 @@ public class AuthenticatedSessionStore implements Serializable{
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;
+ }
+
-
}