# RunServices - Local Run Set Up 🕐2022/8/18 [toc] > 此文件說明如何設定及使用IDEA來執行runServices > 此文件的內容與[Package CASB - Windos&Linux](https://hackmd.io/@TheresaLiao/SkJ0jtV1s)有95%的部分一樣,剩下的5%會在此文件中特別標示:sparkles: ## Environment Setup (Windows) - **Install Java and Maven** - **Java** [[Download](https://www.oracle.com/java/technologies/downloads/#java8-windows)] - **Java SE Development Kit 8u341** - **Maven** [[Download](https://maven.apache.org/download.cgi)] - Download **Binary zip archive** and unzip - Set environment variables - **M2_HOME** Set the path where you unzip your Maven - **PATH** Add the following path to **PATH**: ``` %M2_HOME%\bin ``` ## Prerequisites - **Import Dependencies** - **Miro-1.2** - Go to `casb\artifact` and execute the following command: ```shell mvn install:install-file -DgroupId=org.itri.byoc -DartifactId=Miro -Dversion=1.2 -Dpackaging=jar -Dfile=./Miro-1.2.jar ``` - **RLM** - Go to `casb\RLM ` and execute the following command: ```shell mvn install:install-file -DgroupId=com.reprisesoftware.rlm -DartifactId=Rlm -Dversion=1421 -Dpackaging=jar -Dfile=./rlm1421.jar ``` - **Set up the Logo** - Copy `casb\win\src\main\resources\ITRI_icons\logo20.png` to `casb\win\src\main\resources\default_icons`. - **Required Files** - Copy following files to `casb\win\casb` 此步驟需要準備好以下檔案,並複製到`casb\win\casb`底下 - `casb.lic` > 直接從預先產生好的License選擇「尚未到期」的license,檔名記得改成casb.lic。 - `casb\RLM\rlm1421.dll` - `casb.jks` (For CASB) - 使用Java Keytool產生的Self-signed Certificate,可以沿用剛剛產生的casb.jks。 - `localhost.jks` (For H2 Server and CASB Admin) - Generate the file according to [#Generate localhost.jks](https://hackmd.io/KC946vnTQC-rAPpv2caWfw?view#Generate-localhostjks). - 使用Java Keytool產生的Self-signed Certificate,CN=127.0.0.1 - `casb\win\innoSetup\s3proxy.conf` :sparkles: - Set `s3proxy.secure-endpoint=https://127.0.0.1:443` > You can check the default setting of `s3proxy.conf` [here](https://github.com/ITRI-ICLX-DNN/casb/wiki/Set-up-CASB-configuration-file#s3proxyconf) . - Unzip `solr.zip` to `casb\win\solr`. - 不需要設定Bundled JRE :sparkles: 製作安裝檔的時候才需要。 - **Compile CASB, CASB Admin and runServices** > - **此步驟用來進行「編譯」並把編譯後的executable jar及相關檔案複製到win資料夾底下對應的位置。** > - 在[Package CASB - Windos&Linux](https://hackmd.io/@TheresaLiao/SkJ0jtV1s)中,以下步驟可以透過自動化腳本`casb\win\package_inno.cmd`來完成。 :sparkles: > - 此自動化腳本可以完成編譯、檔案複製、製作執行檔、打包安裝檔等動作。 - **CASB** ```shell cd <path\to>\casb mvn package -Dmaven.test.skip=true -Dmaven.javadoc.skip=true copy /y target\s3proxy win\casb ``` - **CASB Admin** ```shell cd <path\to>\casb\casbAdmin mvn package if not exist "..\win\casbAdmin\" mkdir ..\win\casbAdmin copy /y target\casbAdmin-jar-with-dependencies.jar ..\win\casbAdmin Xcopy /E /I /y src\main\webapp ..\win\casbAdmin\src\main\webapp\ ``` - **runServices** ```shell cd <path\to>\casb\win mvn package copy /y casb\localhost.jks casbAdmin\casb.jks ``` - **Set up the IDEA Project** - Go to the the directory that contains `pom.xml` and execute the following command: ``` mvn idea:idea ``` It will create the `ipr` file. - **IDEA** Run/Debug Configurations - **Main Class** ``` org.itri.Main ``` - **Program arguments**: 無須修改 - **Working directory**: 無須修改 ### Run - 開啟 IDEA Project - 執行程式 --- ## Appendix ### Generate localhost.jks > This keystore is used by H2 Server and CASB Admin. > > - Alias: **casb_localhost** > - File name: localhost.jks > - KeyStore Password: changeit > - Validity: 365 days ```shell keytool -genkeypair -alias casb_localhost -keystore localhost.jks -keyalg RSA -validity 365 -storepass changeit -keypass changeit 您的名字與姓氏為何? [Unknown]: 127.0.0.1 您的組織單位名稱為何? [Unknown]: 您的組織名稱為何? [Unknown]: 您所在的城市或地區名稱為何? [Unknown]: 您所在的州及省份名稱為何? [Unknown]: 此單位的兩個字母國別代碼為何? [Unknown]: CN=127.0.0.1, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown 正確嗎? [否]: y ``` - Export the Public Key Certificate :sparkles: ```shell keytool -export -keystore localhost.jks -alias casb_localhost -file localhost.cer -storepass changeit ``` - Import the certificate to the JDK TrustStore :sparkles: ```shell keytool -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -importcert -alias casb_localhost -file localhost.cer -trustcacerts -keypass changeit -storepass changeit ``` ###### tags: `CASB`