Search in sources :

Example 21 with MBeanPermission

use of javax.management.MBeanPermission in project Payara by payara.

the class BasePolicyWrapper method doImplies.

private boolean doImplies(ProtectionDomain domain, Permission permission) {
    String contextId = PolicyContext.getContextID();
    PolicyConfigurationImpl pci = getPolicyConfigForContext(contextId);
    Policy appPolicy = getPolicy(pci);
    boolean result = appPolicy.implies(domain, permission);
    // login pages, and javax.management.MBeanPermission
    if (!result) {
        if (!(permission instanceof WebResourcePermission) && !(permission instanceof MBeanPermission) && !(permission instanceof WebRoleRefPermission) && !(permission instanceof EJBRoleRefPermission)) {
            final String contextId2 = contextId;
            final Permission permission2 = permission;
            final ProtectionDomain domain2 = domain;
            if (logger.isLoggable(Level.FINE)) {
                Exception ex = new Exception();
                ex.fillInStackTrace();
                logger.log(Level.FINE, "JACC Policy Provider, failed Permission Check at :", ex);
            }
            AccessController.doPrivileged(new PrivilegedAction() {

                @Override
                public Object run() {
                    logger.info("JACC Policy Provider: Failed Permission Check, context(" + contextId2 + ")- permission(" + permission2 + ")");
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine("Domain that failed(" + domain2 + ")");
                    }
                    return null;
                }
            });
        }
    } else {
        Permissions excluded = getExcludedPolicy(pci);
        if (excluded != null) {
            result = !grantedIsExcluded(permission, excluded);
        }
    }
    // at FINEST: log only denies
    if (!result && logger.isLoggable(Level.FINEST)) {
        logger.finest("JACC Policy Provider: PolicyWrapper.implies, context (" + contextId + ")- result was(" + result + ") permission (" + permission + ")");
    }
    return result;
}
Also used : MBeanPermission(javax.management.MBeanPermission) MBeanPermission(javax.management.MBeanPermission)

Example 22 with MBeanPermission

use of javax.management.MBeanPermission in project jdk8u_jdk by JetBrains.

the class ClassLoaderRepositorySupport method getClassLoader.

public final ClassLoader getClassLoader(ObjectName name) {
    ClassLoader instance = loadersWithNames.get(name);
    if (instance != null) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            Permission perm = new MBeanPermission(instance.getClass().getName(), null, name, "getClassLoader");
            sm.checkPermission(perm);
        }
    }
    return instance;
}
Also used : MBeanPermission(javax.management.MBeanPermission) Permission(java.security.Permission) MBeanPermission(javax.management.MBeanPermission) PrivateClassLoader(javax.management.loading.PrivateClassLoader)

Example 23 with MBeanPermission

use of javax.management.MBeanPermission in project jdk8u_jdk by JetBrains.

the class MBeanInstantiator method checkMBeanPermission.

private static void checkMBeanPermission(String classname, String member, ObjectName objectName, String actions) throws SecurityException {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanPermission(classname, member, objectName, actions);
        sm.checkPermission(perm);
    }
}
Also used : MBeanPermission(javax.management.MBeanPermission) MBeanPermission(javax.management.MBeanPermission) Permission(java.security.Permission)

Example 24 with MBeanPermission

use of javax.management.MBeanPermission in project wildfly by wildfly.

the class ServiceMBeanSupportOrderingTestCase method geTestMBeanSar.

@Deployment(name = ServiceMBeanSupportOrderingTestCase.UNMANAGED_SAR_DEPLOYMENT_NAME, managed = false)
public static JavaArchive geTestMBeanSar() {
    final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "service-mbean-order-test.sar");
    sar.addClasses(LifecycleEmitterMBean.class, LifecycleEmitter.class);
    sar.addAsManifestResource(ServiceMBeanSupportOrderingTestCase.class.getPackage(), "jboss-service.xml", "jboss-service.xml");
    sar.addAsManifestResource(createPermissionsXmlAsset(new MBeanPermission(ServiceMBeanSupportOrderingTestCase.class.getPackage().getName() + ".*", "*")), "permissions.xml");
    return sar;
}
Also used : MBeanPermission(javax.management.MBeanPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

MBeanPermission (javax.management.MBeanPermission)24 Permission (java.security.Permission)6 ReflectPermission (java.lang.reflect.ReflectPermission)3 InstanceNotFoundException (javax.management.InstanceNotFoundException)3 ObjectName (javax.management.ObjectName)3 RuntimeOperationsException (javax.management.RuntimeOperationsException)3 Deployment (org.jboss.arquillian.container.test.api.Deployment)3 AccessControlContext (java.security.AccessControlContext)2 Permissions (java.security.Permissions)2 ProtectionDomain (java.security.ProtectionDomain)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 MBeanServerPermission (javax.management.MBeanServerPermission)2 MBeanTrustPermission (javax.management.MBeanTrustPermission)2 PrivateClassLoader (javax.management.loading.PrivateClassLoader)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 FilePermission (java.io.FilePermission)1 SerializablePermission (java.io.SerializablePermission)1 ManagementPermission (java.lang.management.ManagementPermission)1 MalformedURLException (java.net.MalformedURLException)1