本文整理汇总了Java中org.openid4java.association.Association.verifySignature方法的典型用法代码示例。如果您正苦于以下问题:Java Association.verifySignature方法的具体用法?Java Association.verifySignature怎么用?Java Association.verifySignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openid4java.association.Association
的用法示例。
在下文中一共展示了Association.verifySignature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verify
import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
* Responds to a verification request from the consumer.
*
* @param requestParams ParameterList containing the parameters received
* in a verification request from a consumer site.
* @return VerificationResponse to be sent back to the
* consumer site.
*/
public Message verify(ParameterList requestParams)
{
_log.info("Processing verification request...");
boolean isVersion2 = true;
try
{
// build request message from response params (+ ntegrity check)
VerifyRequest vrfyReq = VerifyRequest.createVerifyRequest(requestParams);
isVersion2 = vrfyReq.isVersion2();
String handle = vrfyReq.getHandle();
boolean verified = false;
Association assoc = _privateAssociations.load(handle);
if (_checkPrivateSharedAssociations && _sharedAssociations.load(handle) != null)
{
_log.warn("association for handle: " + handle + " expected to be private " +
"but was found in shared association store, denying direct verification request; " +
"please configure different association store/instances for private vs shared associations");
}
else if (assoc != null)
{
// verify the signature
_log.info("Loaded private association; handle: " + handle);
verified = assoc.verifySignature(
vrfyReq.getSignedText(),
vrfyReq.getSignature());
// remove the association so that the request
// cannot be verified more than once
_privateAssociations.remove(handle);
}
VerifyResponse vrfyResp =
VerifyResponse.createVerifyResponse(! vrfyReq.isVersion2());
vrfyResp.setSignatureVerified(verified);
if (verified)
{
String invalidateHandle = vrfyReq.getInvalidateHandle();
if (invalidateHandle != null &&
_sharedAssociations.load(invalidateHandle) == null) {
_log.info("Confirming shared association invalidate handle: "
+ invalidateHandle);
vrfyResp.setInvalidateHandle(invalidateHandle);
}
}
else
_log.error("Signature verification failed, handle: " + handle);
_log.info("Responding with " + (verified? "positive" : "negative")
+ " verification response");
return vrfyResp;
}
catch (OpenIDException e)
{
_log.error("Error processing verification request; " +
"responding with verification error.", e);
return DirectError.createDirectError(e, ! isVersion2);
}
}
示例2: verify
import org.openid4java.association.Association; //导入方法依赖的package包/类
public Message verify(ParameterList requestParams) {
if(log.isDebugEnabled()) {
log.debug("Processing verification request...");
}
boolean isVersion2 = true;
try {
// build request message from response params (+ ntegrity check)
VerifyRequest vrfyReq = VerifyRequest.createVerifyRequest(requestParams);
isVersion2 = vrfyReq.isVersion2();
String handle = vrfyReq.getHandle();
boolean verified = false;
Association assoc = getPrivateAssociations().load(handle);
String sigMod = null;
if (assoc != null) { // verify the signature
if (log.isDebugEnabled()) {
log.debug("Loaded private association; handle: " + handle);
}
sigMod = vrfyReq.getSignature().replaceAll("\\s", "+");
verified = assoc.verifySignature(vrfyReq.getSignedText(), sigMod);
// remove the association so that the request
// cannot be verified more than once
getPrivateAssociations().remove(handle);
} else {
log.error("No association loaded from the database; handle: " + handle);
}
VerifyResponse vrfyResp =
VerifyResponse.createVerifyResponse(!vrfyReq.isVersion2());
vrfyResp.setSignatureVerified(verified);
if (verified) {
String invalidateHandle = vrfyReq.getInvalidateHandle();
if (invalidateHandle != null &&
getSharedAssociations().load(invalidateHandle) == null) {
if (log.isDebugEnabled()) {
log.debug("Shared association invalidated; handle: " + invalidateHandle);
}
vrfyResp.setInvalidateHandle(invalidateHandle);
}
} else {
log.error("Signature verification failed. handle : " + handle +
" , signed text : " + vrfyReq.getSignedText() +
" , signature : " + sigMod);
}
if (log.isDebugEnabled()) {
log.debug("Responding with " + (verified ? "positive" : "negative") + " verification response");
}
return vrfyResp;
} catch (OpenIDException e) {
log.error("Error processing verification request; responding with verification error", e);
return DirectError.createDirectError(e, !isVersion2);
}
}