当前位置: 首页>>代码示例>>Java>>正文


Java DomainValidator类代码示例

本文整理汇总了Java中org.apache.commons.validator.routines.DomainValidator的典型用法代码示例。如果您正苦于以下问题:Java DomainValidator类的具体用法?Java DomainValidator怎么用?Java DomainValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DomainValidator类属于org.apache.commons.validator.routines包,在下文中一共展示了DomainValidator类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValidAuthorityHostNoDot

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
/**
 * Check if the authority contains a valid hostname without "."
 * characters and an optional port number
 * 
 * @param authority
 * @return <code>true</code> if the authority is valid
 */
private boolean isValidAuthorityHostNoDot(String authority) {
    Perl5Util authorityMatcher = new Perl5Util();
    if (authority != null
            && authorityMatcher.match(
                    "/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
        String hostIP = authorityMatcher.group(1);
        if (hostIP.indexOf('.') < 0) {
            // the hostname contains no dot, add domain validation to check invalid hostname like "g08fnstd110825-"
            DomainValidator domainValidator = DomainValidator.getInstance(true);
            if(!domainValidator.isValid(hostIP)) {
                return false;
            }
            String port = authorityMatcher.group(2);
            if (!isValidPort(port)) {
                return false;
            }
            String extra = authorityMatcher.group(3);
            return GenericValidator.isBlankOrNull(extra);
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:33,代码来源:ADMValidator.java

示例2: isValidAuthorityHostNoTld

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
/**
 * Check if the authority contains a hostname without top level domain
 * and an optional port number
 * 
 * @param authority
 * @return <code>true</code> if the authority is valid
 */
private boolean isValidAuthorityHostNoTld(String authority) {
    Perl5Util authorityMatcher = new Perl5Util();
    if (authority != null
            && authorityMatcher.match(
                    "/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
        String host = authorityMatcher.group(1);
        if (host.indexOf('.') > 0) {
            DomainValidator domainValidator = DomainValidator.getInstance();
            // Make the host have a valid TLD, so that the "no TLD" host can pass the domain validation.
            String patchedHost = host + ".com";
            if(!domainValidator.isValid(patchedHost)) {
                return false;
            }
            String port = authorityMatcher.group(2);
            if (!isValidPort(port)) {
                return false;
            }
            String extra = authorityMatcher.group(3);
            return GenericValidator.isBlankOrNull(extra);
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:ADMValidator.java

示例3: validateKaaHost

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public void validateKaaHost(String host) throws SandboxServiceException {
    if (host == null || host.length() == 0) {
        throw new SandboxServiceException("Kaa host field can not be empty!");
    } else if (!InetAddressValidator.getInstance().isValid(host) &&
            !DomainValidator.getInstance(true).isValid(host)) {
        throw new SandboxServiceException("Invalid hostname/ip address format!");
    }
}
 
开发者ID:kaaproject,项目名称:sandbox-frame,代码行数:10,代码来源:SandboxServiceImpl.java

示例4: validate

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
private void validate(APICreateL3NetworkMsg msg) {
    if (!L3NetworkType.hasType(msg.getType())) {
        throw new ApiMessageInterceptionException(argerr("unsupported l3network type[%s]", msg.getType()));
    }

    if (msg.getDnsDomain() != null) {
        DomainValidator validator = DomainValidator.getInstance();
        if (!validator.isValid(msg.getDnsDomain())) {
            throw new ApiMessageInterceptionException(argerr("%s is not a valid domain name", msg.getDnsDomain()));
        }
    }

    List<L3NetworkCategory> validNetworkCategory = Arrays.asList(L3NetworkCategory.values());
    for (L3NetworkCategory category : validNetworkCategory) {
        if (category.toString().equalsIgnoreCase(msg.getCategory())) {
            msg.setCategory(category.toString());
            break;
        }
    }

    if (L3NetworkCategory.checkSystemAndCategory(msg.isSystem(), L3NetworkCategory.valueOf(msg.getCategory()))) {
        return;
    } else {
        throw new ApiMessageInterceptionException(argerr("not valid combination of system and category," +
                "only %s are valid", L3NetworkCategory.validCombination));
    }

}
 
开发者ID:zstackio,项目名称:zstack,代码行数:29,代码来源:L3NetworkApiInterceptor.java

示例5: isValid

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public boolean isValid(String s) {
    if (s.matches("^.*://.*$")) {
        return org.apache.commons.validator.routines.UrlValidator.getInstance().isValid(s);
    } else {
        String[] parts = s.split("/");

        if (parts.length > 1) {
            return DomainValidator.getInstance().isValid(parts[0]);
        }
    }

    return DomainValidator.getInstance().isValid(s);
}
 
开发者ID:jsastrawi,项目名称:jsastrawi,代码行数:15,代码来源:UrlValidator.java

示例6: OutgoingEmailValidator

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Inject
OutgoingEmailValidator(@GerritServerConfig Config config) {
  String[] allowTLD = config.getStringList("sendemail", null, "allowTLD");
  if (allowTLD.length != 0) {
    try {
      DomainValidator.updateTLDOverride(GENERIC_PLUS, allowTLD);
    } catch (IllegalStateException e) {
      // Should only happen in tests, where the OutgoingEmailValidator
      // is instantiated repeatedly.
      log.error("Failed to update TLD override: " + e.getMessage());
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:OutgoingEmailValidator.java

示例7: expectDomainName

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
/**
 * Validates a field to be a valid IPv4 address
 *
 * @param name The field to check
 * @param message A custom error message instead of the default one
 */
public void expectDomainName(String name, String message) {
    String value = Optional.ofNullable(get(name)).orElse("");

    if (!DomainValidator.getInstance().isValid(value)) {
        addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.DOMAIN_NAME_KEY.name(), name)));
    }
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:14,代码来源:Validator.java

示例8: test

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public boolean test(String value) {
	return DomainValidator.getInstance().isValid(value);
}
 
开发者ID:i49,项目名称:hibiscus,代码行数:5,代码来源:HostnameFormat.java

示例9: matchesHostname

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
private static boolean matchesHostname(String value) {
	return DomainValidator.getInstance().isValid(value);
}
 
开发者ID:i49,项目名称:hibiscus,代码行数:4,代码来源:HostFormat.java

示例10: isValid

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public boolean isValid(final String domain, String attribute) {
    boolean allowLocal = ruleAnnotation.allowLocal();
    DomainValidator domainValidator = DomainValidator.getInstance(allowLocal);
    return domainValidator.isValid(domain);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:7,代码来源:DomainRule.java

示例11: isValidNonBlankValue

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public boolean isValidNonBlankValue(String value, ConstraintValidatorContext context) {
    return DomainValidator.getInstance().isValid(value);
}
 
开发者ID:britter,项目名称:bean-validators,代码行数:5,代码来源:DomainConstraintValidator.java

示例12: isValid

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public boolean isValid(String s) {
    return DomainValidator.getInstance().isValid(s);
}
 
开发者ID:jsastrawi,项目名称:jsastrawi,代码行数:5,代码来源:HostnameValidator.java

示例13: getPredicate

import org.apache.commons.validator.routines.DomainValidator; //导入依赖的package包/类
@Override
public Predicate<Object> getPredicate() {
  return domain -> DomainValidator.getInstance().isValid(domain == null?null:domain.toString());
}
 
开发者ID:apache,项目名称:metron,代码行数:5,代码来源:DomainValidation.java


注:本文中的org.apache.commons.validator.routines.DomainValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。