EsignConfig.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package com.kingdee.eas.custom.esign.util;
  2. import com.kingdee.eas.custom.esign.bizEnum.EsignConfigEnum;
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8. import java.util.Properties;
  9. import java.util.Set;
  10. public class EsignConfig {
  11. private Properties propt = new Properties();//共用参数
  12. private static EsignConfig instance = new EsignConfig();
  13. public static EsignConfig getInstance() {
  14. return instance;
  15. }
  16. // 应用ID
  17. public String getEsignAppId() {
  18. return this.propt.getProperty(EsignConfigEnum.ESIGNAPPID_VALUE);
  19. }
  20. // 应用密钥
  21. public String getEsignAppSecret() {
  22. return this.propt.getProperty(EsignConfigEnum.ESIGNAPPSECRET_VALUE);
  23. }
  24. // e签宝接口调用域名(模拟环境)
  25. //"https://smlopenapi.esign.cn";
  26. // e签宝接口调用域名(正式环境)
  27. //"https://openapi.esign.cn";
  28. public String getEsignHost() {
  29. return this.propt.getProperty(EsignConfigEnum.ESIGNHOST_VALUE);
  30. }
  31. public String get(String key) {
  32. return this.propt.getProperty(key);
  33. }
  34. private EsignConfig() {
  35. this.initConfig("/server/properties/esign/esignConfig.properties");
  36. }
  37. public void initConfig(String filePath) {
  38. try {
  39. InputStreamReader reader = new InputStreamReader(
  40. new FileInputStream(System.getProperty("EAS_HOME") + filePath),
  41. "GBK");
  42. this.propt.load(reader);
  43. } catch (IOException e) {
  44. e.printStackTrace();
  45. }
  46. }
  47. public Map<String, String> getConfig() {
  48. Map<String, String> map = new HashMap<>();
  49. Set<Map.Entry<Object, Object>> set = this.propt.entrySet();
  50. for (Map.Entry<Object, Object> entry : set) {
  51. map.put((String) entry.getKey(), (String) entry.getValue());
  52. }
  53. return map;
  54. }
  55. }