| .. | .. |
|---|
| 9 | 9 | |
|---|
| 10 | 10 | import javax.inject.Named; |
|---|
| 11 | 11 | import javax.inject.Singleton; |
|---|
| 12 | +import javax.sql.DataSource; |
|---|
| 12 | 13 | import javax.ws.rs.core.UriBuilder; |
|---|
| 13 | 14 | import javax.ws.rs.core.UriBuilderException; |
|---|
| 14 | 15 | |
|---|
| 16 | +import org.h2.jdbcx.JdbcDataSource; |
|---|
| 15 | 17 | import org.slf4j.Logger; |
|---|
| 16 | 18 | import org.slf4j.LoggerFactory; |
|---|
| 17 | 19 | |
|---|
| .. | .. |
|---|
| 31 | 33 | } |
|---|
| 32 | 34 | |
|---|
| 33 | 35 | public String getPassword() { |
|---|
| 34 | | - return getFilePassword() + " " + "cur1s1nt3grity"; |
|---|
| 36 | + return getFilePassword() + " " + "53curi5"; |
|---|
| 35 | 37 | } |
|---|
| 36 | 38 | |
|---|
| 37 | 39 | public String getFilePassword() { |
|---|
| .. | .. |
|---|
| 39 | 41 | } |
|---|
| 40 | 42 | |
|---|
| 41 | 43 | public String getUrl(File appDir) { |
|---|
| 42 | | - return String.format("jdbc:h2:%s/db/curisintegrity_cs;CIPHER=AES", appDir.getAbsolutePath()); |
|---|
| 44 | + return String.format("jdbc:h2:%s/db/securis;CIPHER=AES", appDir.getAbsolutePath()); |
|---|
| 43 | 45 | } |
|---|
| 44 | 46 | |
|---|
| 45 | 47 | @Named("base-uri") |
|---|
| .. | .. |
|---|
| 77 | 79 | return Arrays.asList("/db/schema.sql"); |
|---|
| 78 | 80 | } |
|---|
| 79 | 81 | |
|---|
| 80 | | - // @Provides |
|---|
| 81 | | - // @Singleton |
|---|
| 82 | | - // public HelloWorld provideHelloWorld() { |
|---|
| 83 | | - // if (args.length > 0 && args[0].equals("fi")) { |
|---|
| 84 | | - // return new HelloWorldFI(); |
|---|
| 85 | | - // } else { |
|---|
| 86 | | - // return new HelloWorldPL(); |
|---|
| 87 | | - // } |
|---|
| 88 | | - // } |
|---|
| 82 | + @Named("temporary-dir") |
|---|
| 83 | + @Provides |
|---|
| 84 | + @Singleton |
|---|
| 85 | + public File getTemporaryDir() { |
|---|
| 86 | + String tmp = getAppDir().getAbsolutePath(); |
|---|
| 87 | + tmp += File.separator + ".TEMP"; |
|---|
| 88 | + File ftmp = new File(tmp); |
|---|
| 89 | + if (!ftmp.exists()) { |
|---|
| 90 | + if (!ftmp.mkdirs()) |
|---|
| 91 | + return null; |
|---|
| 92 | + log.debug("Created temporary directory for app in: {}", ftmp.getAbsolutePath()); |
|---|
| 93 | + ftmp.deleteOnExit(); |
|---|
| 94 | + } |
|---|
| 95 | + return ftmp; |
|---|
| 96 | + } |
|---|
| 97 | + |
|---|
| 98 | + @Named("app-dir") |
|---|
| 99 | + @Provides |
|---|
| 100 | + @Singleton |
|---|
| 101 | + public File getAppDir() { |
|---|
| 102 | + String appDir = System.getProperty("user.home", System.getProperty("user.dir")); |
|---|
| 103 | + if (appDir == null) { |
|---|
| 104 | + appDir = "."; |
|---|
| 105 | + } |
|---|
| 106 | + appDir += File.separator + ".SeCuris"; |
|---|
| 107 | + File fAppDir = new File(appDir); |
|---|
| 108 | + if (!fAppDir.exists()) { |
|---|
| 109 | + if (!fAppDir.mkdirs()) |
|---|
| 110 | + return null; |
|---|
| 111 | + log.debug("Created app working directory app in: {}", fAppDir.getAbsolutePath()); |
|---|
| 112 | + } |
|---|
| 113 | + return fAppDir; |
|---|
| 114 | + } |
|---|
| 115 | + |
|---|
| 116 | + @Named("support-email") |
|---|
| 117 | + @Provides |
|---|
| 118 | + @Singleton |
|---|
| 119 | + public String getSupportEmail() { |
|---|
| 120 | + return "integrity@curistec.com"; |
|---|
| 121 | + } |
|---|
| 122 | + |
|---|
| 123 | + @Named("hash-logo") |
|---|
| 124 | + @Provides |
|---|
| 125 | + @Singleton |
|---|
| 126 | + public String getHashLogo() { |
|---|
| 127 | + return "1b42616809d4cd8ccf109e3c30d0ab25067f160b30b7354a08ddd563de0096ba"; |
|---|
| 128 | + } |
|---|
| 129 | + |
|---|
| 130 | + @Named("license-req-file-name") |
|---|
| 131 | + @Provides |
|---|
| 132 | + @Singleton |
|---|
| 133 | + public String getLicenseReqFileName() { |
|---|
| 134 | + return "license.req"; |
|---|
| 135 | + } |
|---|
| 136 | + |
|---|
| 137 | + @Named("license-file-name") |
|---|
| 138 | + @Provides |
|---|
| 139 | + @Singleton |
|---|
| 140 | + public String getLicenseFileName() { |
|---|
| 141 | + return "license.lic"; |
|---|
| 142 | + } |
|---|
| 143 | + |
|---|
| 144 | + @Provides |
|---|
| 145 | + @Singleton |
|---|
| 146 | + public DataSource getDataSource(@Named("app-dir") File appDir) { |
|---|
| 147 | + |
|---|
| 148 | + JdbcDataSource dataSource = new JdbcDataSource(); |
|---|
| 149 | + dataSource.setURL(getUrl(appDir)); |
|---|
| 150 | + dataSource.setUser("curis"); |
|---|
| 151 | + dataSource.setPassword(getPassword()); |
|---|
| 152 | + log.debug("JdbcDataSource: {}", dataSource); |
|---|
| 153 | + return dataSource; |
|---|
| 154 | + } |
|---|
| 155 | + |
|---|
| 156 | + @Named("db-files") |
|---|
| 157 | + @Provides |
|---|
| 158 | + @Singleton |
|---|
| 159 | + public List<String> getDbFiles() { |
|---|
| 160 | + return getAppDbFiles(); |
|---|
| 161 | + } |
|---|
| 89 | 162 | |
|---|
| 90 | 163 | } |
|---|