Exemplo n.º 1
0
 private SecurityAdmin getSnapShot() {
   SecurityAdmin sa;
   synchronized (lock) {
     sa =
         new SecurityAdmin(
             supportedSecurityManager, framework, impliedPermissionInfos, permAdminDefaults);
     SecurityRow[] rows = condAdminTable.getRows();
     SecurityRow[] rowsSnapShot = new SecurityRow[rows.length];
     for (int i = 0; i < rows.length; i++)
       rowsSnapShot[i] =
           new SecurityRow(
               sa,
               rows[i].getName(),
               rows[i].getConditionInfos(),
               rows[i].getPermissionInfos(),
               rows[i].getAccessDecision());
     sa.condAdminTable = new SecurityTable(sa, rowsSnapShot);
   }
   return sa;
 }
Exemplo n.º 2
0
 private BundleProtectionDomain createProtectionDomain(Bundle bundle, SecurityAdmin sa) {
   PermissionInfoCollection impliedPermissions = getImpliedPermission(bundle);
   PermissionInfo[] restrictedInfos =
       getFileRelativeInfos(
           SecurityAdmin.getPermissionInfos(
               bundle.getEntry("OSGI-INF/permissions.perm"), framework),
           bundle); //$NON-NLS-1$
   PermissionInfoCollection restrictedPermissions =
       restrictedInfos == null ? null : new PermissionInfoCollection(restrictedInfos);
   BundlePermissions bundlePermissions =
       new BundlePermissions(bundle, sa, impliedPermissions, restrictedPermissions);
   return new BundleProtectionDomain(bundlePermissions, null, bundle);
 }
Exemplo n.º 3
0
 public SecurityAdmin(
     EquinoxSecurityManager supportedSecurityManager,
     Framework framework,
     PermissionStorage permissionStorage)
     throws IOException {
   this.supportedSecurityManager = supportedSecurityManager;
   this.framework = framework;
   this.permissionStorage = new SecurePermissionStorage(permissionStorage);
   this.impliedPermissionInfos =
       SecurityAdmin.getPermissionInfos(
           getClass().getResource(Constants.OSGI_BASE_IMPLIED_PERMISSIONS), framework);
   String[] encodedDefaultInfos = permissionStorage.getPermissionData(null);
   PermissionInfo[] defaultInfos = getPermissionInfos(encodedDefaultInfos);
   if (defaultInfos != null) permAdminDefaults = new PermissionInfoCollection(defaultInfos);
   String[] locations = permissionStorage.getLocations();
   if (locations != null) {
     for (int i = 0; i < locations.length; i++) {
       String[] encodedLocationInfos = permissionStorage.getPermissionData(locations[i]);
       if (encodedLocationInfos != null) {
         PermissionInfo[] locationInfos = getPermissionInfos(encodedLocationInfos);
         permAdminTable.setPermissions(locations[i], locationInfos);
       }
     }
   }
   String[] encodedCondPermInfos = permissionStorage.getConditionalPermissionInfos();
   if (encodedCondPermInfos == null) condAdminTable = new SecurityTable(this, new SecurityRow[0]);
   else {
     SecurityRow[] rows = new SecurityRow[encodedCondPermInfos.length];
     try {
       for (int i = 0; i < rows.length; i++)
         rows[i] = SecurityRow.createSecurityRow(this, encodedCondPermInfos[i]);
     } catch (IllegalArgumentException e) {
       // TODO should log
       // bad format persisted in storage; start clean
       rows = new SecurityRow[0];
     }
     condAdminTable = new SecurityTable(this, rows);
   }
 }