Ejemplo n.º 1
0
 public void doJob() {
   Settings settings = Settings.load();
   setValueIfMissing(settings, SettingsKeys.Admin.DASHBOARD_TYPE, DefaultDashboardProvider.TYPE);
   setValueIfMissing(settings, SettingsKeys.Admin.THEME_VARIANT, AdminTheme.DEFAULT_VARIANT_NAME);
   setValueIfMissing(
       settings, SettingsKeys.Admin.RICHTEXT_EDITOR_TYPE, TinyMCEEditorProvider.EDITOR_TYPE);
   settings.save();
 }
Ejemplo n.º 2
0
  @Provides(type = Core.Type.SECURITY, with = Core.With.AUTHORIZATION_FAILURE)
  public static Result handleAuthFailure(Node node, String withType, Map<String, Object> args)
      throws NodeLoadException, ModuleException {

    User user = SecurityEventGenerator.triggerCurrentUserInterceptor();
    SecurityEventGenerator.triggerBeforeAuthorizationFailure(user);

    try {
      String unauthorizedPage = Settings.load().getValue(CoreSettingsHelper.Keys.UNAUTHORIZED_PAGE);
      try {
        if (StringUtils.isNotBlank(unauthorizedPage)) {
          Content content = CoreLoader.loadAndDecorateNode(unauthorizedPage, 0);
          if (user != null) {
            return Controller.forbidden(content);
          } else {
            return Controller.unauthorized(content);
          }
        }
      } catch (NodeNotFoundException | NodeLoadException | ModuleException e) {
        ExceptionUtil.assertExceptionHandling(e);
        return CoreLoader.redirectToPageLoadErrorPage();
      }

      if (user != null) {
        Logger.warn("Using fallback forbidden handling, sending 403 with no content");
        return Controller.forbidden();
      } else {
        Logger.warn("Using fallback unauthorized handling, sending 401 with no content");
        return Controller.unauthorized();
      }
    } finally {
      SecurityEventGenerator.triggerAfterAuthorizationFailure(user);
    }
  }
Ejemplo n.º 3
0
 private void setValueIfMissing(Settings settings, String settingKey, String newValue) {
   if (StringUtils.isBlank(settings.getValue(settingKey))) {
     settings.setValue(settingKey, newValue);
   }
 }