equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
38 import java.rmi.UnmarshalException; |
38 import java.rmi.UnmarshalException; |
39 import java.rmi.server.RemoteObject; |
39 import java.rmi.server.RemoteObject; |
40 import java.rmi.server.RemoteObjectInvocationHandler; |
40 import java.rmi.server.RemoteObjectInvocationHandler; |
41 import java.rmi.server.RemoteRef; |
41 import java.rmi.server.RemoteRef; |
42 import java.rmi.server.UID; |
42 import java.rmi.server.UID; |
|
43 import java.security.AccessControlContext; |
|
44 import java.security.AccessController; |
|
45 import java.security.Permissions; |
|
46 import java.security.PrivilegedActionException; |
|
47 import java.security.PrivilegedExceptionAction; |
|
48 import java.security.ProtectionDomain; |
43 |
49 |
44 /** |
50 /** |
45 * Activation makes use of special identifiers to denote remote |
51 * Activation makes use of special identifiers to denote remote |
46 * objects that can be activated over time. An activation identifier |
52 * objects that can be activated over time. An activation identifier |
47 * (an instance of the class <code>ActivationID</code>) contains several |
53 * (an instance of the class <code>ActivationID</code>) contains several |
79 private transient UID uid = new UID(); |
85 private transient UID uid = new UID(); |
80 |
86 |
81 /** indicate compatibility with the Java 2 SDK v1.2 version of class */ |
87 /** indicate compatibility with the Java 2 SDK v1.2 version of class */ |
82 private static final long serialVersionUID = -4608673054848209235L; |
88 private static final long serialVersionUID = -4608673054848209235L; |
83 |
89 |
|
90 /** an AccessControlContext with no permissions */ |
|
91 private static final AccessControlContext NOPERMS_ACC; |
|
92 static { |
|
93 Permissions perms = new Permissions(); |
|
94 ProtectionDomain[] pd = { new ProtectionDomain(null, perms) }; |
|
95 NOPERMS_ACC = new AccessControlContext(pd); |
|
96 } |
|
97 |
84 /** |
98 /** |
85 * The constructor for <code>ActivationID</code> takes a single |
99 * The constructor for <code>ActivationID</code> takes a single |
86 * argument, activator, that specifies a remote reference to the |
100 * argument, activator, that specifies a remote reference to the |
87 * activator responsible for activating the object associated with |
101 * activator responsible for activating the object associated with |
88 * this identifier. An instance of <code>ActivationID</code> is globally |
102 * this identifier. An instance of <code>ActivationID</code> is globally |
114 throws ActivationException, UnknownObjectException, RemoteException |
128 throws ActivationException, UnknownObjectException, RemoteException |
115 { |
129 { |
116 try { |
130 try { |
117 MarshalledObject<? extends Remote> mobj = |
131 MarshalledObject<? extends Remote> mobj = |
118 activator.activate(this, force); |
132 activator.activate(this, force); |
119 return mobj.get(); |
133 return AccessController.doPrivileged( |
120 } catch (RemoteException e) { |
134 new PrivilegedExceptionAction<Remote>() { |
121 throw e; |
135 public Remote run() throws IOException, ClassNotFoundException { |
122 } catch (IOException e) { |
136 return mobj.get(); |
123 throw new UnmarshalException("activation failed", e); |
137 } |
124 } catch (ClassNotFoundException e) { |
138 }, NOPERMS_ACC); |
125 throw new UnmarshalException("activation failed", e); |
139 } catch (PrivilegedActionException pae) { |
|
140 Exception ex = pae.getException(); |
|
141 if (ex instanceof RemoteException) { |
|
142 throw (RemoteException) ex; |
|
143 } else { |
|
144 throw new UnmarshalException("activation failed", ex); |
|
145 } |
126 } |
146 } |
127 |
147 |
128 } |
148 } |
129 |
149 |
130 /** |
150 /** |