in sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java [521:585]
protected String resolveWelcomeBanner(ServerSession session) throws IOException {
Object bannerValue = CoreModuleProperties.WELCOME_BANNER.getOrNull(this);
if (bannerValue == null) {
return null;
}
if (bannerValue instanceof CharSequence) {
String message = bannerValue.toString();
if (GenericUtils.isEmpty(message)) {
return null;
}
if (CoreModuleProperties.AUTO_WELCOME_BANNER_VALUE.equalsIgnoreCase(message)) {
try {
return KeyRandomArt.combine(session, ' ', session.getKeyPairProvider());
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
}
if (!message.contains("://")) {
return message;
}
try {
bannerValue = new URI(message);
} catch (URISyntaxException e) {
log.error("resolveWelcomeBanner({}) bad path URI {}: {}", session, message, e.getMessage());
throw new MalformedURLException(
e.getClass().getSimpleName() + " - bad URI (" + message + "): " + e.getMessage());
}
if (message.startsWith("file:/")) {
bannerValue = Paths.get((URI) bannerValue);
}
}
if (bannerValue instanceof File) {
bannerValue = ((File) bannerValue).toPath();
}
if (bannerValue instanceof Path) {
Path path = (Path) bannerValue;
if ((!Files.exists(path)) || (Files.size(path) <= 0L)) {
if (log.isDebugEnabled()) {
log.debug("resolveWelcomeBanner({}) file is empty/does not exist {}", session, path);
}
return null;
}
bannerValue = path.toUri();
}
if (bannerValue instanceof URI) {
bannerValue = ((URI) bannerValue).toURL();
}
if (bannerValue instanceof URL) {
Charset cs = CoreModuleProperties.WELCOME_BANNER_CHARSET.getRequired(this);
return loadWelcomeBanner(session, (URL) bannerValue, cs);
}
return bannerValue.toString();
}