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

import com.chenyang.nse.bussiness.kms.model.Kms;
import com.chenyang.nse.bussiness.service.key.KeyManagerService;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class KmsRunner {
   @Autowired
   private KeyManagerService keyManagerService;

   public void init() throws Exception {
      Map<String, String> map = this.keyManagerService.showKeyParams("5");
      Kms.Credential.init((String)map.get("credtid"), (String)map.get("credaccesskey"), (String)map.get("credsecretkey"), (String)map.get("crediv"), (String)map.get("credprotocol"), (String)map.get("credhost"), Integer.parseInt((String)map.get("credport")));
      Kms.MasterKey.init((String)map.get("keyid"), (String)map.get("keyspec"), (String)map.get("keyusage"), (String)map.get("origin"), (String)map.get("protectionlevel"));
   }
}
