package com.chenyang.nse.bussiness.kms.controller;

import com.chenyang.nse.bussiness.kms.model.Kms;
import com.chenyang.nse.bussiness.kms.service.KmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"kms"})
public class DataKeyController {
   protected Logger logger = LoggerFactory.getLogger(this.getClass());
   @Autowired
   protected KmsService kmsService;

   @RequestMapping({"datakey"})
   public String dataKey() {
      return this.kmsService.createDataKey(Kms.MasterKey.getInstance().getKeyid(), this.kmsService.obtainAccessToken(this.kmsService.obtainChallengeCode()));
   }
}
