提交 702614ef 编写于 作者: S shshahma

8158406: Limited Parameter Processing

Reviewed-by: dfuchs, skoivu
上级 d5f6c573
...@@ -349,7 +349,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -349,7 +349,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
+", unwrapping parameters using classLoaderWithRepository."); +", unwrapping parameters using classLoaderWithRepository.");
values = values =
nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class)); nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class,delegationSubject));
try { try {
final Object params2[] = final Object params2[] =
...@@ -413,7 +413,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -413,7 +413,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
values = nullIsEmpty(unwrap(params, values = nullIsEmpty(unwrap(params,
getClassLoader(loaderName), getClassLoader(loaderName),
defaultClassLoader, defaultClassLoader,
Object[].class)); Object[].class,delegationSubject));
try { try {
final Object params2[] = final Object params2[] =
...@@ -524,7 +524,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -524,7 +524,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
"connectionId=" + connectionId "connectionId=" + connectionId
+" unwrapping query with defaultClassLoader."); +" unwrapping query with defaultClassLoader.");
queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject);
try { try {
final Object params[] = new Object[] { name, queryValue }; final Object params[] = new Object[] { name, queryValue };
...@@ -559,7 +559,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -559,7 +559,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
"connectionId=" + connectionId "connectionId=" + connectionId
+" unwrapping query with defaultClassLoader."); +" unwrapping query with defaultClassLoader.");
queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject);
try { try {
final Object params[] = new Object[] { name, queryValue }; final Object params[] = new Object[] { name, queryValue };
...@@ -709,7 +709,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -709,7 +709,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
attr = unwrap(attribute, attr = unwrap(attribute,
getClassLoaderFor(name), getClassLoaderFor(name),
defaultClassLoader, defaultClassLoader,
Attribute.class); Attribute.class, delegationSubject);
try { try {
final Object params[] = new Object[] { name, attr }; final Object params[] = new Object[] { name, attr };
...@@ -760,7 +760,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -760,7 +760,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
unwrap(attributes, unwrap(attributes,
getClassLoaderFor(name), getClassLoaderFor(name),
defaultClassLoader, defaultClassLoader,
AttributeList.class); AttributeList.class, delegationSubject);
try { try {
final Object params[] = new Object[] { name, attrlist }; final Object params[] = new Object[] { name, attrlist };
...@@ -812,7 +812,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -812,7 +812,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
values = nullIsEmpty(unwrap(params, values = nullIsEmpty(unwrap(params,
getClassLoaderFor(name), getClassLoaderFor(name),
defaultClassLoader, defaultClassLoader,
Object[].class)); Object[].class, delegationSubject));
try { try {
final Object params2[] = final Object params2[] =
...@@ -992,7 +992,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -992,7 +992,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
filterValues[i] = filterValues[i] =
unwrap(filters[i], targetCl, defaultClassLoader, unwrap(filters[i], targetCl, defaultClassLoader,
NotificationFilter.class); NotificationFilter.class, delegationSubjects[i]);
if (debug) logger.debug("addNotificationListener"+ if (debug) logger.debug("addNotificationListener"+
"(ObjectName,NotificationFilter)", "(ObjectName,NotificationFilter)",
...@@ -1060,7 +1060,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1060,7 +1060,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
+" unwrapping filter with target extended ClassLoader."); +" unwrapping filter with target extended ClassLoader.");
filterValue = filterValue =
unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class); unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject);
if (debug) logger.debug("addNotificationListener"+ if (debug) logger.debug("addNotificationListener"+
"(ObjectName,ObjectName,NotificationFilter,Object)", "(ObjectName,ObjectName,NotificationFilter,Object)",
...@@ -1068,7 +1068,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1068,7 +1068,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
+" unwrapping handback with target extended ClassLoader."); +" unwrapping handback with target extended ClassLoader.");
handbackValue = handbackValue =
unwrap(handback, targetCl, defaultClassLoader, Object.class); unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject);
try { try {
final Object params[] = final Object params[] =
...@@ -1199,7 +1199,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1199,7 +1199,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
+" unwrapping filter with target extended ClassLoader."); +" unwrapping filter with target extended ClassLoader.");
filterValue = filterValue =
unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class); unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject);
if (debug) logger.debug("removeNotificationListener"+ if (debug) logger.debug("removeNotificationListener"+
"(ObjectName,ObjectName,NotificationFilter,Object)", "(ObjectName,ObjectName,NotificationFilter,Object)",
...@@ -1207,7 +1207,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1207,7 +1207,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
+" unwrapping handback with target extended ClassLoader."); +" unwrapping handback with target extended ClassLoader.");
handbackValue = handbackValue =
unwrap(handback, targetCl, defaultClassLoader, Object.class); unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject);
try { try {
final Object params[] = final Object params[] =
...@@ -1551,20 +1551,38 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1551,20 +1551,38 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
} }
} }
private static <T> T unwrap(final MarshalledObject<?> mo, private <T> T unwrap(final MarshalledObject<?> mo,
final ClassLoader cl, final ClassLoader cl,
final Class<T> wrappedClass) final Class<T> wrappedClass,
Subject delegationSubject)
throws IOException { throws IOException {
if (mo == null) { if (mo == null) {
return null; return null;
} }
try { try {
final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl)); final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl));
try { try{
return wrappedClass.cast(mo.get()); final AccessControlContext reqACC;
} catch (ClassNotFoundException cnfe) { if (delegationSubject == null)
throw new UnmarshalException(cnfe.toString(), cnfe); reqACC = acc;
} finally { else {
if (subject == null) {
final String msg =
"Subject delegation cannot be enabled unless " +
"an authenticated subject is put in place";
throw new SecurityException(msg);
}
reqACC = subjectDelegator.delegatedContext(
acc, delegationSubject, removeCallerContext);
}
if(reqACC != null){
return AccessController.doPrivileged(
(PrivilegedExceptionAction<T>) () ->
wrappedClass.cast(mo.get()), reqACC);
}else{
return wrappedClass.cast(mo.get());
}
}finally{
AccessController.doPrivileged(new SetCcl(old)); AccessController.doPrivileged(new SetCcl(old));
} }
} catch (PrivilegedActionException pe) { } catch (PrivilegedActionException pe) {
...@@ -1577,14 +1595,19 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1577,14 +1595,19 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
} }
logger.warning("unwrap", "Failed to unmarshall object: " + e); logger.warning("unwrap", "Failed to unmarshall object: " + e);
logger.debug("unwrap", e); logger.debug("unwrap", e);
}catch (ClassNotFoundException ex) {
logger.warning("unwrap", "Failed to unmarshall object: " + ex);
logger.debug("unwrap", ex);
throw new UnmarshalException(ex.toString(), ex);
} }
return null; return null;
} }
private static <T> T unwrap(final MarshalledObject<?> mo, private <T> T unwrap(final MarshalledObject<?> mo,
final ClassLoader cl1, final ClassLoader cl1,
final ClassLoader cl2, final ClassLoader cl2,
final Class<T> wrappedClass) final Class<T> wrappedClass,
Subject delegationSubject)
throws IOException { throws IOException {
if (mo == null) { if (mo == null) {
return null; return null;
...@@ -1598,7 +1621,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ...@@ -1598,7 +1621,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
} }
} }
); );
return unwrap(mo, orderCL, wrappedClass); return unwrap(mo, orderCL, wrappedClass,delegationSubject);
} catch (PrivilegedActionException pe) { } catch (PrivilegedActionException pe) {
Exception e = extractException(pe); Exception e = extractException(pe);
if (e instanceof IOException) { if (e instanceof IOException) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册