| 7f5c7c4 by kpreid at 2006-07-20 |
1 |
package org.erights.e.elib.sealing; |
|
2 |
|
|
3 |
/* |
|
4 |
The contents of this file are subject to the Electric Communities E Open |
|
5 |
Source Code License Version 1.0 (the "License"); you may not use this file |
|
6 |
except in compliance with the License. You may obtain a copy of the License |
|
7 |
at http://www.communities.com/EL/. |
|
8 |
|
|
9 |
Software distributed under the License is distributed on an "AS IS" basis, |
|
10 |
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for |
|
11 |
the specific language governing rights and limitations under the License. |
|
12 |
|
|
13 |
The Original Code is the Distributed E Language Implementation, released |
|
14 |
July 20, 1998. |
|
15 |
|
|
16 |
The Initial Developer of the Original Code is Electric Communities. |
|
17 |
Copyright (C) 1998 Electric Communities. All Rights Reserved. |
|
18 |
|
|
19 |
Contributor(s): ______________________________________. |
|
20 |
*/ |
|
21 |
|
|
22 |
import org.erights.e.elib.serial.PassByProxy; |
|
23 |
import org.erights.e.elib.serial.Persistent; |
|
24 |
|
|
25 |
/** |
| 1b3a04f by markm at 2006-11-17 |
26 |
* Carries a reference, but reveals it only to one who has this Brand's |
|
27 |
* Unsealer. |
| 7f5c7c4 by kpreid at 2006-07-20 |
28 |
* |
|
29 |
* @author Mark S. Miller |
|
30 |
*/ |
| fdf9643 by markm at 2007-03-26 |
31 |
public final class SealedBox implements PassByProxy, Persistent { |
| 7f5c7c4 by kpreid at 2006-07-20 |
32 |
|
| cc958bb by markm at 2007-01-08 |
33 |
static private final long serialVersionUID = 6068151750277696015L; |
|
34 |
|
| 7f5c7c4 by kpreid at 2006-07-20 |
35 |
/** |
|
36 |
* @serial The capability I encapsulate. |
|
37 |
*/ |
|
38 |
final Object myContents; |
|
39 |
|
|
40 |
/** |
| 1b3a04f by markm at 2006-11-17 |
41 |
* @serial The Brand of the {@link Sealer} that sealed this box, and |
|
42 |
* therefore the Brand of the {@link Unsealer} required to obtain |
|
43 |
* myContents. |
| 7f5c7c4 by kpreid at 2006-07-20 |
44 |
*/ |
|
45 |
private final Brand myBrand; |
|
46 |
|
|
47 |
/** |
|
48 |
* |
|
49 |
*/ |
|
50 |
SealedBox(Object contents, Brand brand) { |
|
51 |
myContents = contents; |
|
52 |
myBrand = brand; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
| 1b3a04f by markm at 2006-11-17 |
56 |
* The Brand of the {@link Sealer} that sealed this box, and therefore the |
|
57 |
* Brand of the {@link Unsealer} required to obtain my contents. |
| 7f5c7c4 by kpreid at 2006-07-20 |
58 |
*/ |
|
59 |
public Brand getBrand() { |
|
60 |
return myBrand; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Prints using the Brand's name |
|
65 |
*/ |
|
66 |
public String toString() { |
|
67 |
return "<sealed by " + myBrand + ">"; |
|
68 |
} |
|
69 |
} |