add DomainSetup-HostingAssets for new BookingItem via created-event #111
@ -1,10 +1,13 @@
|
||||
|
||||
package net.hostsharing.hsadminng.hs.booking.item.validators;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItem;
|
||||
import net.hostsharing.hsadminng.hs.validation.PropertiesProvider;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.hosting.asset.validators.Dns.REGISTRAR_LEVEL_DOMAINS;
|
||||
import static net.hostsharing.hsadminng.hs.validation.StringProperty.stringProperty;
|
||||
@ -32,6 +35,19 @@ class HsDomainSetupBookingItemValidator extends HsBookingItemEntityValidator {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> validateEntity(final HsBookingItem bookingItem) {
|
||||
final var violations = new ArrayList<String>();
|
||||
final var domainName = bookingItem.getDirectValue(DOMAIN_NAME_PROPERTY_NAME, String.class);
|
||||
if (!bookingItem.isLoaded() &&
|
||||
domainName.matches("hostsharing.(com|net|org|coop|de)")) {
|
||||
violations.add("'" + bookingItem.toShortString() + ".resources." + DOMAIN_NAME_PROPERTY_NAME + "' = '" + domainName
|
||||
+ "' is a forbidden Hostsharing domain name");
|
||||
}
|
||||
violations.addAll(super.validateEntity(bookingItem));
|
||||
return violations;
|
||||
}
|
||||
|
||||
private static String generateVerificationCode(final EntityManager em, final PropertiesProvider propertiesProvider) {
|
||||
final var userDefinedVerificationCode = propertiesProvider.getDirectValue(VERIFICATION_CODE_PROPERTY_NAME, String.class);
|
||||
if (userDefinedVerificationCode != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user