code: private <T extends AlipayResponse> void checkResponseSign(AlipayRequest<T> request,
                                                                AlipayParser<T> parser,
                                                                String responseBody,
                                                                boolean responseIsSucess) throws AlipayApiException {
          // 针对成功结果且有支付宝公钥的进行验签
          if (!StringUtils.isEmpty(this.alipayPublicKey)) {
  
              SignItem signItem = parser.getSignItem(request, responseBody);
  
              if (signItem == null) {
  
                  throw new AlipayApiException("sign check fail: Body is Empty!");
              }
  
              if (responseIsSucess
                  || (!responseIsSucess && !StringUtils.isEmpty(signItem.getSign()))) {
  
                  boolean rsaCheckContent = AlipaySignature.rsaCheck(signItem.getSignSourceDate(),
                      signItem.getSign(), this.alipayPublicKey, this.charset, this.signType);
  
                  if (!rsaCheckContent) {
  
                      // 针对JSON \/问题，替换/后再尝试做一次验证
                      if (!StringUtils.isEmpty(signItem.getSignSourceDate())
                          && signItem.getSignSourceDate().contains("\\/")) {
  
                          String srouceData = signItem.getSignSourceDate().replace("\\/", "/");
  
                          boolean jsonCheck = AlipaySignature.rsaCheck(srouceData, signItem.getSign(),
                              this.alipayPublicKey, this.charset, this.signType);
  
                          if (!jsonCheck) {
                              throw new AlipayApiException(
                                  "sign check fail: check Sign and Data Fail！JSON also！");
                          }
                      } else {
  
                          throw new AlipayApiException("sign check fail: check Sign and Data Fail!");
                      }
                  }
              }
  
          }
      }
docs: 检查响应签名
  
  @param request
  @param parser
  @param responseBody
  @param responseIsSucess
  @throws AlipayApiException