"null assertion or discovered information.");
return result;
}
Identifier claimedId = discovered.isVersion2() ?
_discovery.parseIdentifier(authResp.getClaimed()) : //may have frag
discovered.getClaimedIdentifier(); //assert id may be delegate in v1
String handle = authResp.getHandle();
URL op = discovered.getOPEndpoint();
Association assoc = _associations.load(op.toString(), handle);
if (assoc != null) // association available, local verification
{
_log.info("Found association: " + assoc.getHandle() +
" verifying signature locally...");
String text = authResp.getSignedText();
String signature = authResp.getSignature();
if (assoc.verifySignature(text, signature))
{
result.setVerifiedId(claimedId);
if (DEBUG) _log.debug("Local signature verification succeeded.");
}
else if (DEBUG)
{
_log.debug("Local signature verification failed.");
result.setStatusMsg("Local signature verification failed");
}
}
else // no association, verify with the OP
{
_log.info("No association found, " +
"contacting the OP for direct verification...");
VerifyRequest vrfy = VerifyRequest.createVerifyRequest(authResp);
ParameterList responseParams = new ParameterList();
int respCode = call(op.toString(), vrfy, responseParams);
if (HttpStatus.SC_OK == respCode)
{
VerifyResponse vrfyResp =
VerifyResponse.createVerifyResponse(responseParams);
vrfyResp.validate();
if (vrfyResp.isSignatureVerified())
{
// process the optional invalidate_handle first
String invalidateHandle = vrfyResp.getInvalidateHandle();
if (invalidateHandle != null)
_associations.remove(op.toString(), invalidateHandle);
result.setVerifiedId(claimedId);
if (DEBUG)
_log.debug("Direct signature verification succeeded " +
"with OP: " + op);
}
else
{
if (DEBUG)
_log.debug("Direct signature verification failed " +
"with OP: " + op);
result.setStatusMsg("Direct signature verification failed.");
}
}
else
{
DirectError err = DirectError.createDirectError(responseParams);
if (DEBUG) _log.debug("Error verifying signature with the OP: "
+ op + " error message: " + err.keyValueFormEncoding());
result.setStatusMsg("Error verifying signature with the OP: "
+ err.getErrorMsg());
}
}
Identifier verifiedID = result.getVerifiedId();
if (verifiedID != null)
_log.info("Verification succeeded for: " + verifiedID);
else
_log.error("Verification failed for: " + authResp.getClaimed()