functions need implement before 07/12

This commit is contained in:
cheney 2022-07-08 17:32:07 +08:00
parent 0b8f61675a
commit 78ed1cd553
5 changed files with 130 additions and 59 deletions

48
pom.xml
View File

@ -8,9 +8,7 @@
<artifactId>1</artifactId>
<version>1.0</version>
<name>1</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<name>sydapi-database</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -28,48 +26,6 @@
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,30 @@
package com.sunyard;
public class SydApiException extends RuntimeException {
// 错误编码
private int retCode;
// 错误消息
private String msg;
public SydApiException(int retCode, String msg) {
this.retCode = retCode;
this.msg = msg;
}
public int getRetCode() {
return retCode;
}
public String getMsg() {
return msg;
}
@Override
public String toString() {
return "SydApiException{" +
"retCode=" + retCode +
", msg='" + msg + '\'' +
'}';
}
}

View File

@ -1,13 +0,0 @@
package com.sunyard.sge.database;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,64 @@
package com.sunyard.sge.database;
import java.util.List;
/**
* 上海黄金交易所 - 数据库加密方案
*
*/
public interface SydApi
{
/**
* 建立到指定地址和端口号的签名服务器的 TCP/IP 连接返回 API 操作对象 SydApi
* 如果采用短连接交易结束要调用 SydApi 的方法SYD_Disconnect_Ex 进行释放连接
*
* @param pcIpList 签名服务器的IP地址
* @param iPortList 签名服务器的端口号
* @param iConnectTimeOut 连接超时单位毫秒
* @param iDealTimeOut 交易接口超时设定单位毫秒(不超过10ms)
* @return SydApi 的对象只要有设备可用则返回
*/
SydApi SYD_Connect_Ex(
String[] pcIpList,
int[] iPortList,
int iConnectTimeOut,
int iDealTimeOut
);
/**
* 关闭与签名服务器的TCP/IP连接
*/
void SYD_Disconnect_Ex();
/**
* 对指定数据进行SM4加解密处理
* @param iKeyIndex 会话密钥索引值
* @param pcData 报文密文或明文
* @param iFlag 加解密标识,0:表示ECB解密1:表示ECB加密
* @return 报文明文或密文
*/
byte[] SYD_SM4_ShortData(
int iKeyIndex,
byte[] pcData,
int iFlag
);
/**
* 对指定批量数据进行SM4加解密处理
*
* @param iKeyIndex 会话密钥索引值数组
* @param pcData 要加密的报文明文或密文数组
* @param iFlag 加解密标识,0:表示ECB解密1:表示ECB加密
* @return List<byte[]>对象List 的长度与输入参数 pcData 的长度相同
*/
List<byte[]> SYD_SM4_BatchData(
int[] iKeyIndex,
List<byte[]> pcData,
int iFlag
);
}

View File

@ -0,0 +1,34 @@
package com.sunyard.sge.database;
import java.util.List;
/**
* 上海黄金交易所 - 数据库加密方案
*
*/
public class SydApi4Database implements SydApi
{
@Override
public SydApi SYD_Connect_Ex(String[] pcIpList, int[] iPortList, int iConnectTimeOut, int iDealTimeOut) {
return null;
}
@Override
public void SYD_Disconnect_Ex() {
}
@Override
public byte[] SYD_SM4_ShortData(int iKeyIndex, byte[] pcData, int iFlag) {
return new byte[0];
}
@Override
public List<byte[]> SYD_SM4_BatchData(int[] iKeyIndex, List<byte[]> pcData, int iFlag) {
return null;
}
}