本文整理匯總了Java中org.xbill.DNS.Name.labels方法的典型用法代碼示例。如果您正苦於以下問題:Java Name.labels方法的具體用法?Java Name.labels怎麽用?Java Name.labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xbill.DNS.Name
的用法示例。
在下文中一共展示了Name.labels方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nsecProvesNoWC
import org.xbill.DNS.Name; //導入方法依賴的package包/類
/**
* Determine if a NSEC record proves the non-existence of a wildcard that
* could have produced qname.
*
* @param nsec The nsec to check.
* @param qname The qname to check against.
* @param signerName The signer of the NSEC RRset.
* @return true if the NSEC proves the condition.
*/
public static boolean nsecProvesNoWC(NSECRecord nsec, Name qname, Name signerName) {
int qnameLabels = qname.labels();
Name ce = closestEncloser(qname, nsec);
int ceLabels = ce.labels();
for (int i = qnameLabels - ceLabels; i > 0; i--) {
Name wcName = qname.wild(i);
if (nsecProvesNameError(nsec, wcName, signerName)) {
return true;
}
}
return false;
}
示例2: processFindKey
import org.xbill.DNS.Name; //導入方法依賴的package包/類
/**
* Process the FINDKEY state. Generally this just calculates the next name
* to query and either issues a DS or a DNSKEY query. It will check to see
* if the correct key has already been reached, in which case it will
* advance the event to the next state.
*
* @param state The state associated with the current key finding phase.
*/
private void processFindKey(FindKeyState state) {
// We know that state.keyEntry is not a null or bad key -- if it were,
// then previous processing should have directed this event to a
// different state.
int qclass = state.qclass;
Name targetKeyName = state.signerName;
Name currentKeyName = Name.empty;
if (state.keyEntry != null) {
currentKeyName = state.keyEntry.getName();
}
if (state.currentDSKeyName != null) {
currentKeyName = state.currentDSKeyName;
state.currentDSKeyName = null;
}
// If our current key entry matches our target, then we are done.
if (currentKeyName.equals(targetKeyName)) {
return;
}
if (state.emptyDSName != null) {
currentKeyName = state.emptyDSName;
}
// Calculate the next lookup name.
int targetLabels = targetKeyName.labels();
int currentLabels = currentKeyName.labels();
int l = targetLabels - currentLabels - 1;
// the next key name would be trying to invent a name, so we stop here
if (l < 0) {
return;
}
Name nextKeyName = new Name(targetKeyName, l);
logger.trace("findKey: targetKeyName = " + targetKeyName + ", currentKeyName = " + currentKeyName + ", nextKeyName = " + nextKeyName);
// The next step is either to query for the next DS, or to query for the
// next DNSKEY.
if (state.dsRRset == null || !state.dsRRset.getName().equals(nextKeyName)) {
Message dsRequest = Message.newQuery(Record.newRecord(nextKeyName, Type.DS, qclass));
SMessage dsResponse = this.sendRequest(dsRequest);
this.processDSResponse(dsRequest, dsResponse, state);
return;
}
// Otherwise, it is time to query for the DNSKEY
Message dnskeyRequest = Message.newQuery(Record.newRecord(state.dsRRset.getName(), Type.DNSKEY, qclass));
SMessage dnskeyResponse = this.sendRequest(dnskeyRequest);
this.processDNSKEYResponse(dnskeyRequest, dnskeyResponse, state);
}
示例3: strictSubdomain
import org.xbill.DNS.Name; //導入方法依賴的package包/類
/**
* Is the first Name strictly a subdomain of the second name (i.e., below
* but not equal to).
*
* @param domain1 The first domain to process.
* @param domain2 The second domain to process.
* @return True when domain1 is a strict subdomain of domain2.
*/
public static boolean strictSubdomain(Name domain1, Name domain2) {
if (domain1.labels() <= domain2.labels()) {
return false;
}
return new Name(domain1, domain1.labels() - domain2.labels()).equals(domain2);
}
示例4: closestEncloser
import org.xbill.DNS.Name; //導入方法依賴的package包/類
/**
* Determines the 'closest encloser' - the name that has the most common
* labels between <code>domain</code> and ({@link NSECRecord#getName()} or
* {@link NSECRecord#getNext()}).
*
* @param domain The name for which the closest encloser is queried.
* @param nsec The covering {@link NSECRecord} to check.
* @return The closest encloser name of <code>domain</code> as defined by
* <code>nsec</code>.
*/
public static Name closestEncloser(Name domain, NSECRecord nsec) {
Name n1 = longestCommonName(domain, nsec.getName());
Name n2 = longestCommonName(domain, nsec.getNext());
return (n1.labels() > n2.labels()) ? n1 : n2;
}
示例5: nextClosest
import org.xbill.DNS.Name; //導入方法依賴的package包/類
/**
* Given a qname and its proven closest encloser, calculate the "next
* closest" name. Basically, this is the name that is one label longer than
* the closest encloser that is still a subdomain of qname.
*
* @param qname The qname.
* @param closestEncloser The closest encloser name.
* @return The next closer name.
*/
private Name nextClosest(Name qname, Name closestEncloser) {
int strip = qname.labels() - closestEncloser.labels() - 1;
return (strip > 0) ? new Name(qname, strip) : qname;
}