use of com.bsnbase.sdk.util.algorithm.AlgorithmTypeContext in project PCNGateway-Java-SDK by BSNDA.
the class BaseResArrayModel method verify.
@Override
public boolean verify() throws Exception {
String signValue = (this.header == null ? "" : this.header.getHeaderString());
for (int i = 0; i < this.body.size(); i++) {
signValue += this.body.get(i).getEncryptionValue();
}
AlgorithmTypeEnum algorithmTypeEnum = AlgorithmTypeEnum.fromAlgorithmTypeEnum(Config.config.getAppInfo().getAlgorithmType());
AlgorithmTypeContext algorithmTypeContext = new AlgorithmTypeContext(algorithmTypeEnum);
boolean verify = algorithmTypeContext.getAlgorithmTypeHandle().verify(PublicConfig.getPublicKey(algorithmTypeEnum), this.mac, signValue);
return verify;
}
use of com.bsnbase.sdk.util.algorithm.AlgorithmTypeContext in project PCNGateway-Java-SDK by BSNDA.
the class BaseResModel method verify.
/**
* Gateway returns the result of signature verfication
*/
@Override
public boolean verify() throws Exception {
String signValue = (this.header == null ? "" : this.header.getHeaderString()) + (this.body == null ? "" : this.body.getEncryptionValue());
AlgorithmTypeEnum algorithmTypeEnum = AlgorithmTypeEnum.fromAlgorithmTypeEnum(Config.config.getAppInfo().getAlgorithmType());
AlgorithmTypeContext algorithmTypeContext = new AlgorithmTypeContext(algorithmTypeEnum);
boolean verify = algorithmTypeContext.getAlgorithmTypeHandle().verify(PublicConfig.getPublicKey(algorithmTypeEnum), this.mac, signValue);
return verify;
}
use of com.bsnbase.sdk.util.algorithm.AlgorithmTypeContext in project PCNGateway-Java-SDK by BSNDA.
the class StoreUtils method generateCSR.
/**
* csr generation
*
* @param name
* @param appCode
* @return
*/
public static UserCertInfo generateCSR(String name, String appCode) {
try {
String DN = "CN=" + Common.getCNName(name, appCode) + ",OU=client";
AlgorithmTypeEnum algorithmTypeEnum = AlgorithmTypeEnum.fromAlgorithmTypeEnum(Config.config.getAppInfo().getAlgorithmType());
AlgorithmTypeContext algorithmTypeContext = new AlgorithmTypeContext(algorithmTypeEnum);
UserCertInfo certInfo = algorithmTypeContext.getAlgorithmTypeHandle().getUserCertInfo(DN);
if (Objects.isNull(certInfo)) {
throw new GlobalException(ResultInfoEnum.ALGORITHM_TYPE_ERROR);
}
return certInfo;
} catch (Exception e) {
logger.error("Get CSR Exception", e);
throw new GlobalException("Get CSR Exception");
}
}
use of com.bsnbase.sdk.util.algorithm.AlgorithmTypeContext in project PCNGateway-Java-SDK by BSNDA.
the class BaseReqModel method sign.
/**
* The request gateway calls the "sign" method
*/
@Override
public void sign() throws Exception {
if (this.header == null) {
throw new GlobalException(ResultInfoEnum.REQUEST_HEADER_ERROR);
}
String signValue = this.header.getHeaderString();
if (this.body != null) {
signValue += this.body.getEncryptionValue();
}
AlgorithmTypeEnum algorithmTypeEnum = AlgorithmTypeEnum.fromAlgorithmTypeEnum(Config.config.getAppInfo().getAlgorithmType());
AlgorithmTypeContext algorithmTypeContext = new AlgorithmTypeContext(algorithmTypeEnum);
String sign = algorithmTypeContext.getAlgorithmTypeHandle().sign(Config.config.getPrk(), signValue);
this.mac = sign;
}
Aggregations