9 |
|
|
10 |
|
// add some test rules |
11 |
|
acl.add(ACL.ALLOW, "*.ukc.ac.uk"); |
12 |
< |
acl.add(ACL.ALLOW, "129.12.*"); |
12 |
> |
acl.add(ACL.ALLOW, "129.12.*.*"); |
13 |
|
acl.add(ACL.ALLOW, "*.bishnet.net"); |
14 |
|
acl.add(ACL.ALLOW, "192.168.*"); |
15 |
+ |
acl.add(ACL.ALLOW, "192.168.*.*"); |
16 |
+ |
acl.add(ACL.ALLOW, "one.two.three.four.five.six.*"); |
17 |
+ |
acl.add(ACL.ALLOW, "192.129.12.*.*"); |
18 |
+ |
acl.add(ACL.ALLOW, "129.12.*"); |
19 |
+ |
acl.add(ACL.ALLOW, "129.12.4"); |
20 |
+ |
acl.add(ACL.ALLOW, "129.*"); |
21 |
+ |
acl.add(ACL.ALLOW, "129*"); |
22 |
+ |
acl.add(ACL.ALLOW, "*"); |
23 |
+ |
acl.add(ACL.ALLOW, ""); |
24 |
|
// not really needed if we default to deny :) |
25 |
|
//acl.add(ACL.DENY, "*"); |
26 |
|
|
27 |
< |
// dump our ACL to the console |
28 |
< |
System.out.println(acl.getStringACL()); |
27 |
> |
// dump our ACL to the console before serialization |
28 |
> |
System.out.println("BEFORE: " + acl); |
29 |
> |
|
30 |
> |
// name for our serialized ACL |
31 |
> |
String aclFilename = "aclfile"; |
32 |
> |
|
33 |
> |
// write out our ACL to a file |
34 |
> |
try { |
35 |
> |
ObjectOutputStream ostream = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(aclFilename))); |
36 |
> |
ostream.writeObject(acl); |
37 |
> |
ostream.flush(); |
38 |
> |
ostream.close(); |
39 |
> |
} |
40 |
> |
catch (Exception e) { |
41 |
> |
System.out.println("exception: " + e); |
42 |
> |
e.printStackTrace(); |
43 |
> |
System.exit(1); |
44 |
> |
} |
45 |
> |
|
46 |
> |
// and read it back in :) |
47 |
> |
try { |
48 |
> |
ObjectInputStream istream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(aclFilename))); |
49 |
> |
acl = (ACL) istream.readObject(); |
50 |
> |
istream.close(); |
51 |
> |
} |
52 |
> |
catch (Exception e) { |
53 |
> |
System.out.println("exception: " + e); |
54 |
> |
e.printStackTrace(); |
55 |
> |
System.exit(1); |
56 |
> |
} |
57 |
> |
|
58 |
> |
// dump our ACL to the console after serialization |
59 |
> |
System.out.println("AFTER: " + acl); |
60 |
|
|
61 |
|
// run a few tests |
62 |
|
System.out.println("killigrew.ukc.ac.uk: " + acl.check("killigrew.ukc.ac.uk")); |