Beispiel #1
0
 void delete(SecurityRow securityRow, boolean firstTry) {
   ConditionalPermissionUpdate update = newConditionalPermissionUpdate();
   List rows = update.getConditionalPermissionInfos();
   for (Iterator iRows = rows.iterator(); iRows.hasNext(); ) {
     ConditionalPermissionInfo info = (ConditionalPermissionInfo) iRows.next();
     if (securityRow.getName().equals(info.getName())) {
       iRows.remove();
       synchronized (lock) {
         if (!update.commit()) {
           if (firstTry)
             // try again
             delete(securityRow, false);
         }
       }
       break;
     }
   }
 }
Beispiel #2
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);
   }
 }
Beispiel #3
0
 public ConditionalPermissionInfo newConditionalPermissionInfo(String encoded) {
   return SecurityRow.createSecurityRowSnapShot(encoded);
 }