started to introduce application to config and to split account_login from account.
This commit is contained in:
@ -6,8 +6,8 @@
|
|||||||
package de.muehlencord.shared.account.web;
|
package de.muehlencord.shared.account.web;
|
||||||
|
|
||||||
import de.muehlencord.shared.account.business.config.boundary.ConfigService;
|
import de.muehlencord.shared.account.business.config.boundary.ConfigService;
|
||||||
import de.muehlencord.shared.account.business.accountcounfig.entity.AccountConfigurationKey;
|
import de.muehlencord.shared.account.business.accountconfig.entity.AccountConfigurationKey;
|
||||||
import de.muehlencord.shared.account.business.accountcounfig.entity.AccountConfigurationValue;
|
import de.muehlencord.shared.account.business.accountconfig.entity.AccountConfigurationValue;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigException;
|
import de.muehlencord.shared.account.business.config.entity.ConfigException;
|
||||||
import javax.ejb.EJB;
|
import javax.ejb.EJB;
|
||||||
import javax.enterprise.context.Dependent;
|
import javax.enterprise.context.Dependent;
|
||||||
|
|||||||
@ -3,17 +3,20 @@
|
|||||||
CAUTION: Do not modify this file unless you know what you are doing.
|
CAUTION: Do not modify this file unless you know what you are doing.
|
||||||
Unexpected results may occur if the code is changed deliberately.
|
Unexpected results may occur if the code is changed deliberately.
|
||||||
-->
|
-->
|
||||||
<dbmodel pgmodeler-ver="0.9.1" author="Joern Muehlencord" last-position="0,0" last-zoom="0.85"
|
<dbmodel pgmodeler-ver="0.9.1" author="Joern Muehlencord" last-position="315,0" last-zoom="0.7"
|
||||||
default-schema="public" default-owner="postgres">
|
default-schema="public">
|
||||||
<database name="account_test" encoding="UTF8" lc-collate="German_Germany.1252" lc-ctype="German_Germany.1252" is-template="false" allow-conns="true" sql-disabled="true">
|
<database name="account_test" encoding="UTF8" lc-collate="C" lc-ctype="C" is-template="false" allow-conns="true" sql-disabled="true">
|
||||||
</database>
|
</database>
|
||||||
|
|
||||||
<schema name="public" fill-color="#e1e1e1" sql-disabled="true">
|
<schema name="public" fill-color="#e1e1e1" sql-disabled="true">
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
<table name="config">
|
<table name="config" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="1912" y="120.235"/>
|
<position x="1880" y="380"/>
|
||||||
|
<column name="application" not-null="true">
|
||||||
|
<type name="uuid" length="0"/>
|
||||||
|
</column>
|
||||||
<column name="config_key" not-null="true">
|
<column name="config_key" not-null="true">
|
||||||
<type name="varchar" length="100"/>
|
<type name="varchar" length="100"/>
|
||||||
</column>
|
</column>
|
||||||
@ -27,13 +30,13 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
<type name="varchar" length="200"/>
|
<type name="varchar" length="200"/>
|
||||||
</column>
|
</column>
|
||||||
<constraint name="config_pk" type="pk-constr" table="public.config">
|
<constraint name="config_pk" type="pk-constr" table="public.config">
|
||||||
<columns names="config_key,config_key_account" ref-type="src-columns"/>
|
<columns names="application,config_key,config_key_account" ref-type="src-columns"/>
|
||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="application_role">
|
<table name="application_role" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="158.022" y="490"/>
|
<position x="160" y="500"/>
|
||||||
<column name="id" not-null="true">
|
<column name="id" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -54,9 +57,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="account">
|
<table name="account" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="1323.59" y="185.294"/>
|
<position x="1240" y="100"/>
|
||||||
<column name="id" not-null="true">
|
<column name="id" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -72,30 +75,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
<column name="lastname" not-null="true">
|
<column name="lastname" not-null="true">
|
||||||
<type name="character varying" length="100"/>
|
<type name="character varying" length="100"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="account_password" not-null="true">
|
|
||||||
<type name="character" length="200"/>
|
|
||||||
</column>
|
|
||||||
<column name="last_login">
|
|
||||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
|
||||||
</column>
|
|
||||||
<column name="last_failed_login">
|
|
||||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
|
||||||
</column>
|
|
||||||
<column name="failure_count" not-null="true" default-value="0">
|
|
||||||
<type name="integer" length="0"/>
|
|
||||||
</column>
|
|
||||||
<column name="status" not-null="true" default-value="'NEW'">
|
<column name="status" not-null="true" default-value="'NEW'">
|
||||||
<type name="character varying" length="10"/>
|
<type name="character varying" length="10"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="password_reset_ongoing" not-null="true" default-value="false">
|
|
||||||
<type name="boolean" length="0"/>
|
|
||||||
</column>
|
|
||||||
<column name="password_reset_valid_to">
|
|
||||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
|
||||||
</column>
|
|
||||||
<column name="password_reset_hash">
|
|
||||||
<type name="character" length="200"/>
|
|
||||||
</column>
|
|
||||||
<column name="created_on" not-null="true" default-value="timezone('utc'::text, now())">
|
<column name="created_on" not-null="true" default-value="timezone('utc'::text, now())">
|
||||||
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
<type name="timestamp with time zone" length="0" with-timezone="true"/>
|
||||||
</column>
|
</column>
|
||||||
@ -116,9 +98,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="account_history">
|
<table name="account_history" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="725.984" y="294.706"/>
|
<position x="760" y="340"/>
|
||||||
<column name="id" not-null="true">
|
<column name="id" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -145,9 +127,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="account_role">
|
<table name="account_role" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="738.806" y="90"/>
|
<position x="740" y="100"/>
|
||||||
<column name="account" not-null="true">
|
<column name="account" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -159,9 +141,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="application_permission">
|
<table name="application_permission" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="1588.77" y="866.604"/>
|
<position x="1560" y="740"/>
|
||||||
<column name="id" not-null="true">
|
<column name="id" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -182,9 +164,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="role_permission">
|
<table name="role_permission" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="843.804" y="631.603"/>
|
<position x="960" y="800"/>
|
||||||
<column name="application_role" not-null="true">
|
<column name="application_role" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -196,9 +178,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="mail_template">
|
<table name="mail_template" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="1840.59" y="309.132"/>
|
<position x="280" y="860"/>
|
||||||
<column name="template_name" not-null="true">
|
<column name="template_name" not-null="true">
|
||||||
<type name="character varying" length="40"/>
|
<type name="character varying" length="40"/>
|
||||||
</column>
|
</column>
|
||||||
@ -210,9 +192,9 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table name="application">
|
<table name="application" hide-ext-attribs="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
<position x="791.059" y="835.059"/>
|
<position x="1080" y="560"/>
|
||||||
<column name="id" not-null="true">
|
<column name="id" not-null="true">
|
||||||
<type name="uuid" length="0"/>
|
<type name="uuid" length="0"/>
|
||||||
</column>
|
</column>
|
||||||
@ -224,16 +206,72 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
</constraint>
|
</constraint>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<extension name="uuid-ossp">
|
<extension name="uuid-ossp" sql-disabled="true">
|
||||||
<schema name="public"/>
|
<schema name="public"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
<table name="account_login" hide-ext-attribs="true">
|
||||||
|
<schema name="public"/>
|
||||||
|
<position x="1880" y="20"/>
|
||||||
|
<column name="id" not-null="true" default-value="uuid_generate_v4()">
|
||||||
|
<type name="uuid" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="account" not-null="true">
|
||||||
|
<type name="uuid" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="account_password" not-null="true">
|
||||||
|
<type name="varchar" length="200"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_login">
|
||||||
|
<type name="timestamptz" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_failed_login">
|
||||||
|
<type name="timestamptz" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="failure_count" not-null="true" default-value="0">
|
||||||
|
<type name="integer" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="password_reset_ongoing" not-null="true" default-value="false">
|
||||||
|
<type name="boolean" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="password_reset_valid_to">
|
||||||
|
<type name="timestamptz" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="password_reset_hash">
|
||||||
|
<type name="varchar" length="200"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_on" not-null="true" default-value="timezone('utc'::text, now())">
|
||||||
|
<type name="timestamptz" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_by" not-null="true">
|
||||||
|
<type name="varchar" length="32"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_updated_on" not-null="true" default-value="timezone('utc'::text, now())">
|
||||||
|
<type name="timestamptz" length="0"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_updated_by" not-null="true">
|
||||||
|
<type name="varchar" length="32"/>
|
||||||
|
</column>
|
||||||
|
<constraint name="account_login_pk" type="pk-constr" table="public.account_login">
|
||||||
|
<columns names="id" ref-type="src-columns"/>
|
||||||
|
</constraint>
|
||||||
|
<constraint name="account_login_uidx" type="uq-constr" table="public.account_login">
|
||||||
|
<columns names="account" ref-type="src-columns"/>
|
||||||
|
</constraint>
|
||||||
|
</table>
|
||||||
|
|
||||||
<constraint name="config_key_account_fk" type="fk-constr" comparison-type="MATCH FULL"
|
<constraint name="config_key_account_fk" type="fk-constr" comparison-type="MATCH FULL"
|
||||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.account" table="public.config">
|
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.account" table="public.config">
|
||||||
<columns names="config_key_account" ref-type="src-columns"/>
|
<columns names="config_key_account" ref-type="src-columns"/>
|
||||||
<columns names="id" ref-type="dst-columns"/>
|
<columns names="id" ref-type="dst-columns"/>
|
||||||
</constraint>
|
</constraint>
|
||||||
|
|
||||||
|
<constraint name="config_application_fk" type="fk-constr" comparison-type="MATCH FULL"
|
||||||
|
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.application" table="public.config">
|
||||||
|
<columns names="application" ref-type="src-columns"/>
|
||||||
|
<columns names="id" ref-type="dst-columns"/>
|
||||||
|
</constraint>
|
||||||
|
|
||||||
<constraint name="application_role_app_fk" type="fk-constr" comparison-type="MATCH FULL"
|
<constraint name="application_role_app_fk" type="fk-constr" comparison-type="MATCH FULL"
|
||||||
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.application" table="public.application_role">
|
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.application" table="public.application_role">
|
||||||
<columns names="application" ref-type="src-columns"/>
|
<columns names="application" ref-type="src-columns"/>
|
||||||
@ -276,6 +314,12 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
<columns names="id" ref-type="dst-columns"/>
|
<columns names="id" ref-type="dst-columns"/>
|
||||||
</constraint>
|
</constraint>
|
||||||
|
|
||||||
|
<constraint name="account_login_fk" type="fk-constr" comparison-type="MATCH FULL"
|
||||||
|
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.account" table="public.account_login">
|
||||||
|
<columns names="account" ref-type="src-columns"/>
|
||||||
|
<columns names="id" ref-type="dst-columns"/>
|
||||||
|
</constraint>
|
||||||
|
|
||||||
<relationship name="rel_account_history_account" type="relfk"
|
<relationship name="rel_account_history_account" type="relfk"
|
||||||
custom-color="#83af1f"
|
custom-color="#83af1f"
|
||||||
src-table="public.account_history"
|
src-table="public.account_history"
|
||||||
@ -321,4 +365,14 @@ CAUTION: Do not modify this file unless you know what you are doing.
|
|||||||
dst-table="public.application" reference-fk="application_permission_app_fk"
|
dst-table="public.application" reference-fk="application_permission_app_fk"
|
||||||
src-required="false" dst-required="false"/>
|
src-required="false" dst-required="false"/>
|
||||||
|
|
||||||
|
<relationship name="rel_account_login_account" type="relfk"
|
||||||
|
src-table="public.account_login"
|
||||||
|
dst-table="public.account" reference-fk="account_login_fk"
|
||||||
|
src-required="false" dst-required="false"/>
|
||||||
|
|
||||||
|
<relationship name="rel_config_application" type="relfk"
|
||||||
|
src-table="public.config"
|
||||||
|
dst-table="public.application" reference-fk="config_application_fk"
|
||||||
|
src-required="false" dst-required="false"/>
|
||||||
|
|
||||||
</dbmodel>
|
</dbmodel>
|
||||||
|
|||||||
@ -281,7 +281,7 @@ public class AccountControl implements Serializable {
|
|||||||
em.merge(account);
|
em.merge(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLoginError(AccountEntity account) {
|
public void addLoginError(ApplicationEntity application, AccountEntity account) {
|
||||||
try {
|
try {
|
||||||
Date now = new Date(); // TODO now in UTC
|
Date now = new Date(); // TODO now in UTC
|
||||||
account.setLastFailedLogin(now);
|
account.setLastFailedLogin(now);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package de.muehlencord.shared.account.business.account.entity;
|
package de.muehlencord.shared.account.business.account.entity;
|
||||||
|
|
||||||
|
import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -18,6 +19,7 @@ import javax.persistence.ManyToMany;
|
|||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
@ -38,7 +40,6 @@ import org.hibernate.annotations.Type;
|
|||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(name = "AccountEntity.findAll", query = "SELECT a FROM AccountEntity a ORDER by a.username"),
|
@NamedQuery(name = "AccountEntity.findAll", query = "SELECT a FROM AccountEntity a ORDER by a.username"),
|
||||||
@NamedQuery(name = "AccountEntity.findByUsername", query = "SELECT a FROM AccountEntity a WHERE a.username = :username"),
|
@NamedQuery(name = "AccountEntity.findByUsername", query = "SELECT a FROM AccountEntity a WHERE a.username = :username"),
|
||||||
@NamedQuery(name = "AccountEntity.findByEmailaddress", query = "SELECT a FROM AccountEntity a WHERE a.emailaddress = :emailaddress ORDER BY a.username"),
|
|
||||||
@NamedQuery(name = "AccountEntity.findByFirstname", query = "SELECT a FROM AccountEntity a WHERE a.firstname = :firstname ORDER BY a.username"),
|
@NamedQuery(name = "AccountEntity.findByFirstname", query = "SELECT a FROM AccountEntity a WHERE a.firstname = :firstname ORDER BY a.username"),
|
||||||
@NamedQuery(name = "AccountEntity.findByLastname", query = "SELECT a FROM AccountEntity a WHERE a.lastname = :lastname ORDER BY a.username"),
|
@NamedQuery(name = "AccountEntity.findByLastname", query = "SELECT a FROM AccountEntity a WHERE a.lastname = :lastname ORDER BY a.username"),
|
||||||
@NamedQuery(name = "AccountEntity.findByAccountPassword", query = "SELECT a FROM AccountEntity a WHERE a.accountPassword = :accountPassword"),
|
@NamedQuery(name = "AccountEntity.findByAccountPassword", query = "SELECT a FROM AccountEntity a WHERE a.accountPassword = :accountPassword"),
|
||||||
@ -55,6 +56,9 @@ import org.hibernate.annotations.Type;
|
|||||||
@NamedQuery(name = "AccountEntity.findByLastUpdatedBy", query = "SELECT a FROM AccountEntity a WHERE a.lastUpdatedBy = :lastUpdatedBy")})
|
@NamedQuery(name = "AccountEntity.findByLastUpdatedBy", query = "SELECT a FROM AccountEntity a WHERE a.lastUpdatedBy = :lastUpdatedBy")})
|
||||||
public class AccountEntity implements Serializable, Account {
|
public class AccountEntity implements Serializable, Account {
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "account")
|
||||||
|
private List<ConfigEntity> configEntityList;
|
||||||
|
|
||||||
private static final long serialVersionUID = 6216991757526150935L;
|
private static final long serialVersionUID = 6216991757526150935L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ -67,16 +71,6 @@ public class AccountEntity implements Serializable, Account {
|
|||||||
private UUID id;
|
private UUID id;
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 32)
|
|
||||||
@Column(name = "username")
|
|
||||||
private String username;
|
|
||||||
@Basic(optional = false)
|
|
||||||
@NotNull
|
|
||||||
@Size(min = 1, max = 200)
|
|
||||||
@Column(name = "emailaddress")
|
|
||||||
private String emailaddress;
|
|
||||||
@Basic(optional = false)
|
|
||||||
@NotNull
|
|
||||||
@Size(min = 1, max = 100)
|
@Size(min = 1, max = 100)
|
||||||
@Column(name = "firstname")
|
@Column(name = "firstname")
|
||||||
private String firstname;
|
private String firstname;
|
||||||
@ -142,43 +136,30 @@ public class AccountEntity implements Serializable, Account {
|
|||||||
private List<ApplicationRoleEntity> applicationRoleList;
|
private List<ApplicationRoleEntity> applicationRoleList;
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accountId", fetch = FetchType.LAZY)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accountId", fetch = FetchType.LAZY)
|
||||||
private List<AccountHistoryEntity> accountHistoryList;
|
private List<AccountHistoryEntity> accountHistoryList;
|
||||||
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "account")
|
||||||
|
private AccountLoginEntity accountLogin;
|
||||||
|
|
||||||
public AccountEntity() {
|
public AccountEntity() {
|
||||||
|
// empty constructor required for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountEntity(UUID id) {
|
@Override
|
||||||
this.id = id;
|
public String getUsername() {
|
||||||
}
|
if (accountLogin == null) {
|
||||||
|
return null;
|
||||||
public AccountEntity (String name) {
|
} else {
|
||||||
this.username = name;
|
return accountLogin.getUsername();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountEntity(UUID id, String username, String emailaddress, String firstname, String lastname, String accountPassword, int failureCount, String status, boolean passwordResetOngoing, Date createdOn, String createdBy, Date lastUpdatedOn, String lastUpdatedBy) {
|
|
||||||
this.id = id;
|
|
||||||
this.username = username;
|
|
||||||
this.emailaddress = emailaddress;
|
|
||||||
this.firstname = firstname;
|
|
||||||
this.lastname = lastname;
|
|
||||||
this.accountPassword = accountPassword;
|
|
||||||
this.failureCount = failureCount;
|
|
||||||
this.status = status;
|
|
||||||
this.passwordResetOngoing = passwordResetOngoing;
|
|
||||||
this.createdOn = createdOn;
|
|
||||||
this.createdBy = createdBy;
|
|
||||||
this.lastUpdatedOn = lastUpdatedOn;
|
|
||||||
this.lastUpdatedBy = lastUpdatedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addApplicationRole(ApplicationRoleEntity applicationRole) {
|
public void addApplicationRole(ApplicationRoleEntity applicationRole) {
|
||||||
if (applicationRoleList == null) {
|
if (applicationRoleList == null) {
|
||||||
applicationRoleList = new ArrayList<>();
|
applicationRoleList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
applicationRoleList.add (applicationRole);
|
applicationRoleList.add(applicationRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* **** getter / setter **** */
|
|
||||||
|
|
||||||
|
/* **** getter / setter **** */
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -187,23 +168,6 @@ public class AccountEntity implements Serializable, Account {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmailaddress() {
|
|
||||||
return emailaddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmailaddress(String emailaddress) {
|
|
||||||
this.emailaddress = emailaddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFirstname() {
|
public String getFirstname() {
|
||||||
return firstname;
|
return firstname;
|
||||||
@ -361,4 +325,21 @@ public class AccountEntity implements Serializable, Account {
|
|||||||
return "de.muehlencord.shared.account.entity.Account[ id=" + id + " ]";
|
return "de.muehlencord.shared.account.entity.Account[ id=" + id + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccountLoginEntity getAccountLogin() {
|
||||||
|
return accountLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountLogin(AccountLoginEntity accountLogin) {
|
||||||
|
this.accountLogin = accountLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
|
public List<ConfigEntity> getConfigEntityList() {
|
||||||
|
return configEntityList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigEntityList(List<ConfigEntity> configEntityList) {
|
||||||
|
this.configEntityList = configEntityList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package de.muehlencord.shared.account.business.account.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.Lob;
|
||||||
|
import javax.persistence.NamedQueries;
|
||||||
|
import javax.persistence.NamedQuery;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jomu
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "account_login")
|
||||||
|
@XmlRootElement
|
||||||
|
@NamedQueries({
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findAll", query = "SELECT a FROM AccountLoginEntity a"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByAccountPassword", query = "SELECT a FROM AccountLoginEntity a WHERE a.accountPassword = :accountPassword"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByLastLogin", query = "SELECT a FROM AccountLoginEntity a WHERE a.lastLogin = :lastLogin"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByLastFailedLogin", query = "SELECT a FROM AccountLoginEntity a WHERE a.lastFailedLogin = :lastFailedLogin"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByFailureCount", query = "SELECT a FROM AccountLoginEntity a WHERE a.failureCount = :failureCount"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByPasswordResetOngoing", query = "SELECT a FROM AccountLoginEntity a WHERE a.passwordResetOngoing = :passwordResetOngoing"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByPasswordResetValidTo", query = "SELECT a FROM AccountLoginEntity a WHERE a.passwordResetValidTo = :passwordResetValidTo"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByPasswordResetHash", query = "SELECT a FROM AccountLoginEntity a WHERE a.passwordResetHash = :passwordResetHash"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByCreatedOn", query = "SELECT a FROM AccountLoginEntity a WHERE a.createdOn = :createdOn"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByCreatedBy", query = "SELECT a FROM AccountLoginEntity a WHERE a.createdBy = :createdBy"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByLastUpdatedOn", query = "SELECT a FROM AccountLoginEntity a WHERE a.lastUpdatedOn = :lastUpdatedOn"),
|
||||||
|
@NamedQuery(name = "AccountLoginEntity.findByLastUpdatedBy", query = "SELECT a FROM AccountLoginEntity a WHERE a.lastUpdatedBy = :lastUpdatedBy")})
|
||||||
|
public class AccountLoginEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -799045989045040077L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "id")
|
||||||
|
@GeneratedValue(generator = "uuid2")
|
||||||
|
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||||
|
@Type(type = "pg-uuid")
|
||||||
|
private UUID id;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 1, max = 32)
|
||||||
|
@Column(name = "username")
|
||||||
|
private String username;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 1, max = 200)
|
||||||
|
@Column(name = "emailaddress")
|
||||||
|
private String emailaddress;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 1, max = 200)
|
||||||
|
@Column(name = "account_password")
|
||||||
|
private String accountPassword;
|
||||||
|
@Column(name = "last_login")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date lastLogin;
|
||||||
|
@Column(name = "last_failed_login")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date lastFailedLogin;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "failure_count")
|
||||||
|
private int failureCount;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "password_reset_ongoing")
|
||||||
|
private boolean passwordResetOngoing;
|
||||||
|
@Column(name = "password_reset_valid_to")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date passwordResetValidTo;
|
||||||
|
@Size(max = 200)
|
||||||
|
@Column(name = "password_reset_hash")
|
||||||
|
private String passwordResetHash;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "created_on")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date createdOn;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 1, max = 32)
|
||||||
|
@Column(name = "created_by")
|
||||||
|
private String createdBy;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "last_updated_on")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date lastUpdatedOn;
|
||||||
|
@Basic(optional = false)
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 1, max = 32)
|
||||||
|
@Column(name = "last_updated_by")
|
||||||
|
private String lastUpdatedBy;
|
||||||
|
@JoinColumn(name = "account", referencedColumnName = "id")
|
||||||
|
@OneToOne(optional = false)
|
||||||
|
private AccountEntity account;
|
||||||
|
|
||||||
|
public AccountLoginEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountPassword() {
|
||||||
|
return accountPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountPassword(String accountPassword) {
|
||||||
|
this.accountPassword = accountPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastLogin() {
|
||||||
|
return lastLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLogin(Date lastLogin) {
|
||||||
|
this.lastLogin = lastLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastFailedLogin() {
|
||||||
|
return lastFailedLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastFailedLogin(Date lastFailedLogin) {
|
||||||
|
this.lastFailedLogin = lastFailedLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFailureCount() {
|
||||||
|
return failureCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailureCount(int failureCount) {
|
||||||
|
this.failureCount = failureCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPasswordResetOngoing() {
|
||||||
|
return passwordResetOngoing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPasswordResetOngoing(boolean passwordResetOngoing) {
|
||||||
|
this.passwordResetOngoing = passwordResetOngoing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getPasswordResetValidTo() {
|
||||||
|
return passwordResetValidTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPasswordResetValidTo(Date passwordResetValidTo) {
|
||||||
|
this.passwordResetValidTo = passwordResetValidTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPasswordResetHash() {
|
||||||
|
return passwordResetHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPasswordResetHash(String passwordResetHash) {
|
||||||
|
this.passwordResetHash = passwordResetHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedOn() {
|
||||||
|
return createdOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedOn(Date createdOn) {
|
||||||
|
this.createdOn = createdOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastUpdatedOn() {
|
||||||
|
return lastUpdatedOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastUpdatedOn(Date lastUpdatedOn) {
|
||||||
|
this.lastUpdatedOn = lastUpdatedOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastUpdatedBy() {
|
||||||
|
return lastUpdatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastUpdatedBy(String lastUpdatedBy) {
|
||||||
|
this.lastUpdatedBy = lastUpdatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountEntity getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount(AccountEntity account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmailaddress() {
|
||||||
|
return emailaddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailaddress(String emailaddress) {
|
||||||
|
this.emailaddress = emailaddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 0;
|
||||||
|
hash += (id != null ? id.hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
// TODO: Warning - this method won't work in the case the id fields are not set
|
||||||
|
if (!(object instanceof AccountLoginEntity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AccountLoginEntity other = (AccountLoginEntity) object;
|
||||||
|
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "de.muehlencord.shared.account.business.account.entity.AccountLoginEntity[ id=" + id + " ]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,7 +3,7 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.business.accountcounfig.entity;
|
package de.muehlencord.shared.account.business.accountconfig.entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -3,7 +3,7 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.business.accountcounfig.entity;
|
package de.muehlencord.shared.account.business.accountconfig.entity;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -2,6 +2,7 @@ package de.muehlencord.shared.account.business.application.entity;
|
|||||||
|
|
||||||
import de.muehlencord.shared.account.business.account.entity.ApplicationPermissionEntity;
|
import de.muehlencord.shared.account.business.account.entity.ApplicationPermissionEntity;
|
||||||
import de.muehlencord.shared.account.business.account.entity.ApplicationRoleEntity;
|
import de.muehlencord.shared.account.business.account.entity.ApplicationRoleEntity;
|
||||||
|
import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -53,7 +54,9 @@ public class ApplicationEntity implements Serializable {
|
|||||||
private List<ApplicationRoleEntity> applicationRoleEntityList;
|
private List<ApplicationRoleEntity> applicationRoleEntityList;
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "application")
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "application")
|
||||||
private List<ApplicationPermissionEntity> applicationPermissions;
|
private List<ApplicationPermissionEntity> applicationPermissions;
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "application")
|
||||||
|
private List<ConfigEntity> configItems;
|
||||||
|
|
||||||
public ApplicationEntity() {
|
public ApplicationEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,4 +119,13 @@ public class ApplicationEntity implements Serializable {
|
|||||||
this.applicationPermissions = applicationPermissions;
|
this.applicationPermissions = applicationPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
|
public List<ConfigEntity> getConfigItems() {
|
||||||
|
return configItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigItems(List<ConfigEntity> configItems) {
|
||||||
|
this.configItems = configItems;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package de.muehlencord.shared.account.business.config.boundary;
|
|||||||
|
|
||||||
import de.muehlencord.shared.account.business.account.entity.Account;
|
import de.muehlencord.shared.account.business.account.entity.Account;
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
|
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
|
import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK;
|
import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigException;
|
import de.muehlencord.shared.account.business.config.entity.ConfigException;
|
||||||
@ -62,8 +63,9 @@ public class ConfigService implements Serializable {
|
|||||||
* more than one value is defined for the given key but none of the values
|
* more than one value is defined for the given key but none of the values
|
||||||
* is defined for the system user
|
* is defined for the system user
|
||||||
*/
|
*/
|
||||||
public String getConfigValue(String configKey) throws ConfigException {
|
public String getConfigValue(ApplicationEntity application, String configKey) throws ConfigException {
|
||||||
Query query = em.createNamedQuery("ConfigEntity.findByConfigKey");
|
Query query = em.createNamedQuery("ConfigEntity.findByConfigKey");
|
||||||
|
query.setParameter ("application", application);
|
||||||
query.setParameter("configKey", configKey);
|
query.setParameter("configKey", configKey);
|
||||||
List<ConfigEntity> configList = query.getResultList();
|
List<ConfigEntity> configList = query.getResultList();
|
||||||
if ((configList == null) || (configList.isEmpty())) {
|
if ((configList == null) || (configList.isEmpty())) {
|
||||||
@ -86,13 +88,13 @@ public class ConfigService implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConfigValue(String configKey, String defaultValue) throws ConfigException {
|
public String getConfigValue(ApplicationEntity application, String configKey, String defaultValue) throws ConfigException {
|
||||||
return getConfigValue(configKey, defaultValue, false);
|
return getConfigValue(application, configKey, defaultValue, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConfigValue(String configKey, String defaultValue, boolean storeDefaultValue) throws ConfigException {
|
public String getConfigValue(ApplicationEntity application, String configKey, String defaultValue, boolean storeDefaultValue) throws ConfigException {
|
||||||
// get configValue as usual
|
// get configValue as usual
|
||||||
String configValue = getConfigValue(configKey);
|
String configValue = getConfigValue(application, configKey);
|
||||||
|
|
||||||
// if config value is not found null has been returned
|
// if config value is not found null has been returned
|
||||||
// in this case the value to return is the defaultValue
|
// in this case the value to return is the defaultValue
|
||||||
@ -103,13 +105,13 @@ public class ConfigService implements Serializable {
|
|||||||
// check if the default value should be stored in the database
|
// check if the default value should be stored in the database
|
||||||
if (storeDefaultValue) {
|
if (storeDefaultValue) {
|
||||||
AccountEntity account = getAccount("system");
|
AccountEntity account = getAccount("system");
|
||||||
updateConfigValue(configKey, account, configValue);
|
updateConfigValue(application, configKey, account, configValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConfigValue(String configKey, Account account, boolean fallbackToSystem) throws ConfigException {
|
public String getConfigValue(ApplicationEntity application, String configKey, Account account, boolean fallbackToSystem) throws ConfigException {
|
||||||
Query query = em.createNamedQuery("ConfigEntity.findByConfigKeyAndAccount");
|
Query query = em.createNamedQuery("ConfigEntity.findByConfigKeyAndAccount");
|
||||||
query.setParameter("configKey", configKey);
|
query.setParameter("configKey", configKey);
|
||||||
query.setParameter("account", account);
|
query.setParameter("account", account);
|
||||||
@ -117,7 +119,7 @@ public class ConfigService implements Serializable {
|
|||||||
if ((configList == null) || (configList.isEmpty())) {
|
if ((configList == null) || (configList.isEmpty())) {
|
||||||
// fallback to default / system value
|
// fallback to default / system value
|
||||||
if (fallbackToSystem) {
|
if (fallbackToSystem) {
|
||||||
return getConfigValue(configKey);
|
return getConfigValue(application, configKey);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -130,8 +132,8 @@ public class ConfigService implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConfigValue(String configKey, String defaultValue, boolean storeDefaultValue, Account account, boolean fallbackToSystem) throws ConfigException {
|
public String getConfigValue(ApplicationEntity application, String configKey, String defaultValue, boolean storeDefaultValue, Account account, boolean fallbackToSystem) throws ConfigException {
|
||||||
String configValue = getConfigValue(configKey, account, fallbackToSystem);
|
String configValue = getConfigValue(application, configKey, account, fallbackToSystem);
|
||||||
|
|
||||||
if (configValue == null) {
|
if (configValue == null) {
|
||||||
// value not found for given account and if allowed also not found for system user
|
// value not found for given account and if allowed also not found for system user
|
||||||
@ -140,7 +142,7 @@ public class ConfigService implements Serializable {
|
|||||||
|
|
||||||
// check if the default value should be stored in the database
|
// check if the default value should be stored in the database
|
||||||
if (storeDefaultValue) {
|
if (storeDefaultValue) {
|
||||||
updateConfigValue(configKey, account, configValue);
|
updateConfigValue(application, configKey, account, configValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return configValue;
|
return configValue;
|
||||||
@ -148,14 +150,14 @@ public class ConfigService implements Serializable {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public boolean updateConfigValue(String configKey, String configValue) throws ConfigException {
|
public boolean updateConfigValue(ApplicationEntity application,String configKey, String configValue) throws ConfigException {
|
||||||
Account account = getAccount("system");
|
Account account = getAccount("system");
|
||||||
return updateConfigValue(configKey, account, configValue);
|
return updateConfigValue(application, configKey, account, configValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public boolean updateConfigValue(String configKey, String accountName, String configValue) {
|
public boolean updateConfigValue(ApplicationEntity application,String configKey, String accountName, String configValue) {
|
||||||
Account account = getAccount(accountName);
|
Account account = getAccount(accountName);
|
||||||
if (accountName == null) {
|
if (accountName == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -164,12 +166,12 @@ public class ConfigService implements Serializable {
|
|||||||
LOGGER.error("Account for usreName {} not found", accountName);
|
LOGGER.error("Account for usreName {} not found", accountName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updateConfigValue(configKey, account, configValue);
|
return updateConfigValue(application, configKey, account, configValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public boolean updateConfigValue(String configKey, Account account, String configValue) {
|
public boolean updateConfigValue(ApplicationEntity application, String configKey, Account account, String configValue) {
|
||||||
if ((configKey == null) || (configKey.equals("")) || (configValue == null) || (configValue.equals(""))) {
|
if ((configKey == null) || (configKey.equals("")) || (configValue == null) || (configValue.equals(""))) {
|
||||||
// null or empty key / values are not possible
|
// null or empty key / values are not possible
|
||||||
return false;
|
return false;
|
||||||
@ -181,7 +183,7 @@ public class ConfigService implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AccountEntity accountEntity = getAccount (account.getUsername());
|
AccountEntity accountEntity = getAccount (account.getUsername());
|
||||||
ConfigEntityPK pk = new ConfigEntityPK(configKey, accountEntity);
|
ConfigEntityPK pk = new ConfigEntityPK(application, configKey, accountEntity);
|
||||||
ConfigEntity currentEntity = em.find(ConfigEntity.class, pk);
|
ConfigEntity currentEntity = em.find(ConfigEntity.class, pk);
|
||||||
if (currentEntity == null) {
|
if (currentEntity == null) {
|
||||||
currentEntity = new ConfigEntity(pk);
|
currentEntity = new ConfigEntity(pk);
|
||||||
|
|||||||
@ -6,11 +6,14 @@
|
|||||||
package de.muehlencord.shared.account.business.config.entity;
|
package de.muehlencord.shared.account.business.config.entity;
|
||||||
|
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
|
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.EmbeddedId;
|
import javax.persistence.EmbeddedId;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.QueryHint;
|
import javax.persistence.QueryHint;
|
||||||
@ -34,15 +37,15 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|||||||
hints = {
|
hints = {
|
||||||
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
||||||
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")}),
|
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")}),
|
||||||
@NamedQuery(name = "ConfigEntity.findByConfigKey", query = "SELECT c FROM ConfigEntity c WHERE c.configPK.configKey = :configKey",
|
@NamedQuery(name = "ConfigEntity.findByConfigKey", query = "SELECT c FROM ConfigEntity c WHERE c.configPK.application = :application AND c.configPK.configKey = :configKey",
|
||||||
hints = {
|
hints = {
|
||||||
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
||||||
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")}),
|
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")}),
|
||||||
@NamedQuery(name = "ConfigEntity.findByConfigKeyAndAccount", query = "SELECT c FROM ConfigEntity c WHERE c.configPK.configKey = :configKey AND c.configPK.configKeyAccount = :account",
|
@NamedQuery(name = "ConfigEntity.findByConfigKeyAndAccount", query = "SELECT c FROM ConfigEntity c WHERE c.configPK.application = :application AND c.configPK.configKey = :configKey AND c.configPK.configKeyAccount = :account",
|
||||||
hints = {
|
hints = {
|
||||||
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
||||||
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")}),
|
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")}),
|
||||||
@NamedQuery(name = "ConfigEntity.findByConfigValue", query = "SELECT c FROM ConfigEntity c WHERE c.configValue = :configValue",
|
@NamedQuery(name = "ConfigEntity.findByConfigValue", query = "SELECT c FROM ConfigEntity c WHERE c.configPK.application = :application AND c.configValue = :configValue",
|
||||||
hints = {
|
hints = {
|
||||||
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
@QueryHint(name = "org.hibernate.cacheable", value = "true"),
|
||||||
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")})
|
@QueryHint(name = "org.hibernate.cacheRegion", value = "Queries")})
|
||||||
@ -59,13 +62,13 @@ public class ConfigEntity implements Serializable {
|
|||||||
private String configValue;
|
private String configValue;
|
||||||
@Size(max = 200)
|
@Size(max = 200)
|
||||||
@Column(name = "config_key_group")
|
@Column(name = "config_key_group")
|
||||||
private String configKeyGroup;
|
private String configKeyGroup;
|
||||||
|
|
||||||
public ConfigEntity() {
|
public ConfigEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigEntity(String configKey, AccountEntity account) {
|
public ConfigEntity(ApplicationEntity application, String configKey, AccountEntity account) {
|
||||||
this.configPK = new ConfigEntityPK(configKey, account);
|
this.configPK = new ConfigEntityPK(application, configKey, account);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigEntity(ConfigEntityPK configPK) {
|
public ConfigEntity(ConfigEntityPK configPK) {
|
||||||
@ -95,7 +98,7 @@ public class ConfigEntity implements Serializable {
|
|||||||
public void setConfigKeyGroup(String configKeyGroup) {
|
public void setConfigKeyGroup(String configKeyGroup) {
|
||||||
this.configKeyGroup = configKeyGroup;
|
this.configKeyGroup = configKeyGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
package de.muehlencord.shared.account.business.config.entity;
|
package de.muehlencord.shared.account.business.config.entity;
|
||||||
|
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
|
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -23,20 +24,25 @@ import javax.validation.constraints.Size;
|
|||||||
public class ConfigEntityPK implements Serializable {
|
public class ConfigEntityPK implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 8133795368429249008L;
|
private static final long serialVersionUID = 8133795368429249008L;
|
||||||
|
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 100)
|
@Size(min = 1, max = 100)
|
||||||
@Column(name = "config_key")
|
@Column(name = "config_key")
|
||||||
private String configKey;
|
private String configKey;
|
||||||
@JoinColumn(name = "config_key_account", referencedColumnName = "id")
|
@JoinColumn(name = "config_key_account", referencedColumnName = "id", insertable = false, updatable = false)
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
private AccountEntity configKeyAccount;
|
private AccountEntity configKeyAccount;
|
||||||
|
@JoinColumn(name = "application", referencedColumnName = "id", insertable = false, updatable = false)
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
private ApplicationEntity application;
|
||||||
|
|
||||||
public ConfigEntityPK() {
|
public ConfigEntityPK() {
|
||||||
|
// empty constructor required for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigEntityPK(String configKey, AccountEntity configKeyAccount) {
|
public ConfigEntityPK(ApplicationEntity application, String configKey, AccountEntity configKeyAccount) {
|
||||||
|
this.application = application;
|
||||||
this.configKey = configKey;
|
this.configKey = configKey;
|
||||||
this.configKeyAccount = configKeyAccount;
|
this.configKeyAccount = configKeyAccount;
|
||||||
}
|
}
|
||||||
@ -57,6 +63,14 @@ public class ConfigEntityPK implements Serializable {
|
|||||||
this.configKeyAccount = configKeyAccount;
|
this.configKeyAccount = configKeyAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApplicationEntity getApplication() {
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplication(ApplicationEntity application) {
|
||||||
|
this.application = application;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
@ -85,5 +99,5 @@ public class ConfigEntityPK implements Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "de.muehlencord.shared.account.business.config.entity.ConfigPK[ configKey=" + configKey + ", configKeyAccount=" + configKeyAccount + " ]";
|
return "de.muehlencord.shared.account.business.config.entity.ConfigPK[ configKey=" + configKey + ", configKeyAccount=" + configKeyAccount + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package de.muehlencord.shared.account.business.mail.boundary;
|
package de.muehlencord.shared.account.business.mail.boundary;
|
||||||
|
|
||||||
import de.muehlencord.shared.account.business.mail.entity.MailTemplateException;
|
import de.muehlencord.shared.account.business.mail.entity.MailTemplateException;
|
||||||
import de.muehlencord.shared.account.business.accountcounfig.entity.AccountConfigurationKey;
|
import de.muehlencord.shared.account.business.accountconfig.entity.AccountConfigurationKey;
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
|
import de.muehlencord.shared.account.business.account.entity.AccountLoginEntity;
|
||||||
import de.muehlencord.shared.account.business.mail.entity.MailDatamodel;
|
import de.muehlencord.shared.account.business.mail.entity.MailDatamodel;
|
||||||
import de.muehlencord.shared.account.business.mail.entity.MailException;
|
import de.muehlencord.shared.account.business.mail.entity.MailException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -22,7 +23,7 @@ import javax.mail.internet.MimeMessage;
|
|||||||
import javax.mail.internet.MimeMultipart;
|
import javax.mail.internet.MimeMultipart;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import de.muehlencord.shared.account.business.accountcounfig.entity.AccountConfigurationValue;
|
import de.muehlencord.shared.account.business.accountconfig.entity.AccountConfigurationValue;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -62,7 +63,14 @@ public class MailService implements Serializable {
|
|||||||
|
|
||||||
public String sendTestHtmlEmail(String recipient) throws MailException {
|
public String sendTestHtmlEmail(String recipient) throws MailException {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
AccountEntity account = new AccountEntity(UUID.randomUUID(), "joern.muehlencord", "joern@muehlencord.de", "Jörn", "Mühlencord", "secret", 0, "NEW", false, now, "admin", now, "admin");
|
AccountEntity account = new AccountEntity();
|
||||||
|
account.setId (UUID.randomUUID());
|
||||||
|
account.setFirstname("Jörn");
|
||||||
|
account.setLastname ("Mühlencord");
|
||||||
|
AccountLoginEntity accountLogin = new AccountLoginEntity();
|
||||||
|
accountLogin.setAccountPassword("secret");
|
||||||
|
accountLogin.setAccount(account);
|
||||||
|
account.setAccountLogin(accountLogin);
|
||||||
MailDatamodel dataModel = new MailDatamodel(account);
|
MailDatamodel dataModel = new MailDatamodel(account);
|
||||||
dataModel.addParameter("url", "http://url.de");
|
dataModel.addParameter("url", "http://url.de");
|
||||||
dataModel.addParameter("resetUrl", "http://reseturl.de");
|
dataModel.addParameter("resetUrl", "http://reseturl.de");
|
||||||
@ -181,7 +189,7 @@ public class MailService implements Serializable {
|
|||||||
String resetUrlWithToken = passwordResetUrl + "?token=" + token;
|
String resetUrlWithToken = passwordResetUrl + "?token=" + token;
|
||||||
model.addParameter("url", baseUrl);
|
model.addParameter("url", baseUrl);
|
||||||
model.addParameter("resetUrl", resetUrlWithToken);
|
model.addParameter("resetUrl", resetUrlWithToken);
|
||||||
return sendHTMLMail(account.getEmailaddress(), "Reset your password", model, "password_reset_html");
|
return sendHTMLMail(account.getAccountLogin().getEmailaddress(), "Reset your password", model, "password_reset_html");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String transportMail(Message message) throws MessagingException {
|
private String transportMail(Message message) throws MessagingException {
|
||||||
|
|||||||
@ -2,8 +2,11 @@
|
|||||||
package de.muehlencord.shared.account.business.config.boundary;
|
package de.muehlencord.shared.account.business.config.boundary;
|
||||||
|
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
|
import de.muehlencord.shared.account.business.account.entity.AccountLoginEntity;
|
||||||
|
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
|
import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK;
|
import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK;
|
||||||
|
import java.util.UUID;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -28,9 +31,18 @@ public class ConfigServiceTest {
|
|||||||
private EntityManager entityManagerMock;
|
private EntityManager entityManagerMock;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
AccountEntity account = new AccountEntity ("system");
|
ApplicationEntity application = new ApplicationEntity();
|
||||||
ConfigEntityPK pk = new ConfigEntityPK("account.maxFailedLogins", account);
|
application.setId(UUID.randomUUID());
|
||||||
|
application.setApplicationName("Test App");
|
||||||
|
|
||||||
|
AccountEntity account = new AccountEntity();
|
||||||
|
AccountLoginEntity login = new AccountLoginEntity();
|
||||||
|
login.setAccount (account);
|
||||||
|
login.setUsername("system");
|
||||||
|
account.setAccountLogin(login);
|
||||||
|
|
||||||
|
ConfigEntityPK pk = new ConfigEntityPK(application, "account.maxFailedLogins", account);
|
||||||
ConfigEntity configEntity = new ConfigEntity (pk);
|
ConfigEntity configEntity = new ConfigEntity (pk);
|
||||||
configEntity.setConfigValue("7");
|
configEntity.setConfigValue("7");
|
||||||
when (entityManagerMock.find(ConfigEntity.class, "account.maxFailedLogins")).thenReturn (configEntity);
|
when (entityManagerMock.find(ConfigEntity.class, "account.maxFailedLogins")).thenReturn (configEntity);
|
||||||
|
|||||||
Reference in New Issue
Block a user