提交 4e73f25f 编写于 作者: S smarks

8173697: Less Active Activations

Reviewed-by: skoivu, rhalade, rriggs, chegar, coffeys
上级 14301f1b
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,6 +40,12 @@ import java.rmi.server.RemoteObject; ...@@ -40,6 +40,12 @@ import java.rmi.server.RemoteObject;
import java.rmi.server.RemoteObjectInvocationHandler; import java.rmi.server.RemoteObjectInvocationHandler;
import java.rmi.server.RemoteRef; import java.rmi.server.RemoteRef;
import java.rmi.server.UID; import java.rmi.server.UID;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.Permissions;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
/** /**
* Activation makes use of special identifiers to denote remote * Activation makes use of special identifiers to denote remote
...@@ -81,6 +87,14 @@ public class ActivationID implements Serializable { ...@@ -81,6 +87,14 @@ public class ActivationID implements Serializable {
/** indicate compatibility with the Java 2 SDK v1.2 version of class */ /** indicate compatibility with the Java 2 SDK v1.2 version of class */
private static final long serialVersionUID = -4608673054848209235L; private static final long serialVersionUID = -4608673054848209235L;
/** an AccessControlContext with no permissions */
private static final AccessControlContext NOPERMS_ACC;
static {
Permissions perms = new Permissions();
ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
NOPERMS_ACC = new AccessControlContext(pd);
}
/** /**
* The constructor for <code>ActivationID</code> takes a single * The constructor for <code>ActivationID</code> takes a single
* argument, activator, that specifies a remote reference to the * argument, activator, that specifies a remote reference to the
...@@ -116,13 +130,19 @@ public class ActivationID implements Serializable { ...@@ -116,13 +130,19 @@ public class ActivationID implements Serializable {
try { try {
MarshalledObject<? extends Remote> mobj = MarshalledObject<? extends Remote> mobj =
activator.activate(this, force); activator.activate(this, force);
return AccessController.doPrivileged(
new PrivilegedExceptionAction<Remote>() {
public Remote run() throws IOException, ClassNotFoundException {
return mobj.get(); return mobj.get();
} catch (RemoteException e) { }
throw e; }, NOPERMS_ACC);
} catch (IOException e) { } catch (PrivilegedActionException pae) {
throw new UnmarshalException("activation failed", e); Exception ex = pae.getException();
} catch (ClassNotFoundException e) { if (ex instanceof RemoteException) {
throw new UnmarshalException("activation failed", e); throw (RemoteException) ex;
} else {
throw new UnmarshalException("activation failed", ex);
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册