Merge branch 'dev' into 'master'
Dev See merge request eshop/biz_service_ebtp_extend!27
This commit is contained in:
@ -0,0 +1,36 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.bizmessage.controller;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1")
|
||||||
|
public class AuthorizeController {
|
||||||
|
|
||||||
|
private @Autowired IBaseCacheUserService service;
|
||||||
|
|
||||||
|
@GetMapping("user")
|
||||||
|
@ResponseStatus(code = HttpStatus.OK)
|
||||||
|
public Object user(Principal principal) {
|
||||||
|
BaseCacheUser cacheUser = service.getCacheUser();
|
||||||
|
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
System.out.println(auth.getName());
|
||||||
|
System.out.println(auth.getAuthorities());
|
||||||
|
System.out.println(principal);
|
||||||
|
|
||||||
|
return cacheUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -64,7 +64,21 @@ public class TimeServiceConstant {
|
|||||||
* @param timestamp 时间戳加密原文
|
* @param timestamp 时间戳加密原文
|
||||||
* @return 时间戳对象
|
* @return 时间戳对象
|
||||||
*/
|
*/
|
||||||
public TSAVerifyResult verifyTimeStamp(String timestamp){
|
public TtsAgent.TtsParseResult verifyTimeStamp2(String timestamp){
|
||||||
|
try{
|
||||||
|
log.info("timestamp -->"+timestamp);
|
||||||
|
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
|
||||||
|
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(verifyResult.getSignedTime());
|
||||||
|
TtsAgent.TtsParseResult ttsParseResult = new TtsAgent.TtsParseResult(time, HelperUtil.bytesToHexString(verifyResult.getData()),
|
||||||
|
verifyResult.getSignerSubject());
|
||||||
|
return ttsParseResult;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("解析时间戳", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TSAVerifyResult verifyTimeStamp(String timestamp){
|
||||||
try{
|
try{
|
||||||
log.info("timestamp -->"+timestamp);
|
log.info("timestamp -->"+timestamp);
|
||||||
TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp));
|
TSAVerifyResult verifyResult = client.verifyTimeStamp(Base64.decodeBase64(timestamp));
|
||||||
@ -83,10 +97,7 @@ public class TimeServiceConstant {
|
|||||||
public TtsAgent.TtsParseResult getServiceTimeObj(String data){
|
public TtsAgent.TtsParseResult getServiceTimeObj(String data){
|
||||||
try{
|
try{
|
||||||
String timestamp = this.signTimeStamp(data);
|
String timestamp = this.signTimeStamp(data);
|
||||||
TSAVerifyResult verifyResult = this.verifyTimeStamp(timestamp);
|
TtsAgent.TtsParseResult ttsParseResult = this.verifyTimeStamp2(timestamp);
|
||||||
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(verifyResult.getSignedTime());
|
|
||||||
TtsAgent.TtsParseResult ttsParseResult = new TtsAgent.TtsParseResult(time, HelperUtil.bytesToHexString(verifyResult.getData()),
|
|
||||||
verifyResult.getSignerSubject());
|
|
||||||
return ttsParseResult;
|
return ttsParseResult;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("获取时间戳异常", e);
|
log.error("获取时间戳异常", e);
|
||||||
@ -145,7 +156,8 @@ public class TimeServiceConstant {
|
|||||||
.setDate(date.getDate())
|
.setDate(date.getDate())
|
||||||
.setHour(date.getHours())
|
.setHour(date.getHours())
|
||||||
.setMinute(date.getMinutes())
|
.setMinute(date.getMinutes())
|
||||||
.setSecond(date.getSeconds());
|
.setSecond(date.getSeconds())
|
||||||
|
.setTimestamp(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
|
||||||
return systemTime;
|
return systemTime;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("获取时间戳异常", e);
|
log.error("获取时间戳异常", e);
|
||||||
|
@ -40,9 +40,9 @@ public class TimeServiceController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("解析时间戳加密原文")
|
@ApiOperation("解析时间戳加密原文")
|
||||||
@GetMapping(value = "/verifyTimeStamp")
|
@GetMapping(value = "/verifyTimeStamp")
|
||||||
public BaseResponse<TSAVerifyResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
public BaseResponse<TtsAgent.TtsParseResult> verifyTimeStamp(@ApiParam(value = "时间戳加密原文", required = true) @RequestBody String timestamp) {
|
||||||
TimeServiceConstant constant = new TimeServiceConstant();
|
TimeServiceConstant constant = new TimeServiceConstant();
|
||||||
return BaseResponse.success(constant.verifyTimeStamp(timestamp));
|
return BaseResponse.success(constant.verifyTimeStamp2(timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,8 +11,10 @@ import lombok.experimental.Accessors;
|
|||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SystemTime {
|
public class SystemTime {
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private String timestamp;
|
||||||
/**
|
/**
|
||||||
* 年
|
* 年
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package com.chinaunicom.mall.ebtp.extend.timeService.tsa;
|
package com.chinaunicom.mall.ebtp.extend.timeService.tsa;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CA 时间戳服务接口
|
* CA 时间戳服务接口
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user