Search in sources :

Example 1 with CookieThemeResolver

use of org.springframework.web.servlet.theme.CookieThemeResolver in project cas by apereo.

the class CasThemesConfiguration method themeResolver.

@ConditionalOnMissingBean(name = "themeResolver")
@Bean
public ThemeResolver themeResolver() {
    final String defaultThemeName = casProperties.getTheme().getDefaultThemeName();
    final FixedThemeResolver fixedResolver = new FixedThemeResolver();
    fixedResolver.setDefaultThemeName(defaultThemeName);
    final SessionThemeResolver sessionThemeResolver = new SessionThemeResolver();
    sessionThemeResolver.setDefaultThemeName(defaultThemeName);
    final TicketGrantingCookieProperties tgc = casProperties.getTgc();
    final CookieThemeResolver cookieThemeResolver = new CookieThemeResolver();
    cookieThemeResolver.setDefaultThemeName(defaultThemeName);
    cookieThemeResolver.setCookieDomain(tgc.getDomain());
    cookieThemeResolver.setCookieHttpOnly(tgc.isHttpOnly());
    cookieThemeResolver.setCookieMaxAge(tgc.getMaxAge());
    cookieThemeResolver.setCookiePath(tgc.getPath());
    cookieThemeResolver.setCookieSecure(tgc.isSecure());
    final RegisteredServiceThemeResolver serviceThemeResolver = new RegisteredServiceThemeResolver(servicesManager, serviceThemeResolverSupportedBrowsers(), authenticationRequestServiceSelectionStrategies, this.resourceLoader, new CasConfigurationProperties());
    serviceThemeResolver.setDefaultThemeName(defaultThemeName);
    final RequestHeaderThemeResolver header = new RequestHeaderThemeResolver();
    header.setDefaultThemeName(defaultThemeName);
    final ChainingThemeResolver chainingThemeResolver = new ChainingThemeResolver();
    chainingThemeResolver.addResolver(cookieThemeResolver).addResolver(sessionThemeResolver).addResolver(header).addResolver(serviceThemeResolver).addResolver(fixedResolver);
    chainingThemeResolver.setDefaultThemeName(defaultThemeName);
    return chainingThemeResolver;
}
Also used : ChainingThemeResolver(org.apereo.cas.services.web.ChainingThemeResolver) FixedThemeResolver(org.springframework.web.servlet.theme.FixedThemeResolver) RequestHeaderThemeResolver(org.apereo.cas.services.web.RequestHeaderThemeResolver) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) RegisteredServiceThemeResolver(org.apereo.cas.services.web.RegisteredServiceThemeResolver) TicketGrantingCookieProperties(org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties) CookieThemeResolver(org.springframework.web.servlet.theme.CookieThemeResolver) SessionThemeResolver(org.springframework.web.servlet.theme.SessionThemeResolver) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 TicketGrantingCookieProperties (org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties)1 ChainingThemeResolver (org.apereo.cas.services.web.ChainingThemeResolver)1 RegisteredServiceThemeResolver (org.apereo.cas.services.web.RegisteredServiceThemeResolver)1 RequestHeaderThemeResolver (org.apereo.cas.services.web.RequestHeaderThemeResolver)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 CookieThemeResolver (org.springframework.web.servlet.theme.CookieThemeResolver)1 FixedThemeResolver (org.springframework.web.servlet.theme.FixedThemeResolver)1 SessionThemeResolver (org.springframework.web.servlet.theme.SessionThemeResolver)1