|
@@ -1,7 +1,6 @@
|
|
package com.dragoninfo.dcuc.duceap.service.impl;
|
|
package com.dragoninfo.dcuc.duceap.service.impl;
|
|
|
|
|
|
-import com.dragoninfo.dcuc.common.exception.GmIntegrityException;
|
|
|
|
-import com.dragoninfo.dcuc.common.exception.GmNonRepudiationException;
|
|
|
|
|
|
+import com.dragoninfo.dcuc.common.utils.ResponseUtil;
|
|
import com.dragoninfo.dcuc.duceap.service.IGmVerifyService;
|
|
import com.dragoninfo.dcuc.duceap.service.IGmVerifyService;
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
@@ -13,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 国密算法校验service
|
|
* 国密算法校验service
|
|
|
|
+ *
|
|
* @author mazq
|
|
* @author mazq
|
|
* @date 2021/5/11
|
|
* @date 2021/5/11
|
|
*/
|
|
*/
|
|
@@ -20,19 +20,19 @@ import org.springframework.stereotype.Service;
|
|
public class GmVerifyServiceImpl implements IGmVerifyService {
|
|
public class GmVerifyServiceImpl implements IGmVerifyService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- SM2SignStrategy sm2SignStrategy;
|
|
|
|
|
|
+ private SM2SignStrategy sm2SignStrategy;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- SM3SignStrategy sm3SignStrategy;
|
|
|
|
|
|
+ private SM3SignStrategy sm3SignStrategy;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- SM4DESStrategy sm4DesStrategy;
|
|
|
|
|
|
+ private SM4DESStrategy sm4DesStrategy;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseStatus gmSm2Verify(String origin, String sign) {
|
|
public ResponseStatus gmSm2Verify(String origin, String sign) {
|
|
boolean verify = sm2SignStrategy.verify(origin, sign);
|
|
boolean verify = sm2SignStrategy.verify(origin, sign);
|
|
- if(!verify){
|
|
|
|
- throw new GmNonRepudiationException();
|
|
|
|
|
|
+ if (!verify) {
|
|
|
|
+ return ResponseStatus.fail();
|
|
}
|
|
}
|
|
return ResponseStatus.success();
|
|
return ResponseStatus.success();
|
|
}
|
|
}
|
|
@@ -40,21 +40,37 @@ public class GmVerifyServiceImpl implements IGmVerifyService {
|
|
@Override
|
|
@Override
|
|
public ResponseStatus gmSm3Verify(String origin, String digest) {
|
|
public ResponseStatus gmSm3Verify(String origin, String digest) {
|
|
boolean verify = sm3SignStrategy.verify(origin, digest);
|
|
boolean verify = sm3SignStrategy.verify(origin, digest);
|
|
- if(!verify){
|
|
|
|
- throw new GmIntegrityException();
|
|
|
|
|
|
+ if (!verify) {
|
|
|
|
+ return ResponseStatus.fail();
|
|
}
|
|
}
|
|
return ResponseStatus.success();
|
|
return ResponseStatus.success();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResponseDTO gmSm4Decode(String encode) {
|
|
|
|
|
|
+ public ResponseDTO<String> gmSm4Decode(String encode) {
|
|
String dec = sm4DesStrategy.dec(encode);
|
|
String dec = sm4DesStrategy.dec(encode);
|
|
- return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,dec);
|
|
|
|
|
|
+ return ResponseUtil.newInstance(dec);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResponseDTO gmSm4Encode(String origin) {
|
|
|
|
|
|
+ public ResponseDTO<String> gmSm4Encode(String origin) {
|
|
String enc = sm4DesStrategy.enc(origin);
|
|
String enc = sm4DesStrategy.enc(origin);
|
|
- return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,enc);
|
|
|
|
|
|
+ return ResponseUtil.newInstance(enc);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseDTO<String> gmSm2Sign(String origin) {
|
|
|
|
+
|
|
|
|
+ String sign = sm2SignStrategy.sign(origin);
|
|
|
|
+
|
|
|
|
+ return ResponseUtil.newInstance(sign);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseDTO<String> gmSm3Digest(String origin) {
|
|
|
|
+
|
|
|
|
+ String summary = sm3SignStrategy.summary(origin);
|
|
|
|
+
|
|
|
|
+ return ResponseUtil.newInstance(summary);
|
|
}
|
|
}
|
|
}
|
|
}
|