use of javax.management.MBeanPermission in project felix by apache.
the class MX4JMBeanServer method setAttributes.
public AttributeList setAttributes(ObjectName objectName, AttributeList attributes) throws InstanceNotFoundException, ReflectionException {
if (attributes == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid attribute list"));
}
objectName = secureObjectName(objectName);
MBeanMetaData metadata = findMBeanMetaData(objectName);
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
// Must check if the user has the right to call this method, regardless of the attributes
sm.checkPermission(new MBeanPermission(metadata.info.getClassName(), "-", objectName, "setAttribute"));
}
return getHeadInterceptor().setAttributes(metadata, attributes);
}
use of javax.management.MBeanPermission in project felix by apache.
the class MX4JMBeanServer method getClassLoaderFor.
public ClassLoader getClassLoaderFor(ObjectName name) throws InstanceNotFoundException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
name = secureObjectName(name);
}
// If name is null, I get InstanceNotFoundException
MBeanMetaData metadata = findMBeanMetaData(name);
if (sm != null) {
sm.checkPermission(new MBeanPermission(metadata.info.getClassName(), "-", name, "getClassLoaderFor"));
}
return metadata.mbean.getClass().getClassLoader();
}
use of javax.management.MBeanPermission in project felix by apache.
the class MX4JMBeanServer method queryMBeans.
public Set queryMBeans(ObjectName patternName, QueryExp filter) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
patternName = secureObjectName(patternName);
// Must check if the user has the right to call this method,
// no matter which ObjectName has been passed.
sm.checkPermission(new MBeanPermission("-#-[-]", "queryMBeans"));
}
Set match = queryObjectNames(patternName, filter, true);
Set set = new HashSet();
for (Iterator i = match.iterator(); i.hasNext(); ) {
ObjectName name = (ObjectName) i.next();
try {
MBeanMetaData metadata = findMBeanMetaData(name);
set.add(metadata.instance);
} catch (InstanceNotFoundException ignored) {
// A concurrent thread removed the MBean after queryNames, ignore
}
}
return set;
}
use of javax.management.MBeanPermission in project felix by apache.
the class MX4JMBeanServer method getClassLoader.
public ClassLoader getClassLoader(ObjectName name) throws InstanceNotFoundException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
name = secureObjectName(name);
if (name == null) {
sm.checkPermission(new MBeanPermission("-#-[-]", "getClassLoader"));
} else {
MBeanMetaData metadata = findMBeanMetaData(name);
sm.checkPermission(new MBeanPermission(metadata.info.getClassName(), "-", name, "getClassLoader"));
}
}
return getClassLoaderImpl(name);
}
use of javax.management.MBeanPermission in project jdk8u_jdk by JetBrains.
the class MBeanInstantiator method getClassLoader.
private ClassLoader getClassLoader(final ObjectName name) {
if (clr == null) {
return null;
}
// Restrict to getClassLoader permission only
Permissions permissions = new Permissions();
permissions.add(new MBeanPermission("*", null, name, "getClassLoader"));
ProtectionDomain protectionDomain = new ProtectionDomain(null, permissions);
ProtectionDomain[] domains = { protectionDomain };
AccessControlContext ctx = new AccessControlContext(domains);
ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return clr.getClassLoader(name);
}
}, ctx);
return loader;
}
Aggregations