Search in sources :

Example 1 with SiteSecurityCallback

use of org.olat.core.gui.control.navigation.SiteSecurityCallback in project OpenOLAT by OpenOLAT.

the class CourseSiteDef method createSite.

protected SiteInstance createSite(UserRequest ureq, CourseSiteConfiguration courseConfig, SiteConfiguration config) {
    if (courseConfig == null)
        return null;
    String secCallbackBeanId = config.getSecurityCallbackBeanId();
    SiteSecurityCallback siteSecCallback = (SiteSecurityCallback) CoreSpringFactory.getBean(secCallbackBeanId);
    UserSession usess = ureq.getUserSession();
    if (usess == null || usess.getRoles() == null)
        return null;
    boolean canSeeToolController = usess.getRoles().isAuthor() || usess.getRoles().isOLATAdmin() || usess.getRoles().isInstitutionalResourceManager();
    boolean showToolController = true;
    if (!canSeeToolController && !courseConfig.isToolbar()) {
        showToolController = false;
    }
    LanguageConfiguration langConfig = getLanguageConfiguration(ureq, courseConfig);
    if (langConfig == null) {
        return null;
    }
    String icon = courseConfig.getNavIconCssClass();
    return createCourseSiteInstance(langConfig, showToolController, siteSecCallback, icon);
}
Also used : SiteSecurityCallback(org.olat.core.gui.control.navigation.SiteSecurityCallback) UserSession(org.olat.core.util.UserSession) LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration)

Example 2 with SiteSecurityCallback

use of org.olat.core.gui.control.navigation.SiteSecurityCallback in project OpenOLAT by OpenOLAT.

the class CatalogContextEntryControllerCreator method isCatalogSiteVisible.

private boolean isCatalogSiteVisible(UserRequest ureq) {
    if (repositoryModule.isCatalogEnabled() && repositoryModule.isCatalogSiteEnabled()) {
        try {
            CatalogSiteDef siteDef = CoreSpringFactory.getImpl(CatalogSiteDef.class);
            SiteDefinitions siteDefinitions = CoreSpringFactory.getImpl(SiteDefinitions.class);
            SiteConfiguration config = siteDefinitions.getConfigurationSite(siteDef);
            if (config != null && StringHelper.containsNonWhitespace(config.getSecurityCallbackBeanId())) {
                String secCallbackBeanId = config.getSecurityCallbackBeanId();
                Object siteSecCallback = CoreSpringFactory.getBean(secCallbackBeanId);
                if (siteSecCallback instanceof SiteSecurityCallback && !((SiteSecurityCallback) siteSecCallback).isAllowedToLaunchSite(ureq)) {
                    return false;
                }
            }
        } catch (Exception e) {
            log.error("Cannot find if the user is allowed to launch the catalog.", e);
        }
        return true;
    } else {
        return false;
    }
}
Also used : SiteSecurityCallback(org.olat.core.gui.control.navigation.SiteSecurityCallback) CatalogSiteDef(org.olat.repository.site.CatalogSiteDef) SiteConfiguration(org.olat.core.gui.control.navigation.SiteConfiguration) SiteDefinitions(org.olat.core.gui.control.navigation.SiteDefinitions)

Example 3 with SiteSecurityCallback

use of org.olat.core.gui.control.navigation.SiteSecurityCallback in project openolat by klemens.

the class CourseSiteDef method createSite.

protected SiteInstance createSite(UserRequest ureq, CourseSiteConfiguration courseConfig, SiteConfiguration config) {
    if (courseConfig == null)
        return null;
    String secCallbackBeanId = config.getSecurityCallbackBeanId();
    SiteSecurityCallback siteSecCallback = (SiteSecurityCallback) CoreSpringFactory.getBean(secCallbackBeanId);
    UserSession usess = ureq.getUserSession();
    if (usess == null || usess.getRoles() == null)
        return null;
    boolean canSeeToolController = usess.getRoles().isAuthor() || usess.getRoles().isOLATAdmin() || usess.getRoles().isInstitutionalResourceManager();
    boolean showToolController = true;
    if (!canSeeToolController && !courseConfig.isToolbar()) {
        showToolController = false;
    }
    LanguageConfiguration langConfig = getLanguageConfiguration(ureq, courseConfig);
    if (langConfig == null) {
        return null;
    }
    String icon = courseConfig.getNavIconCssClass();
    return createCourseSiteInstance(langConfig, showToolController, siteSecCallback, icon);
}
Also used : SiteSecurityCallback(org.olat.core.gui.control.navigation.SiteSecurityCallback) UserSession(org.olat.core.util.UserSession) LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration)

Example 4 with SiteSecurityCallback

use of org.olat.core.gui.control.navigation.SiteSecurityCallback in project openolat by klemens.

the class CatalogContextEntryControllerCreator method isCatalogSiteVisible.

private boolean isCatalogSiteVisible(UserRequest ureq) {
    if (repositoryModule.isCatalogEnabled() && repositoryModule.isCatalogSiteEnabled()) {
        try {
            CatalogSiteDef siteDef = CoreSpringFactory.getImpl(CatalogSiteDef.class);
            SiteDefinitions siteDefinitions = CoreSpringFactory.getImpl(SiteDefinitions.class);
            SiteConfiguration config = siteDefinitions.getConfigurationSite(siteDef);
            if (config != null && StringHelper.containsNonWhitespace(config.getSecurityCallbackBeanId())) {
                String secCallbackBeanId = config.getSecurityCallbackBeanId();
                Object siteSecCallback = CoreSpringFactory.getBean(secCallbackBeanId);
                if (siteSecCallback instanceof SiteSecurityCallback && !((SiteSecurityCallback) siteSecCallback).isAllowedToLaunchSite(ureq)) {
                    return false;
                }
            }
        } catch (Exception e) {
            log.error("Cannot find if the user is allowed to launch the catalog.", e);
        }
        return true;
    } else {
        return false;
    }
}
Also used : SiteSecurityCallback(org.olat.core.gui.control.navigation.SiteSecurityCallback) CatalogSiteDef(org.olat.repository.site.CatalogSiteDef) SiteConfiguration(org.olat.core.gui.control.navigation.SiteConfiguration) SiteDefinitions(org.olat.core.gui.control.navigation.SiteDefinitions)

Aggregations

SiteSecurityCallback (org.olat.core.gui.control.navigation.SiteSecurityCallback)4 SiteConfiguration (org.olat.core.gui.control.navigation.SiteConfiguration)2 SiteDefinitions (org.olat.core.gui.control.navigation.SiteDefinitions)2 UserSession (org.olat.core.util.UserSession)2 LanguageConfiguration (org.olat.course.site.model.LanguageConfiguration)2 CatalogSiteDef (org.olat.repository.site.CatalogSiteDef)2