use of org.osgi.jmx.service.permissionadmin.PermissionAdminMBean in project aries by apache.
the class PermissionAdminMBeanTest method testMBeanInterface.
@Test
public void testMBeanInterface() throws IOException {
PermissionAdminMBean mBean = getMBean(PermissionAdminMBean.OBJECTNAME, PermissionAdminMBean.class);
PermissionAdmin permAdminService = context().getService(PermissionAdmin.class);
assertNotNull(permAdminService);
String[] serviceLocation = permAdminService.getLocations();
String[] mBeanLocations = mBean.listLocations();
assertArrayEquals(serviceLocation, mBeanLocations);
PermissionInfo defPerm = new PermissionInfo("AllPermission", "*", "*");
permAdminService.setDefaultPermissions(new PermissionInfo[] { defPerm });
PermissionInfo[] permissions = permAdminService.getDefaultPermissions();
assertNotNull(permissions);
String[] encoded = toEncodedPerm(permissions);
String[] mBeanDefPermissions = mBean.listDefaultPermissions();
assertArrayEquals(encoded, mBeanDefPermissions);
Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
assertNotNull(a);
String location = a.getLocation();
PermissionInfo bundleaPerm = new PermissionInfo("ServicePermission", "ServiceA", "GET");
mBean.setPermissions(location, new String[] { bundleaPerm.getEncoded() });
String[] serviceBundleaPerm = toEncodedPerm(permAdminService.getPermissions(location));
String[] mBeanBundleaPerm = mBean.getPermissions(location);
assertNotNull(mBeanBundleaPerm);
assertArrayEquals(serviceBundleaPerm, mBeanBundleaPerm);
PermissionInfo defaultPerm = new PermissionInfo("AllPermission", "*", "GET");
mBean.setDefaultPermissions(new String[] { defaultPerm.getEncoded() });
String[] serviceDefaultPerm = toEncodedPerm(permAdminService.getDefaultPermissions());
String[] mBeanDefaultPerm = mBean.listDefaultPermissions();
assertNotNull(mBeanDefaultPerm);
assertArrayEquals(serviceDefaultPerm, mBeanDefaultPerm);
}
use of org.osgi.jmx.service.permissionadmin.PermissionAdminMBean in project aries by apache.
the class PermissionAdminMBeanHandler method constructInjectMBean.
/**
* @see org.apache.aries.jmx.AbstractCompendiumHandler#constructInjectMBean(java.lang.Object)
*/
@Override
protected StandardMBean constructInjectMBean(Object targetService) {
PermissionAdminMBean paMBean = new PermissionAdmin((org.osgi.service.permissionadmin.PermissionAdmin) targetService);
StandardMBean mbean = null;
try {
mbean = new StandardMBean(paMBean, PermissionAdminMBean.class);
} catch (NotCompliantMBeanException e) {
Logger logger = agentContext.getLogger();
logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
}
return mbean;
}
Aggregations