https://github.com/acile067/project_oib_smart_meter
Projekat iz predmeta Osnove informacione bezbednosti IS (oib). Pametno brojilo.
https://github.com/acile067/project_oib_smart_meter
certificates cssharp ftn groups-manager json rbac securtiy users wcf windows
Last synced: 6 months ago
JSON representation
Projekat iz predmeta Osnove informacione bezbednosti IS (oib). Pametno brojilo.
- Host: GitHub
- URL: https://github.com/acile067/project_oib_smart_meter
- Owner: Acile067
- Created: 2024-12-08T15:06:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-04T14:59:43.000Z (over 1 year ago)
- Last Synced: 2025-04-03T11:45:34.293Z (over 1 year ago)
- Topics: certificates, cssharp, ftn, groups-manager, json, rbac, securtiy, users, wcf, windows
- Language: C#
- Homepage:
- Size: 206 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Smart Meter
Developed as a project for the course 'Fundamentals of Information Security', the system processes smart meter readings and stores data on the recorded consumption. Security is achieved through the use of certificates, RBAC (Role-Based Access Control), and an event logger.
## Built using
-
.NET 8
## Installation:
1. **Install .NET SDK**:
Download and install the .NET SDK 8.0 for your operating system from [here](https://dotnet.microsoft.com/en-us/download/dotnet/8.0).
2. **Verify installation**:
Run the following command in your terminal to confirm:
```bash
dotnet --list-sdks
```
## How to run:
Preparation:
### 1. Create Users and Groups
1. **Navigate to**:
**Computer Management** → **Local Users and Groups**
2. **Create Users**:
- **Administrator1** (password: `1234`)
- **Operator1** (password: `1234`)
- **SuperAdministrator1** (password: `1234`)
- **MainService** (password: `1234`)
- **LoadBalancer** (password: `1234`)
- **Worker1** (password: `1234`)
- **Worker2** (password: `1234`)
3. **Create Groups**:
- **Admin** → Add **Administrator1**
- **Operator** → Add **Operator1**
- **Super-administrator** → Add **SuperAdministrator1**
---
### 2. Create and Install Certificates
1. **Locate `makecert.exe`**:
Navigate to `C:\Program Files (x86)\Windows Kits\10\bin` and find the folder corresponding to your version (e.g., `\10.0.22621.0\x86`).
2. **Open Command Prompt**:
Run **Command Prompt** as Administrator and move to the directory with `makecert.exe`:
```bash
cd "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86"
```
---
### 3. Generate Certificates:
- Self-Signed Certificate:
```bash
makecert -n "CN=TestCA" -r -sv TestCA.pvk TestCA.cer
```
- Worker and LoadBalancer Certificates:
Generate `.pvk` and `.cer` files:
```bash
makecert -sv Worker1.pvk -iv TestCA.pvk -n "CN=Worker1" -pe -ic TestCA.cer Worker1.cer -sr localmachine -ss My -sky exchange
```
```bash
makecert -sv Worker2.pvk -iv TestCA.pvk -n "CN=Worker2" -pe -ic TestCA.cer Worker2.cer -sr localmachine -ss My -sky exchange
```
```bash
makecert -sv LoadBalancer.pvk -iv TestCA.pvk -n "CN=LoadBalancer" -pe -ic TestCA.cer LoadBalancer.cer -sr localmachine -ss My -sky exchange
```
Generate .pfx Files:
```bash
pvk2pfx.exe /pvk Worker1.pvk /pi 1234 /spc Worker1.cer /pfx Worker1.pfx
```
```bash
pvk2pfx.exe /pvk Worker2.pvk /pi 1234 /spc Worker2.cer /pfx Worker2.pfx
```
```bash
pvk2pfx.exe /pvk LoadBalancer.pvk /pi 1234 /spc LoadBalancer.cer /pfx LoadBalancer.pfx
```
---
### 4. Install Certificates:
#### TestCA Certificate
1. Locate `TestCA.cer`, double-click, and choose **Install Certificate**.
2. Select **Local Machine** → Place in **Trusted Root Certification Authorities** → Next → Finish.
---
#### Worker and LoadBalancer Certificates
1. Locate `.pfx` files (e.g., `Worker1.pfx`), double-click, and follow these steps:
- Select **Local Machine**.
- Enter password `1234`.
- Check **Mark this key as exportable**.
- Place in **Personal** store.
2. Locate `.cer` files (e.g., `Worker1.cer`), double-click, and follow these steps:
- Select **Local Machine**.
- Place in **Trusted People**.
- Click Finish.
3. Repeat these steps for `Worker2` and `LoadBalancer`.
---
### 5. Manage Certificates in MMC:
1. Open MMC:
- Press `Windows + R`, type `mmc`, and hit Enter.
2. Add Certificates Snap-in:
- Go to **File** → **Add/Remove Snap-ins**.
- Select **Certificates**.
- Choose **Computer Account** → **Local Computer** → Finish.
3. Configure Worker1 Certificate:
- Locate `Worker1` under **Personal > Certificates**.
- Right-click the certificate → Select **Manage Private Keys**.
- Add `Worker1` user → Click OK.
4. Repeat these steps for `Worker2` and `LoadBalancer`.
---
Run:
### 1. Clone the project:
Clone the repository and navigate to the appropriate directory:
```bash
git clone https://github.com/Acile067/Project_OIB_Smart_Meter.git
cd Project_OIB_Smart_Meter/Smart_Meter
```
### 2. Build the Project
#### Build using MSVC:
1. Open the **Developer Command Prompt for VS 2022**.
2. Build the project using the following command:
```bash
msbuild Smart_Meter.sln /p:Configuration=Debug /p:Platform=x64
```
### 3. Set Security Permissions
1. Navigate to the `Project_OIB_Smart_Meter` folder.
2. Right-click on the `Smart_Meter` folder → Select **Properties**.
3. Go to the **Security** tab and add all created users with **Full Control** permissions.
### 4. Run the Project
#### Important Notes:
- **First-Time Run:** The service must be run as an administrator the first time to allow it to create the Event Log File.
- For subsequent runs, use the specific accounts mentioned below.
#### Steps:
1. **Run the Service**:
- Navigate to: `\Smart_Meter\Service\bin\Debug`.
- Hold **Shift + Right-Click** on `Service.exe` → Select **Run as different user**.
- For the **first run**, select the **Administrator** account. For subsequent runs, use the **MainService** account.
2. **Run the Load Balancer**:
- Navigate to: `\Smart_Meter\LoadBalancer\bin\Debug`.
- Hold **Shift + Right-Click** on `LoadBalancer.exe` → Select **Run as different user** → Use the **LoadBalancer** account.
3. **Run Workers**:
- Navigate to: `\Smart_Meter\Worker\bin\Debug`.
- Hold **Shift + Right-Click** on `Worker.exe` → Select **Run as different user**.
- Run two instances:
- One using the **Worker1** account.
- One using the **Worker2** account.
4. **Run Clients**:
- Navigate to: `\Smart_Meter\Client\bin\Debug`.
- Hold **Shift + Right-Click** on `Client.exe` → Select **Run as different user**.
- Run instances using the following accounts:
- **Administrator1**
- **SuperAdministrator1**
- **Operator1**