new field cert_dns_alt_names

This commit is contained in:
Peter Hormanns 2017-06-21 12:34:31 +02:00
parent d24c19f30a
commit 187bddaf8d
3 changed files with 25 additions and 5 deletions

View File

@ -1,9 +1,15 @@
INSERT INTO domain_option (domain_option_name) INSERT INTO domain_option (domain_option_name)
VALUES ('greylisting'); VALUES ('letsencrypt');
ALTER TABLE domain
ADD COLUMN cert_dns_alt_names CHARACTER VARYING(512);
UPDATE domain
SET cert_dns_alt_names = domain_name || ',www.' || domain_name ;
INSERT INTO contactrole_ref (contact_id, role) INSERT INTO contactrole_ref (contact_id, role)
( SELECT contact_id, 'voting-right' FROM contact ); ( SELECT contact_id, 'voting-right' FROM contact );
CREATE TABLE member_asset ( CREATE TABLE member_asset (
member_asset_id integer NOT NULL, member_asset_id integer NOT NULL,
bp_id integer NOT NULL, bp_id integer NOT NULL,

View File

@ -25,7 +25,6 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AnnModuleImpl; import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Domains") @Entity(name = "Domains")
@ -62,6 +61,9 @@ public class Domain extends AbstractEntity {
joinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")}, joinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")},
inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")}) inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")})
private Set<DomainOption> domainoptions; private Set<DomainOption> domainoptions;
@Column(name = "cert_dns_alt_names", columnDefinition = "character varying(512)")
private String certDNSAltNames;
public Domain() { public Domain() {
} }
@ -180,4 +182,12 @@ public class Domain extends AbstractEntity {
this.domainoptions = domainOptions; this.domainoptions = domainOptions;
} }
public String getCertDNSAltNames() {
return certDNSAltNames;
}
public void setCertDNSAltNames(String certDNSAltNames) {
this.certDNSAltNames = certDNSAltNames;
}
} }

View File

@ -111,7 +111,8 @@ public class DomainModuleImpl extends AbstractModuleImpl {
Domain dom = (Domain) newEntity; Domain dom = (Domain) newEntity;
Date now = new Date(); Date now = new Date();
dom.setSince(now); dom.setSince(now);
if (dom.getName() == null || dom.getName().length() == 0) { final String domName = dom.getName();
if (domName == null || domName.length() == 0) {
throw new HSAdminException("domain name required"); throw new HSAdminException("domain name required");
} }
UnixUser admin = dom.getUser(); UnixUser admin = dom.getUser();
@ -137,7 +138,7 @@ public class DomainModuleImpl extends AbstractModuleImpl {
boolean otherUserDomain = false; boolean otherUserDomain = false;
// search for domains superior to dom // search for domains superior to dom
Query domainQuery = em.createQuery("SELECT d FROM Domains d WHERE d.name = :domainName"); Query domainQuery = em.createQuery("SELECT d FROM Domains d WHERE d.name = :domainName");
String superior = dom.getName(); String superior = domName;
while (superior.contains(".") && !usersDomain) { while (superior.contains(".") && !usersDomain) {
superior = superior.substring(superior.indexOf('.') + 1); superior = superior.substring(superior.indexOf('.') + 1);
domainQuery.setParameter("domainName", superior); domainQuery.setParameter("domainName", superior);
@ -180,6 +181,9 @@ public class DomainModuleImpl extends AbstractModuleImpl {
} }
dom.setDomainoptions(domainOptions); dom.setDomainoptions(domainOptions);
} }
if (dom.getCertDNSAltNames() == null) {
dom.setCertDNSAltNames(domName + ",www." + domName);
}
if (dom.isPacDomain()) { if (dom.isPacDomain()) {
em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getName().substring(6) + "@hostsharing.net")); em.persist(new EMailAddress("owner", "", dom, dom.getUser().getPac().getCustomer().getName().substring(6) + "@hostsharing.net"));
em.persist(new EMailAddress("admin", "", dom, dom.getUser().getPac().getName() + "@hostsharing.net")); em.persist(new EMailAddress("admin", "", dom, dom.getUser().getPac().getName() + "@hostsharing.net"));