Search in sources :

Example 1 with BootstrapSettings

use of de.agilecoders.wicket.core.settings.BootstrapSettings in project syncope by apache.

the class SyncopeConsoleApplication method init.

@Override
protected void init() {
    super.init();
    // read console.properties
    Properties props = PropertyUtils.read(getClass(), CONSOLE_PROPERTIES, "console.directory").getLeft();
    site = props.getProperty("site");
    Args.notNull(site, "<site>");
    anonymousUser = props.getProperty("anonymousUser");
    Args.notNull(anonymousUser, "<anonymousUser>");
    anonymousKey = props.getProperty("anonymousKey");
    Args.notNull(anonymousKey, "<anonymousKey>");
    scheme = props.getProperty("scheme");
    Args.notNull(scheme, "<scheme>");
    host = props.getProperty("host");
    Args.notNull(host, "<host>");
    port = props.getProperty("port");
    Args.notNull(port, "<port>");
    rootPath = props.getProperty("rootPath");
    Args.notNull(rootPath, "<rootPath>");
    useGZIPCompression = props.getProperty("useGZIPCompression");
    Args.notNull(useGZIPCompression, "<useGZIPCompression>");
    maxUploadFileSizeMB = props.getProperty("maxUploadFileSizeMB") == null ? null : Integer.valueOf(props.getProperty("maxUploadFileSizeMB"));
    maxWaitTime = Integer.valueOf(props.getProperty("maxWaitTimeOnApplyChanges", "30"));
    String csrf = props.getProperty("csrf");
    // process page properties
    pageClasses = new HashMap<>();
    populatePageClasses(props);
    pageClasses = Collections.unmodifiableMap(pageClasses);
    // Application settings
    IBootstrapSettings settings = new BootstrapSettings();
    // set theme provider
    settings.setThemeProvider(new SingleThemeProvider(new AdminLTE()));
    // install application settings
    Bootstrap.install(this, settings);
    getResourceSettings().setUseMinifiedResources(true);
    getResourceSettings().setThrowExceptionOnMissingResource(true);
    getJavaScriptLibrarySettings().setJQueryReference(new DynamicJQueryResourceReference());
    getSecuritySettings().setAuthorizationStrategy(new MetaDataRoleAuthorizationStrategy(this));
    ClassPathScanImplementationLookup lookup = (ClassPathScanImplementationLookup) getServletContext().getAttribute(ConsoleInitializer.CLASSPATH_LOOKUP);
    lookup.getPageClasses().forEach(cls -> MetaDataRoleAuthorizationStrategy.authorize(cls, SyncopeConsoleSession.AUTHENTICATED));
    getMarkupSettings().setStripWicketTags(true);
    getMarkupSettings().setCompressWhitespace(true);
    if (BooleanUtils.toBoolean(csrf)) {
        getRequestCycleListeners().add(new CsrfPreventionRequestCycleListener());
    }
    getRequestCycleListeners().add(new SyncopeConsoleRequestCycleListener());
    mountPage("/login", getSignInPageClass());
    flowableModelerDirectory = props.getProperty("flowableModelerDirectory");
    Args.notNull(flowableModelerDirectory, "<flowableModelerDirectory>");
    try {
        reconciliationReportKey = props.getProperty("reconciliationReportKey");
    } catch (NumberFormatException e) {
        LOG.error("While parsing reconciliationReportKey", e);
    }
    Args.notNull(reconciliationReportKey, "<reconciliationReportKey>");
    mountResource("/" + FLOWABLE_MODELER_CONTEXT, new ResourceReference(FLOWABLE_MODELER_CONTEXT) {

        private static final long serialVersionUID = -128426276529456602L;

        @Override
        public IResource getResource() {
            return new FilesystemResource(FLOWABLE_MODELER_CONTEXT, flowableModelerDirectory);
        }
    });
    mountResource("/workflowDefGET", new ResourceReference("workflowDefGET") {

        private static final long serialVersionUID = -128426276529456602L;

        @Override
        public IResource getResource() {
            return new WorkflowDefGETResource();
        }
    });
    mountResource("/workflowDefPUT", new ResourceReference("workflowDefPUT") {

        private static final long serialVersionUID = -128426276529456602L;

        @Override
        public IResource getResource() {
            return new WorkflowDefPUTResource();
        }
    });
    // enable component path
    if (getDebugSettings().isAjaxDebugModeEnabled()) {
        getDebugSettings().setComponentPathAttributeName("syncope-path");
    }
}
Also used : SingleThemeProvider(de.agilecoders.wicket.core.settings.SingleThemeProvider) Properties(java.util.Properties) MetaDataRoleAuthorizationStrategy(org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy) IBootstrapSettings(de.agilecoders.wicket.core.settings.IBootstrapSettings) BootstrapSettings(de.agilecoders.wicket.core.settings.BootstrapSettings) CsrfPreventionRequestCycleListener(org.apache.wicket.protocol.http.CsrfPreventionRequestCycleListener) IBootstrapSettings(de.agilecoders.wicket.core.settings.IBootstrapSettings) FilesystemResource(org.apache.syncope.client.console.resources.FilesystemResource) ClassPathScanImplementationLookup(org.apache.syncope.client.console.init.ClassPathScanImplementationLookup) WorkflowDefGETResource(org.apache.syncope.client.console.resources.WorkflowDefGETResource) AdminLTE(org.apache.syncope.client.console.themes.AdminLTE) DynamicJQueryResourceReference(org.apache.wicket.resource.DynamicJQueryResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference) WorkflowDefPUTResource(org.apache.syncope.client.console.resources.WorkflowDefPUTResource) DynamicJQueryResourceReference(org.apache.wicket.resource.DynamicJQueryResourceReference) IResource(org.apache.wicket.request.resource.IResource)

Example 2 with BootstrapSettings

use of de.agilecoders.wicket.core.settings.BootstrapSettings in project hale by halestudio.

the class BaseWebApplication method init.

@Override
public void init() {
    super.init();
    BootstrapSettings settings = new BootstrapSettings();
    final ThemeProvider themeProvider = new BootswatchThemeProvider() {

        {
            add(new MetroTheme());
            add(new GoogleTheme());
            add(new WicketTheme());
            add(new Bootstrap3Theme());
            defaultTheme("bootstrap-responsive");
        // defaultTheme("bootstrap");
        }
    };
    settings.setThemeProvider(themeProvider);
    Bootstrap.install(this, settings);
    BootstrapLess.install(this);
    configureResourceBundles();
    IPackageResourceGuard packageResourceGuard = getResourceSettings().getPackageResourceGuard();
    if (packageResourceGuard instanceof SecurePackageResourceGuard) {
        SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;
        guard.addPattern("+org/apache/wicket/resource/jquery/*.map");
    }
    // enforce mounts so security interceptors based on URLs can't be fooled
    getSecuritySettings().setEnforceMounts(true);
    getSecuritySettings().setAuthorizationStrategy(new SimplePageAuthorizationStrategy(SecuredPage.class, getLoginPageClass()) {

        @Override
        protected boolean isAuthorized() {
            SecurityContext securityContext = SecurityContextHolder.getContext();
            if (securityContext != null) {
                Authentication authentication = securityContext.getAuthentication();
                if (authentication != null && authentication.isAuthenticated()) {
                    for (GrantedAuthority authority : authentication.getAuthorities()) {
                        if (authority.getAuthority().equals(UserConstants.ROLE_USER) || authority.getAuthority().equals(UserConstants.ROLE_ADMIN)) {
                            // allow access only for users/admins
                            return true;
                        }
                    }
                }
            }
            return false;
        }
    });
    getComponentInstantiationListeners().add(new SpringComponentInjector(this));
    getRequestCycleListeners().add(new AbstractRequestCycleListener() {

        @Override
        public IRequestHandler onException(RequestCycle cycle, Exception ex) {
            return new RenderPageRequestHandler(new PageProvider(new ExceptionPage(ex)));
        }
    });
    // add login page to every application based on this one (if enabled)
    Class<? extends BasePage> loginClass = getLoginPageClass();
    if (loginClass != null) {
        // login page
        mountPage("/login", loginClass);
        // user settings
        mountPage("/settings", UserSettingsPage.class);
        // about
        mountPage("/about", AboutPage.class);
        // contact
        mountPage("/contact", ContactPage.class);
        if (OpenIdLoginPage.class.equals(loginClass)) {
            // for OpenID auth also add page for new users
            mountPage("/new", NewUserPage.class);
        }
    }
}
Also used : WicketTheme(de.agilecoders.wicket.themes.markup.html.wicket.WicketTheme) IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) GoogleTheme(de.agilecoders.wicket.themes.markup.html.google.GoogleTheme) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SimplePageAuthorizationStrategy(org.apache.wicket.authorization.strategies.page.SimplePageAuthorizationStrategy) MetroTheme(de.agilecoders.wicket.themes.markup.html.metro.MetroTheme) Bootstrap3Theme(de.agilecoders.wicket.themes.markup.html.bootstrap3.Bootstrap3Theme) BootstrapSettings(de.agilecoders.wicket.core.settings.BootstrapSettings) IPackageResourceGuard(org.apache.wicket.markup.html.IPackageResourceGuard) SecurePackageResourceGuard(org.apache.wicket.markup.html.SecurePackageResourceGuard) Authentication(org.springframework.security.core.Authentication) PageProvider(org.apache.wicket.core.request.handler.PageProvider) AbstractRequestCycleListener(org.apache.wicket.request.cycle.AbstractRequestCycleListener) SecurityContext(org.springframework.security.core.context.SecurityContext) ExceptionPage(eu.esdihumboldt.hale.server.webapp.pages.ExceptionPage) SecuredPage(eu.esdihumboldt.hale.server.webapp.pages.SecuredPage) BootswatchThemeProvider(de.agilecoders.wicket.themes.settings.BootswatchThemeProvider) SpringComponentInjector(org.apache.wicket.spring.injection.annot.SpringComponentInjector) BootswatchThemeProvider(de.agilecoders.wicket.themes.settings.BootswatchThemeProvider) ThemeProvider(de.agilecoders.wicket.core.settings.ThemeProvider)

Example 3 with BootstrapSettings

use of de.agilecoders.wicket.core.settings.BootstrapSettings in project nutch by apache.

the class NutchUiApplication method init.

/**
 * @see org.apache.wicket.Application#init()
 */
@Override
public void init() {
    super.init();
    BootstrapSettings settings = new BootstrapSettings();
    Bootstrap.install(this, settings);
    configureTheme(settings);
    getComponentInstantiationListeners().add(new SpringComponentInjector(this, context));
}
Also used : BootstrapSettings(de.agilecoders.wicket.core.settings.BootstrapSettings) SpringComponentInjector(org.apache.wicket.spring.injection.annot.SpringComponentInjector)

Example 4 with BootstrapSettings

use of de.agilecoders.wicket.core.settings.BootstrapSettings in project ocvn by devgateway.

the class FormsWebApplication method configureBootstrap.

/**
 * configures wicket-bootstrap and installs the settings.
 */
private void configureBootstrap() {
    WicketWebjars.install(this);
    final IBootstrapSettings settings = new BootstrapSettings();
    // specify an empty bootstrap css resource so that we can have more
    // control when do we load the bootstrap styles.
    // By default all pages will load bootstrap.css file and there are
    // situations (like print page) when we don't need this styles.
    // The boostrap.css file is loaded as dependency in MainCss Instance
    // settings.setCssResourceReference(EmptyCss.INSTANCE);
    settings.useCdnResources(false);
    // use the default bootstrap theme
    Bootstrap.install(this, settings);
    BootstrapLess.install(this);
}
Also used : IBootstrapSettings(de.agilecoders.wicket.core.settings.IBootstrapSettings) BootstrapSettings(de.agilecoders.wicket.core.settings.BootstrapSettings) IBootstrapSettings(de.agilecoders.wicket.core.settings.IBootstrapSettings)

Example 5 with BootstrapSettings

use of de.agilecoders.wicket.core.settings.BootstrapSettings in project oc-explorer by devgateway.

the class FormsWebApplication method configureBootstrap.

/**
 * configures wicket-bootstrap and installs the settings.
 */
private void configureBootstrap() {
    WicketWebjars.install(this);
    final IBootstrapSettings settings = new BootstrapSettings();
    // specify an empty bootstrap css resource so that we can have more
    // control when do we load the bootstrap styles.
    // By default all pages will load bootstrap.css file and there are
    // situations (like print page) when we don't need this styles.
    // The boostrap.css file is loaded as dependency in MainCss Instance
    // settings.setCssResourceReference(EmptyCss.INSTANCE);
    settings.useCdnResources(false);
    // use the default bootstrap theme
    Bootstrap.install(this, settings);
    BootstrapLess.install(this);
}
Also used : IBootstrapSettings(de.agilecoders.wicket.core.settings.IBootstrapSettings) BootstrapSettings(de.agilecoders.wicket.core.settings.BootstrapSettings) IBootstrapSettings(de.agilecoders.wicket.core.settings.IBootstrapSettings)

Aggregations

BootstrapSettings (de.agilecoders.wicket.core.settings.BootstrapSettings)5 IBootstrapSettings (de.agilecoders.wicket.core.settings.IBootstrapSettings)3 SpringComponentInjector (org.apache.wicket.spring.injection.annot.SpringComponentInjector)2 SingleThemeProvider (de.agilecoders.wicket.core.settings.SingleThemeProvider)1 ThemeProvider (de.agilecoders.wicket.core.settings.ThemeProvider)1 Bootstrap3Theme (de.agilecoders.wicket.themes.markup.html.bootstrap3.Bootstrap3Theme)1 GoogleTheme (de.agilecoders.wicket.themes.markup.html.google.GoogleTheme)1 MetroTheme (de.agilecoders.wicket.themes.markup.html.metro.MetroTheme)1 WicketTheme (de.agilecoders.wicket.themes.markup.html.wicket.WicketTheme)1 BootswatchThemeProvider (de.agilecoders.wicket.themes.settings.BootswatchThemeProvider)1 ExceptionPage (eu.esdihumboldt.hale.server.webapp.pages.ExceptionPage)1 SecuredPage (eu.esdihumboldt.hale.server.webapp.pages.SecuredPage)1 Properties (java.util.Properties)1 ClassPathScanImplementationLookup (org.apache.syncope.client.console.init.ClassPathScanImplementationLookup)1 FilesystemResource (org.apache.syncope.client.console.resources.FilesystemResource)1 WorkflowDefGETResource (org.apache.syncope.client.console.resources.WorkflowDefGETResource)1 WorkflowDefPUTResource (org.apache.syncope.client.console.resources.WorkflowDefPUTResource)1 AdminLTE (org.apache.syncope.client.console.themes.AdminLTE)1 SimplePageAuthorizationStrategy (org.apache.wicket.authorization.strategies.page.SimplePageAuthorizationStrategy)1 MetaDataRoleAuthorizationStrategy (org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy)1