All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alipay.api.DefaultSignChecker Maven / Gradle / Ivy

Go to download

Alipay openapi SDK for Java Copyright © 2018 杭州蚂蚁金服 All rights reserved. 版权所有 (C)杭州蚂蚁金服 http://open.alipay.com

There is a newer version: 4.39.218.ALL
Show newest version
/**
 * Alipay.com Inc. Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.alipay.api;

import com.alipay.api.internal.util.AlipaySignature;

/**
 * @author liuqun.lq
 * @version $Id: DefaultSignChecker.java, v 0.1 2018年07月03日 12:06 liuqun.lq Exp $
 */
public class DefaultSignChecker implements SignChecker {

    private String alipayPublicKey;

    public DefaultSignChecker(String alipayPublicKey) {
        this.alipayPublicKey = alipayPublicKey;
    }

    public boolean check(String sourceContent, String signature, String signType, String charset) {
        boolean success = false;
        try {
            success = AlipaySignature.rsaCheck(sourceContent, signature, alipayPublicKey, charset, signType);
        } catch (AlipayApiException e) {
            throw new RuntimeException(e);
        }
        return success;
    }

    public boolean checkCert(String sourceContent, String signature, String signType, String charset, String publicKey) {
        boolean success = false;
        try {
            success = AlipaySignature.rsaCheck(sourceContent, signature, publicKey, charset, signType);
        } catch (AlipayApiException e) {
            throw new RuntimeException(e);
        }
        return success;
    }

    /**
     * Getter method for property alipayPublicKey.
     *
     * @return property value of alipayPublicKey
     */
    public String getAlipayPublicKey() {
        return alipayPublicKey;
    }

    /**
     * Setter method for property alipayPublicKey.
     *
     * @param alipayPublicKey value to be assigned to property alipayPublicKey
     */
    public void setAlipayPublicKey(String alipayPublicKey) {
        this.alipayPublicKey = alipayPublicKey;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy