Skip to content

Commit 77db80c

Browse files
authored
Merge pull request #13 from HackTheOxidation/proxy
added proxy for ACL
2 parents cdbd76a + 37955b4 commit 77db80c

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed

src/main/java/printserver/server/EncryptedAuthenticator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected void addUser(String username, String password) throws NoSuchAlgorithmE
3232
public PrintServer authenticate(String username, String password) throws RemoteException {
3333
try {
3434
Login login = this.authenticateLogin(username, password);
35-
if(login.isAuthenticated()) return new PrintServant();
35+
if(login.isAuthenticated()) return new Proxy(db.getPriviligesForUser(username));
3636
} catch (Exception e) {
3737
System.out.println("DEBUG - authenticate: " + e.getMessage());
3838
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package printserver.server;
2+
3+
import java.rmi.RemoteException;
4+
import java.util.List;
5+
6+
public class Proxy extends PrintServant{
7+
static List<String> acl;
8+
9+
public Proxy(List<String> access) throws RemoteException {
10+
super();
11+
acl = access;
12+
}
13+
14+
@Override
15+
public void print(String filename, String printer) throws RemoteException {
16+
if (acl.contains("print")) {
17+
super.print(filename, printer);
18+
} else {
19+
System.out.println("Permission for print is denied");
20+
}
21+
}
22+
23+
@Override
24+
public void queue(String printer) throws RemoteException {
25+
if (acl.contains("queue")) {
26+
super.queue(printer);
27+
} else {
28+
System.out.println("Permission for queue is denied");
29+
}
30+
}
31+
32+
@Override
33+
public void topQueue(String printer, int job) throws RemoteException {
34+
if (acl.contains("topQueue")) {
35+
super.topQueue(printer, job);
36+
} else {
37+
System.out.println("Permission for topQueue is denied");
38+
}
39+
}
40+
41+
@Override
42+
public void start() throws RemoteException {
43+
if (acl.contains("start")) {
44+
super.start();
45+
} else {
46+
System.out.println("Permission for start is denied");
47+
}
48+
}
49+
50+
@Override
51+
public void stop() throws RemoteException {
52+
if (acl.contains("stop")) {
53+
super.stop();
54+
} else {
55+
System.out.println("Permission for stop is denied");
56+
}
57+
}
58+
59+
@Override
60+
public void restart() throws RemoteException {
61+
if (acl.contains("restart")) {
62+
super.restart();
63+
} else {
64+
System.out.println("Permission for restart is denied");
65+
}
66+
}
67+
68+
@Override
69+
public void status(String printer) throws RemoteException {
70+
if (acl.contains("status")) {
71+
super.status(printer);
72+
} else {
73+
System.out.println("Permission for status is denied");
74+
}
75+
}
76+
77+
@Override
78+
public void readConfig(String printer) throws RemoteException {
79+
if (acl.contains("readConfig")) {
80+
super.readConfig(printer);
81+
} else {
82+
System.out.println("Permission for readConfig is denied");
83+
}
84+
}
85+
86+
@Override
87+
public void setConfig(String printer, String value) throws RemoteException {
88+
if (acl.contains("setConfig")) {
89+
super.setConfig(printer, value);
90+
} else {
91+
System.out.println("Permission for setConfig is denied");
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)