1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.river.reggie.proxy;
19
20 import org.apache.river.proxy.ConstrainableProxyUtil;
21 import java.io.IOException;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import net.jini.core.constraint.MethodConstraints;
25 import net.jini.core.constraint.RemoteMethodControl;
26 import net.jini.security.proxytrust.ProxyTrustIterator;
27 import net.jini.security.proxytrust.SingletonProxyTrustIterator;
28 import org.apache.river.api.io.AtomicSerial;
29 import org.apache.river.api.io.AtomicSerial.GetArg;
30
31
32
33
34
35
36
37 @AtomicSerial
38 final class ConstrainableRegistration
39 extends Registration implements RemoteMethodControl
40 {
41 private static final long serialVersionUID = 2L;
42
43
44 private final MethodConstraints constraints;
45
46 private static GetArg check(GetArg arg) throws IOException {
47 MethodConstraints constraints = (MethodConstraints) arg.get("constraints", null);
48 Registration reg = new Registration(arg);
49 ConstrainableProxyUtil.verifyConsistentConstraints(
50 constraints, reg.server, methodMappings);
51 return arg;
52 }
53
54 ConstrainableRegistration(GetArg arg) throws IOException {
55 super(check(arg));
56 constraints = (MethodConstraints) arg.get("constraints", null);
57 }
58
59
60
61
62
63 ConstrainableRegistration( Registrar server,
64 ServiceLease lease,
65 MethodConstraints constraints,
66 boolean setConstraints)
67 {
68 super( setConstraints ? (Registrar) ((RemoteMethodControl) server).setConstraints(
69 translateConstraints(constraints)): server,lease);
70 this.constraints = constraints;
71 }
72
73
74 @Override
75 public RemoteMethodControl setConstraints(MethodConstraints constraints) {
76 return new ConstrainableRegistration(server, lease, constraints, true);
77 }
78
79
80 @Override
81 public MethodConstraints getConstraints() {
82 return constraints;
83 }
84
85
86
87
88
89 private ProxyTrustIterator getProxyTrustIterator() {
90 return new SingletonProxyTrustIterator(server);
91 }
92
93 private void writeObject(ObjectOutputStream out) throws IOException {
94 out.defaultWriteObject();
95 }
96
97
98
99
100
101 private void readObject(ObjectInputStream in)
102 throws IOException, ClassNotFoundException
103 {
104 in.defaultReadObject();
105 ConstrainableProxyUtil.verifyConsistentConstraints(
106 constraints, server, methodMappings);
107 }
108 }