/** * Adds the required criteria for authorization to the query for sites and series security groups * * @param query */ public void authorizeSitesAndSSGs(DICOMQuery query) { AuthorizationCriteria auth = query.getAuthorizationCriteria(); if (auth == null) { // Add authorization criteria if it does not // already exist auth = new AuthorizationCriteria(); query.setCriteria(auth); } auth.setSeriesSecurityGroups(getAuthorizedSeriesSecurityGroups()); auth.setSites(getAuthorizedSites()); }
private static AuthorizationCriteria createAuthorizationCriteria() throws Exception { AuthorizationManager am = new AuthorizationManager("kascice"); List<SiteData> authorizedSites = am.getAuthorizedSites(RoleType.READ); List<String> authorizedCollections = am.getAuthorizedCollections(RoleType.READ); List<String> authorizedSeriesSecurityGroups = am.getAuthorizedSeriesSecurityGroups(RoleType.READ); AuthorizationCriteria authorizationCriteria = new AuthorizationCriteria(); authorizationCriteria.setCollections(authorizedCollections); authorizationCriteria.setSites(authorizedSites); authorizationCriteria.setSeriesSecurityGroups(authorizedSeriesSecurityGroups); return authorizationCriteria; }
/** * Adds the required criteria for authorization to the query for collections * * @param query * @return returns false if user attempted to view data with unauthorized collections */ public boolean authorizeCollections(DICOMQuery query) { boolean returnValue = true; AuthorizationCriteria auth = query.getAuthorizationCriteria(); if (auth == null) { // Add authorization criteria if it does not // already exist auth = new AuthorizationCriteria(); query.setCriteria(auth); } CollectionCriteria cc = query.getCollectionCriteria(); if (cc == null) { // User didn't choose any collections, so filter by the collections // they are authorized to see auth.setCollections(getAuthorizedCollections()); } else { List<String> authorizedCollections = getAuthorizedCollections(); List<String> collectionsToRemove = new ArrayList<String>(); // Look at each collection to ensure that user is allowed to view it for (String selectedCollection : cc.getCollectionObjects()) { if (!authorizedCollections.contains(selectedCollection)) { returnValue = false; collectionsToRemove.add(selectedCollection); } } for (String collectionToRemove : collectionsToRemove) { cc.removeCollection(collectionToRemove); } } return returnValue; }