596afd76a7000ad0fb1427866db3f84d38ad4e93.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package com.kingdee.customer.Auth.handler;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.FileNotFoundException;
  5. import java.io.IOException;
  6. import java.util.Properties;
  7. import com.kingdee.bos.BOSException;
  8. import org.apache.commons.configuration.ConfigurationException;
  9. import org.apache.commons.configuration.PropertiesConfiguration;
  10. import org.apache.log4j.Logger;
  11. /**
  12. * @author dengzhouhong
  13. * @version 1.0.0
  14. * @ClassName ConfigAddressServletUtil.java
  15. * @Description TODO
  16. * @createTime 2024年04月29日 10:25
  17. */
  18. public class ConfigAddressServletUtil {
  19. private static Logger logger =
  20. Logger.getLogger(ConfigAddressServletUtil.class);
  21. static Properties prop = null;
  22. /**
  23. * 获取登陆邮箱信息
  24. * @param
  25. * @return
  26. * @throws IOException
  27. * @throws ConfigurationException
  28. * @throws BOSException
  29. */
  30. public static void getProperties()
  31. {
  32. String configFilePath= System.getProperty("eas.properties.dir")+ "/adSsoConfig.properties";
  33. logger.info("配置文件路径:"+configFilePath);
  34. System.out.println("配置文件路径:"+configFilePath);
  35. File configFile = new File(configFilePath);
  36. prop = new Properties();
  37. FileInputStream fin = null;
  38. try
  39. {
  40. //createPropertiesFileIfNotExist(configFile);
  41. fin = new FileInputStream(configFile);
  42. PropertiesConfiguration config = new PropertiesConfiguration();
  43. config.load(fin, "UTF-8");
  44. prop.setProperty("authUrl", config.getString("authUrl"));
  45. prop.setProperty("tokenUrl", config.getString("tokenUrl"));
  46. prop.setProperty("refreshTokenUrl", config.getString("refreshTokenUrl"));
  47. prop.setProperty("client_id", config.getString("client_id"));
  48. prop.setProperty("client_secret", config.getString("client_secret"));
  49. prop.setProperty("url", config.getString("shrUrl"));
  50. prop.setProperty("userUrl", config.getString("userUrl"));
  51. prop.setProperty("dataCenter", config.getString("dataCenter"));
  52. prop.setProperty("locale", config.getString("locale"));
  53. prop.setProperty("mobileEid", config.getString("mobileEid"));
  54. }
  55. catch (FileNotFoundException e) {
  56. logger.error("ConfigAddressUtil.....FileNotFoundException ",e);
  57. } catch (IOException e) {
  58. logger.error("ConfigAddressUtil.....IOException ",e);
  59. } catch (ConfigurationException e) {
  60. logger.error("ConfigAddressUtil.....ConfigurationException ",e);
  61. } finally {
  62. try {
  63. fin.close();
  64. } catch (IOException e) {
  65. logger.error("ConfigAddressUtil.....IOException ",e);
  66. }
  67. }
  68. }
  69. public static String getProperty(String fileName) {
  70. getProperties();
  71. return prop.getProperty(fileName);
  72. }
  73. }