mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2197: Extend Java service to return a list of security clearances the user can see.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@104244 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -74,4 +74,12 @@ public class ClearanceLevelManager
|
|||||||
}
|
}
|
||||||
throw new LevelIdNotFound(classificationLevelId);
|
throw new LevelIdNotFound(classificationLevelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the highest security clearance level.
|
||||||
|
*/
|
||||||
|
public ClearanceLevel getMostSecureLevel()
|
||||||
|
{
|
||||||
|
return clearanceLevels.get(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,10 +22,13 @@ import org.alfresco.query.PagingResults;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.NoSuchPersonException;
|
import org.alfresco.service.cmr.security.NoSuchPersonException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service offers access to users' security clearance levels.
|
* This service offers access to users' security clearance levels.
|
||||||
*
|
*
|
||||||
* @author Neil Mc Erlean
|
* @author Neil Mc Erlean
|
||||||
|
* @author David Webster
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface SecurityClearanceService
|
public interface SecurityClearanceService
|
||||||
@@ -66,4 +69,13 @@ public interface SecurityClearanceService
|
|||||||
* @return the user's security clearance
|
* @return the user's security clearance
|
||||||
*/
|
*/
|
||||||
SecurityClearance setUserSecurityClearance(String userName, String clearanceId);
|
SecurityClearance setUserSecurityClearance(String userName, String clearanceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an immutable list of the defined clearance levels.
|
||||||
|
*
|
||||||
|
* @return clearance levels in descending order from highest to lowest
|
||||||
|
* (where fewer users have access to the highest clearance levels
|
||||||
|
* and therefore access to the most restricted documents).
|
||||||
|
*/
|
||||||
|
List<ClearanceLevel> getClearanceLevels();
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import static org.alfresco.module.org_alfresco_module_rm.classification.model.Cl
|
|||||||
import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLEARANCE_LEVEL;
|
import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLEARANCE_LEVEL;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||||
@@ -35,6 +36,7 @@ import org.alfresco.util.ParameterCheck;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Neil Mc Erlean
|
* @author Neil Mc Erlean
|
||||||
|
* @author David Webster
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements SecurityClearanceService
|
public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements SecurityClearanceService
|
||||||
@@ -195,4 +197,33 @@ public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements Sec
|
|||||||
|
|
||||||
return getUserSecurityClearance(userName);
|
return getUserSecurityClearance(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ClearanceLevel> getClearanceLevels()
|
||||||
|
{
|
||||||
|
if (clearanceManager == null)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
// FIXME Currently assume user has highest security clearance, this should be fixed as part of RM-2112.
|
||||||
|
ClearanceLevel usersLevel = clearanceManager.getMostSecureLevel();
|
||||||
|
|
||||||
|
return restrictList(clearanceManager.getClearanceLevels(), usersLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a list containing all clearance levels up to and including the supplied level.
|
||||||
|
*
|
||||||
|
* @param allLevels The list of all the clearance levels starting with the highest security.
|
||||||
|
* @param targetLevel The highest security clearance level that should be returned. If this is not found then
|
||||||
|
* an empty list will be returned.
|
||||||
|
* @return an immutable list of the levels that a user at the target level can see.
|
||||||
|
*/
|
||||||
|
List<ClearanceLevel> restrictList(List<ClearanceLevel> allLevels, ClearanceLevel targetLevel)
|
||||||
|
{
|
||||||
|
int targetIndex = allLevels.indexOf(targetLevel);
|
||||||
|
if (targetIndex == -1) { return Collections.emptyList(); }
|
||||||
|
List<ClearanceLevel> subList = allLevels.subList(targetIndex, allLevels.size());
|
||||||
|
return Collections.unmodifiableList(subList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user