本文整理汇总了Java中org.apache.commons.net.whois.WhoisClient类的典型用法代码示例。如果您正苦于以下问题:Java WhoisClient类的具体用法?Java WhoisClient怎么用?Java WhoisClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WhoisClient类属于org.apache.commons.net.whois包,在下文中一共展示了WhoisClient类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDomainImpl
import org.apache.commons.net.whois.WhoisClient; //导入依赖的package包/类
@Override
public Domain getDomainImpl(DomainName domainName) throws RDAPError {
try {
String tld = domainName.getTLDLabel().getStringValue();
WhoisClient whoisClient = new WhoisClient();
whoisClient.setDefaultTimeout(10000);
whoisClient.setConnectTimeout(5000);
whoisClient.connect("whois.nic." + tld, 43);
whoisClient.setSoTimeout(10000);
String query = domainName.getStringValue();
String whoisData = whoisClient.query(query);
if (StringUtils.strip(whoisData).startsWith(QUOTA_EXCEEDED)) {
throw new QuotaReachedError();
}
if (StringUtils.strip(whoisData).startsWith(NO_MATCH)) {
return null;
}
if (StringUtils.strip(whoisData).startsWith(DOMAIN_NOT_FOUND)) {
return null;
}
WhoisDomainParser parser = new WhoisDomainParser();
WhoisDomain whoisDomain = parser.parse(whoisData);
if (whoisDomain == null || whoisDomain.domain == null || StringUtils.isEmpty(whoisDomain.domain.uLabel)) {
throw new InternalServerError("Unrecognized result");
}
return convert(whoisDomain, tld);
} catch (IOException e) {
throw new InternalServerError(e.getMessage());
}
}
开发者ID:DNSBelgium,项目名称:rdap-server-sample-gtld,代码行数:31,代码来源:GtldWhoisService.java
示例2: getRegistrar
import org.apache.commons.net.whois.WhoisClient; //导入依赖的package包/类
private WhoisRegistrar getRegistrar(String tld, String registrar) throws RDAPError {
try {
WhoisClient whoisClient = new WhoisClient();
whoisClient.setDefaultTimeout(10000);
whoisClient.setConnectTimeout(5000);
whoisClient.connect("whois.nic." + tld, 43);
whoisClient.setSoTimeout(10000);
String query = "registrar " + registrar;
String whoisData = whoisClient.query(query);
if (StringUtils.strip(whoisData).startsWith(QUOTA_EXCEEDED)) {
throw new QuotaReachedError();
}
if (StringUtils.strip(whoisData).startsWith(NO_MATCH)) {
return null;
}
WhoisRegistrarListParser parser = new WhoisRegistrarListParser();
List<WhoisRegistrar> results = parser.parseResult(whoisData);
for (Iterator<WhoisRegistrar> iterator = results.iterator(); iterator.hasNext(); ) {
WhoisRegistrar whoisRegistrar = iterator.next();
if (!whoisRegistrar.name.equals(registrar)) {
iterator.remove();
}
}
if (results.isEmpty()) {
return null;
}
return results.iterator().next();
} catch (IOException e) {
throw new InternalServerError(e.getMessage());
}
}
开发者ID:DNSBelgium,项目名称:rdap-server-sample-gtld,代码行数:32,代码来源:GtldWhoisService.java
示例3: getHost
import org.apache.commons.net.whois.WhoisClient; //导入依赖的package包/类
private WhoisHost getHost(String tld, String host) throws RDAPError {
try {
WhoisClient whoisClient = new WhoisClient();
whoisClient.setDefaultTimeout(10000);
whoisClient.setConnectTimeout(5000);
whoisClient.connect("whois.nic." + tld, 43);
whoisClient.setSoTimeout(10000);
String query = "nameserver " + host;
String whoisData = whoisClient.query(query);
if (StringUtils.strip(whoisData).startsWith(QUOTA_EXCEEDED)) {
throw new QuotaReachedError();
}
if (StringUtils.strip(whoisData).startsWith(NO_MATCH)) {
return null;
}
WhoisHostListParser parser = new WhoisHostListParser();
List<WhoisHost> results = parser.parseResult(whoisData);
for (Iterator<WhoisHost> iterator = results.iterator(); iterator.hasNext(); ) {
WhoisHost whoisHost = iterator.next();
if (!whoisHost.name.equals(host)) {
iterator.remove();
}
}
if (results.isEmpty()) {
return null;
}
return results.iterator().next();
} catch (IOException e) {
throw new InternalServerError(e.getMessage());
}
}
开发者ID:DNSBelgium,项目名称:rdap-server-sample-gtld,代码行数:32,代码来源:GtldWhoisService.java
示例4: NetnameUpdater
import org.apache.commons.net.whois.WhoisClient; //导入依赖的package包/类
public NetnameUpdater(TypedProperties props) {
this.props = props;
this.whoisClient = new WhoisClient();
this.matcher = Pattern.compile(NETNAME_REG_EXP, Pattern.MULTILINE).matcher("");
}
开发者ID:cert-se,项目名称:megatron-java,代码行数:6,代码来源:NetnameUpdater.java
注:本文中的org.apache.commons.net.whois.WhoisClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论