- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT memid, domain FROM `domains` WHERE id=? AND deleted IS NULL");
- ps.setInt(1, id);
-
- GigiResultSet rs = ps.executeQuery();
- if ( !rs.next()) {
- throw new IllegalArgumentException("Invalid domain id " + id);
- }
- this.id = id;
- owner = User.getById(rs.getInt(1));
- suffix = rs.getString(2);
- rs.close();
- }
-
- public Domain(User owner, String suffix) throws GigiApiException {
- checkCertifyableDomain(suffix, owner.isInGroup(Group.CODESIGNING));
- this.owner = owner;
- this.suffix = suffix;
-
- }
-
- public static void checkCertifyableDomain(String s, boolean hasPunycodeRight) throws GigiApiException {
- String[] parts = s.split("\\.", -1);
- if (parts.length < 2) {
- throw new GigiApiException("Domain does not contain '.'.");
- }
- for (int i = parts.length - 1; i >= 0; i--) {
- if ( !isVaildDomainPart(parts[i], hasPunycodeRight)) {
- throw new GigiApiException("Syntax error in Domain");
- }
- }
- String publicSuffix = PublicSuffixes.getInstance().getRegistrablePart(s);
- if ( !s.equals(publicSuffix)) {
- throw new GigiApiException("You may only register a domain with exactly one lable before the public suffix.");
- }
- checkPunycode(parts[0], s.substring(parts[0].length() + 1));
- }