当前位置: 首页>>代码示例>>Java>>正文


Java Association.verifySignature方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:79,代码来源:ServerManager.java

示例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);
        }
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:64,代码来源:OpenIDServerManager.java


注:本文中的org.openid4java.association.Association.verifySignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。