use of org.apereo.cas.util.spring.boot.DefaultCasBanner in project cas by apereo.
the class CasEmbeddedContainerUtils method getCasBannerInstance.
/**
* Gets cas banner instance.
*
* @return the cas banner instance
*/
public static Banner getCasBannerInstance() {
final String packageName = CasEmbeddedContainerUtils.class.getPackage().getName();
final Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(new FilterBuilder().includePackage(packageName)).setUrls(ClasspathHelper.forPackage(packageName)).setScanners(new SubTypesScanner(true)));
final Set<Class<? extends AbstractCasBanner>> subTypes = reflections.getSubTypesOf(AbstractCasBanner.class);
subTypes.remove(DefaultCasBanner.class);
if (subTypes.isEmpty()) {
return new DefaultCasBanner();
}
try {
final Class<? extends AbstractCasBanner> clz = subTypes.iterator().next();
LOGGER.debug("Created banner [{}]", clz);
return clz.getDeclaredConstructor().newInstance();
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return new DefaultCasBanner();
}
use of org.apereo.cas.util.spring.boot.DefaultCasBanner in project cas by apereo.
the class CasBannerProvider method getBanner.
@Override
public String getBanner() {
if (CasCommandLineParser.isSkippingBanner(environment)) {
return null;
}
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
final PrintStream ps = new PrintStream(baos, true, StandardCharsets.UTF_8.name());
new DefaultCasBanner().printBanner(environment, getClass(), ps);
final String content = new String(baos.toByteArray(), StandardCharsets.UTF_8);
return content;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return "CAS";
}
Aggregations