if (cid == null) {
log.debug("verifyCEID - No CID in the XRD");
return Status.CID_FAILED;
}
XRI cidX;
try {
cidX = XRI.fromURINormalForm(cid.getValue());
}
catch (Exception e) {
log.debug("verifyCEID - Unable to parse CID");
return Status.CID_FAILED;
}
if (ceid.getValue().equals(cid.getValue())) {
log.debug("verifyCEID - CID is character-for-character equivalent to CEID.");
return Status.CID_VERIFIED;
}
try {
XRI ceidX = XRI.fromURINormalForm(ceid.getValue());
log.info("verifyCEID - resolving CEID");
XRD ceidXRD = resolveAuthToXRD(ceidX, flags, state);
Status s = ceidXRD.getStatus();
if (!s.getCID().equals(Status.CID_VERIFIED)) {
log.debug("verifyCEID - XRD for CEID is not CID verified");
return Status.CID_FAILED;
}
CanonicalID cid2 = ceidXRD.getCanonicalID();
if (cid2 == null) {
log.debug("verifyCEID - no CID in the XRD in CEID");
return Status.CID_FAILED;
}
XRI cidX2 = XRI.fromURINormalForm(cid2.getValue());
if (!cidX2.toURINormalForm().equals(cidX.toURINormalForm())) {
log.debug("verifyCEID - CEID's XRD's CID is not equivalent to the original CID");
return Status.CID_FAILED;
}
/// look for an EquivID or CanonicalEquivID backpointer to the original CID
CanonicalEquivID ceid2 = ceidXRD.getCanonicalEquivID();
XRI ceidX2 = XRI.fromURINormalForm(ceid2.getValue());
if (ceidX2.toURINormalForm().equals(cidX.toURINormalForm())) {
log.debug("verifyCEID - CEID backpointer found");
return Status.CID_VERIFIED;
}
for (int i = 0; i < ceidXRD.getNumEquivIDs(); i++) {
EquivID e = ceidXRD.getEquivIDAt(i);
XRI eX = XRI.fromURINormalForm(e.getValue());
if (eX.toURINormalForm().equals(cidX.toURINormalForm())) {
log.debug("verifyCEID - EquivID backpointer found");
return Status.CID_VERIFIED;
}
}
}