示例#1
0
 public void setPermissions(String location, PermissionInfo[] permissions) {
   checkAllPermission();
   synchronized (lock) {
     permAdminTable.setPermissions(location, permissions);
     try {
       permissionStorage.setPermissionData(location, getEncodedPermissionInfos(permissions));
     } catch (IOException e) {
       // TODO log
       e.printStackTrace();
     }
   }
 }
示例#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);
   }
 }