aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2013-07-26 07:47:08 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2013-07-26 07:47:08 +0200
commit59fd2c0ea0649c94340d67b735a2d53696065e4c (patch)
tree43722934ecabd4694c7675686c5541f857392cd9 /id/server/moa-id-commons
parentcfb70f755c45a2cad582e8030b1542add9949efb (diff)
downloadmoa-id-spss-59fd2c0ea0649c94340d67b735a2d53696065e4c.tar.gz
moa-id-spss-59fd2c0ea0649c94340d67b735a2d53696065e4c.tar.bz2
moa-id-spss-59fd2c0ea0649c94340d67b735a2d53696065e4c.zip
Bugfixes:
- handle Error if more then one authentication is started for one Online-Application - handle MultiThread error if more then one authentication process is active in one user session Add: - Add UserData database. (is required for the web-based configuration tool) - Add additional OA parameter in MOA-ID 2.x configuration scheme to set OAs active or not TODO: change 'searchOAWith....' to only get results with active=true
Diffstat (limited to 'id/server/moa-id-commons')
-rw-r--r--id/server/moa-id-commons/pom.xml4
-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
-rw-r--r--id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd1
-rw-r--r--id/server/moa-id-commons/src/main/resources/config/persistence_template.xml5
6 files changed, 290 insertions, 13 deletions
diff --git a/id/server/moa-id-commons/pom.xml b/id/server/moa-id-commons/pom.xml
index 540bd7b89..f04de3ad8 100644
--- a/id/server/moa-id-commons/pom.xml
+++ b/id/server/moa-id-commons/pom.xml
@@ -122,10 +122,8 @@
<extension>true</extension>
<schemaDirectory>src/main/resources/config</schemaDirectory>
<bindingDirectory>src/main/resources/config</bindingDirectory>
- <!-- persistenceXml>src/main/resources/config/persistence_template.xml</persistenceXml-->
+ <persistenceXml>src/main/resources/config/persistence_template.xml</persistenceXml>
<generatePackage>at.gv.egovernment.moa.id.commons.db.dao.config</generatePackage>
-
- <!-- roundtripTestClassName>RoundtripTest</roundtripTestClassName -->
</configuration>
</plugin>
<plugin>
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;
+ }
+
-
}
diff --git a/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd b/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd
index 9f4e54212..a90205260 100644
--- a/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd
+++ b/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd
@@ -504,6 +504,7 @@
<xsd:complexType name="ProxyComponentType"/>
<xsd:complexType name="OnlineApplicationType">
<xsd:sequence>
+ <xsd:element name="isActive" type="xsd:boolean" minOccurs="1" maxOccurs="1" default="false"/>
<xsd:element name="AuthComponent_OA" minOccurs="0">
<xsd:annotation>
<xsd:documentation>enthält Parameter über die OA, die die
diff --git a/id/server/moa-id-commons/src/main/resources/config/persistence_template.xml b/id/server/moa-id-commons/src/main/resources/config/persistence_template.xml
index d7ec8c625..727be25ec 100644
--- a/id/server/moa-id-commons/src/main/resources/config/persistence_template.xml
+++ b/id/server/moa-id-commons/src/main/resources/config/persistence_template.xml
@@ -2,9 +2,6 @@
<persistence version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<persistence-unit name="##generated">
- <class>at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore</class>
- <class>at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore</class>
- <class>at.gv.egovernment.moa.id.commons.db.dao.session.OASessionStore</class>
- <class>at.gv.egovernment.moa.id.commons.db.dao.session.OldSSOSessionIDStore</class>
+ <class>at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase</class>
</persistence-unit>
</persistence>