public String getEntityReference() { return urlEntityReference == null? (site == null? "" : site.getReference()) : urlEntityReference; } }
public String getEntityReference() { return urlEntityReference == null ? (site == null ? "" : site.getReference()) : urlEntityReference; } }
private ContentReviewService getSelectedProvider() { if (defaultProvider < 0) { throw new ContentReviewProviderException("No Default Content Review Provider"); } Optional<Site> currentSite = getCurrentSite(); if (currentSite.isPresent()) { if (log.isDebugEnabled()) log.debug("In Location:" + currentSite.get().getReference()); final String overrideProvider = currentSite.get().getProperties().getProperty("contentreview.provider"); if (StringUtils.isNotEmpty(overrideProvider) && enabledProviders.stream().anyMatch(p -> p.intValue() == Math.abs(overrideProvider.hashCode()))) { return providers.stream().filter(crs -> crs.getProviderId().intValue() == Math.abs(overrideProvider.hashCode())).collect(Collectors.toList()).get(0); } } return providers.stream().filter(crs -> crs.getProviderId().intValue() == defaultProvider).collect(Collectors.toList()).get(0); }
/** * Get all provider IDs for the given site. * * @param site the site to retrieve all provider IDs * @return a List of Strings of provider IDs for the given site */ public static List<String> getProviderIDsForSite(Site site) { List<String> providers = new ArrayList<>(); if (site != null) { providers.addAll(getAuthzGroupService().getProviderIds(site.getReference())); } return providers; }
/** * Get all provider IDs for all sites given. * * @param sites the list of sites to retrieve all provider IDs * @return a Map, where the key is the realm ID, and the value is a list of provider IDs for that site */ public static Map<String, List<String>> getProviderIDsForSites(List<Site> sites) { Map<String, List<String>> realmProviderMap = new HashMap<>(); if (!sites.isEmpty()) { List<String> realmIDs = new ArrayList<>(); for (Site site : sites) { realmIDs.add(site.getReference()); } realmProviderMap = getAuthzGroupService().getProviderIDsForRealms(realmIDs); } return realmProviderMap; }
/** * Get all provider IDs for the given site. * * @param site the site to retrieve all provider IDs * @return a List of Strings of provider IDs for the given site */ public static List<String> getProviderIDsForSite(Site site) { List<String> providers = new ArrayList<>(); if (site != null) { providers.addAll(getAuthzGroupService().getProviderIds(site.getReference())); } return providers; }
/** * {@inheritDoc} */ public List<User> getUsersWithPermission(String permission) { try { //current site Site currentSite = siteService.getSite(getCurrentLocationId()); //get userids with permission in this site/azg Set<String> usersWithPermission = authzGroupService.getUsersIsAllowed(permission, Collections.singletonList(currentSite.getReference())); //get Users return userDirectoryService.getUsers(usersWithPermission); } catch (Exception e) { log.error("getUsersWithPermission exception: " + e.getClass() + ":" + e.getMessage()); } return Collections.EMPTY_LIST; }
/** * Disable the site and site group azgs for a site that's being deleted. * * @param site * The site. */ protected void disableAzg(Site site) { // disable a realm for each group for (Iterator iGroups = site.getGroups().iterator(); iGroups.hasNext();) { Group group = (Group) iGroups.next(); disableAuthorizationGroup(group.getReference()); } // disable realm last, to keep those permissions around disableAuthorizationGroup(site.getReference()); }
/** * Creates a course from a sakai Site * * @param site The Sakai site */ public CourseImpl(Site site) { this.site = site; this.uuid = site.getReference(); this.title = site.getTitle(); this.siteContext = site.getId(); this.externallyManaged = Boolean.valueOf(site.getProperties().getProperty(CourseImpl.EXTERNALLY_MAINTAINED)).booleanValue(); this.selfRegistrationAllowed = Boolean.valueOf(site.getProperties().getProperty(CourseImpl.STUDENT_REGISTRATION_ALLOWED)).booleanValue(); this.selfSwitchingAllowed = Boolean.valueOf(site.getProperties().getProperty(CourseImpl.STUDENT_SWITCHING_ALLOWED)).booleanValue(); }
public String getCurrentLocationReference() { String location = null; try { String context = toolManager.getCurrentPlacement().getContext(); Site s = siteService.getSite( context ); location = s.getReference(); // get the entity reference to the site } catch (Exception e) { // sakai failed to get us a location so we can assume we are not inside the portal location = null; } return location; }
/** * Creates a course from a sakai Site * * @param site The Sakai site */ public CourseImpl(Site site) { this.site = site; this.uuid = site.getReference(); this.title = site.getTitle(); this.siteContext = site.getId(); this.externallyManaged = Boolean.valueOf(site.getProperties().getProperty(CourseImpl.EXTERNALLY_MAINTAINED)).booleanValue(); this.selfRegistrationAllowed = Boolean.valueOf(site.getProperties().getProperty(CourseImpl.STUDENT_REGISTRATION_ALLOWED)).booleanValue(); this.selfSwitchingAllowed = Boolean.valueOf(site.getProperties().getProperty(CourseImpl.STUDENT_SWITCHING_ALLOWED)).booleanValue(); }
/** * {@inheritDoc} */ public boolean isUserRoleSwapped(String siteId) throws IdUnusedException { if (siteId == null) { siteId = getCurrentSiteId(); } final Site site = siteService().getSite(siteId); // they are roleswapped if they have an 'effective role' final String effectiveRole = getUserEffectiveRole(site.getReference()); if (StringUtils.isNotBlank(effectiveRole)) { return true; } return false; } }
private Optional<String> getNumericId(User user, Site site, boolean checkVisibilityPermission) { if (user == null || site == null || !isInstitutionalNumericIdEnabled(site) || (checkVisibilityPermission && !secServ.unlock(user, USER_PERM_STUDENT_NUMBER_VISIBLE, site.getReference()))) { return Optional.empty(); } try { String studentNumber = user.getProperties().getProperty(USER_PROP_STUDENT_NUMBER); if (serverConfigurationService.getBoolean(PROP_ENCRYPT_NUMERIC_ID, true)) { studentNumber = encryptionUtilities.decrypt(studentNumber); } if (StringUtils.isNotBlank(studentNumber)) { return Optional.of(studentNumber); } } catch (Exception e) { log.warn("Error getting studentNumber for {}", user.getId(), e); } return Optional.empty(); }
public boolean checkLockOnCurrentUserAndSite(String authzfunction) { String context = toolmanager.getCurrentPlacement().getContext(); try { Site site = siteService.getSite(context); return securityService.unlock(authzfunction, site.getReference()); } catch (IdUnusedException e) { throw UniversalRuntimeException.accumulate(e, "Could not fetch the site for context " + context); } }
public SiteSerialized(Site site, String termProp){ this.id = site.getId(); this.url = site.getUrl(); this.title = site.getTitle(); Object prop = site.getProperties().get(termProp); term = ""; if(prop != null){ term = prop.toString(); } this.reference = site.getReference(); this.setPublished(site.isPublished()); }
public boolean checkLockOnCurrentUserAndSite(String authzfunction) { String context = toolmanager.getCurrentPlacement().getContext(); try { Site site = siteService.getSite(context); return securityService.unlock(authzfunction, site.getReference()); } catch (IdUnusedException e) { throw UniversalRuntimeException.accumulate(e, "Could not fetch the site for context " + context); } }
public SiteSerialized(Site site, String termProp){ this.id = site.getId(); this.url = site.getUrl(); this.title = site.getTitle(); Object prop = site.getProperties().get(termProp); term = ""; if(prop != null){ term = prop.toString(); } this.reference = site.getReference(); this.setPublished(site.isPublished()); }
@Override public void update(Observable o, Object obj) { if (obj == null || !(obj instanceof Event)) { return; } Event event = (Event) obj; if (SiteService.EVENT_SITE_USER_INVALIDATE.equals(event.getEvent())) { Site site = null; try { site = siteService().getSite(event.getResource()); } catch (IdUnusedException e) { log.warn("Security invalidation error when handling an event (" + event.getEvent() + "), for site " + event.getResource()); } if (site != null) { resetSecurityCache(site.getReference()); } } }
/** * {@inheritDoc} * * @return */ public String getSiteReference() { try { Site currentSite = siteService.getSite(toolManager .getCurrentPlacement().getContext()); return currentSite.getReference(); } catch (IdUnusedException e) { throw new PermissionException( Messages.getString("RWikiSecurityServiceImpl.2")); //$NON-NLS-1$ } }
/** * @inheritDoc */ public void save(Site site) throws IdUnusedException, PermissionException { if (site.getId() == null) throw new IdUnusedException("<null>"); String siteRef = site.getReference(); if (!unlockCheck(SECURE_UPDATE_GROUP_MEMBERSHIP, siteRef) && !unlockCheck(SECURE_UPDATE_SITE_MEMBERSHIP, siteRef)) { // check security (throws if not permitted) unlock(SECURE_UPDATE_SITE, siteRef); } // check for existance if (!storage().check(site.getId())) { throw new IdUnusedException(site.getId()); } // Save the site doSave((BaseSite) site, false); }