Skip to content

Commit a6ed84d

Browse files
authored
Create Server.java
1 parent e87f823 commit a6ed84d

File tree

1 file changed

+44
-0
lines changed
  • software design and architecture/access control system

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Dummy implementation
2+
import org.springframework.stereotype.Service;
3+
4+
@Service
5+
public class AccessControlService {
6+
7+
public HTTPStatus doPost(JSONObject json) {
8+
String data = deocodeRFIDSignature(json.get("user"));
9+
User user = fetchUserData(data)
10+
Door door = fetchDoorData(json.get("hostname"));
11+
if (door.getPermittedGroups.contains(user.getGroup())) {
12+
logAccessRequest(...);
13+
return HTTPStatus.OK;
14+
}
15+
16+
logAccessRequest(...);
17+
return HTTPStatus.UNAUTHORIZED;
18+
}
19+
20+
// Log access requests
21+
public void logAccessRequest(String userId, String doorId, boolean accessGranted, String timestamp) {
22+
Service loggingService = getServiceUrlFromRegistry("LoggingService");
23+
loggingService.send(userId, doorId, accessGranted, timestamp);
24+
}
25+
26+
// Decoding Service: Decodes the RFID signature retrieved from the scanned data
27+
public String decodeRFIDSignature(String scannedData) {
28+
Service decodingService = getServiceUrlFromRegistry("DecodingService");
29+
return decodedService.decode(scannedData);
30+
}
31+
32+
// User Service: Fetches user data, including organizational group membership
33+
public User fetchUserData(String userId) {
34+
Service userService = getServiceUrlFromRegistry("UserService");
35+
return userService.get(userId);
36+
}
37+
38+
// Door Service: Retrieves door-specific data, including organizational group access permissions
39+
public Door fetchDoorData(String doorId) {
40+
Service doorService = getServiceUrlFromRegistry("DoorService");
41+
return doorService.get(doorId);
42+
}
43+
44+
}

0 commit comments

Comments
 (0)