Пример #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 void setDefaultPermissions(PermissionInfo[] permissions) {
   checkAllPermission();
   synchronized (lock) {
     if (permissions == null) permAdminDefaults = null;
     else permAdminDefaults = new PermissionInfoCollection(permissions);
     try {
       permissionStorage.setPermissionData(null, getEncodedPermissionInfos(permissions));
     } catch (IOException e) {
       // log
       e.printStackTrace();
     }
   }
 }
Пример #3
0
 boolean commit(List rows, long updateStamp) {
   checkAllPermission();
   synchronized (lock) {
     if (updateStamp != timeStamp) return false;
     SecurityRow[] newRows = new SecurityRow[rows.size()];
     Collection names = new ArrayList();
     for (int i = 0; i < newRows.length; i++) {
       Object rowObj = rows.get(i);
       if (!(rowObj instanceof ConditionalPermissionInfo))
         throw new IllegalStateException(
             "Invalid type \""
                 + rowObj.getClass().getName()
                 + "\" at row: "
                 + i); //$NON-NLS-1$//$NON-NLS-2$
       ConditionalPermissionInfo infoBaseRow = (ConditionalPermissionInfo) rowObj;
       String name = infoBaseRow.getName();
       if (name == null) name = generateName();
       if (names.contains(name))
         throw new IllegalStateException(
             "Duplicate name \"" + name + "\" at row: " + i); // $NON-NLS-1$//$NON-NLS-2$
       newRows[i] =
           new SecurityRow(
               this,
               name,
               infoBaseRow.getConditionInfos(),
               infoBaseRow.getPermissionInfos(),
               infoBaseRow.getAccessDecision());
     }
     condAdminTable = new SecurityTable(this, newRows);
     try {
       permissionStorage.saveConditionalPermissionInfos(condAdminTable.getEncodedRows());
     } catch (IOException e) {
       // TODO log
       e.printStackTrace();
     }
     timeStamp += 1;
     return true;
   }
 }