This is an automated email from the ASF dual-hosted git repository.
smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new c41230bde KNOX-3008 - Displaying hostname and custom banner text on
the Knox Home page and other UIs (#842)
c41230bde is described below
commit c41230bdeb64601235615447a3961570d6b1de08
Author: Sandor Molnar <[email protected]>
AuthorDate: Tue Feb 27 11:26:33 2024 +0100
KNOX-3008 - Displaying hostname and custom banner text on the Knox Home
page and other UIs (#842)
---
gateway-admin-ui/admin-ui/app/app.module.ts | 4 +++-
.../session.information.component.html | 2 ++
.../session.information.component.ts | 20 +++++++++++++++++++-
.../app/sessionInformation/session.information.ts | 1 +
gateway-release/home/conf/topologies/manager.xml | 3 +++
.../knox/gateway/config/impl/GatewayConfigImpl.java | 7 +++++++
gateway-service-metadata/pom.xml | 4 ++++
.../service/metadata/GeneralProxyInformation.java | 12 ++++++++++++
.../service/metadata/KnoxMetadataResource.java | 3 +++
.../gateway/service/session/SessionInformation.java | 11 +++++++++++
.../gateway/service/session/SessionResource.java | 1 +
.../org/apache/knox/gateway/GatewayTestConfig.java | 5 +++++
.../apache/knox/gateway/config/GatewayConfig.java | 6 ++++++
.../org/apache/knox/gateway/dto/HomePageProfile.java | 8 +++++---
.../apache/knox/gateway/dto/HomePageProfileTest.java | 4 ++--
knox-homepage-ui/home/app/app.module.ts | 4 +++-
.../general.proxy.information.component.html | 4 ++++
.../general.proxy.information.component.ts | 9 +++++++++
.../general.proxy.information.ts | 1 +
.../session.information.component.html | 1 +
.../session.information.component.ts | 20 +++++++++++++++++++-
.../app/sessionInformation/session.information.ts | 1 +
.../token-generation/app/app.module.ts | 3 ++-
.../app/session.information.component.html | 1 +
.../app/session.information.component.ts | 20 +++++++++++++++++++-
.../token-generation/app/token-generation.models.ts | 1 +
.../token-management/app/app.module.ts | 3 ++-
.../app/session.information.component.html | 2 ++
.../app/session.information.component.ts | 20 +++++++++++++++++++-
.../token-management/app/session.information.ts | 1 +
pom.xml | 13 +++++++++++++
31 files changed, 182 insertions(+), 13 deletions(-)
diff --git a/gateway-admin-ui/admin-ui/app/app.module.ts
b/gateway-admin-ui/admin-ui/app/app.module.ts
index 02c10ef0b..bc51ea9e9 100644
--- a/gateway-admin-ui/admin-ui/app/app.module.ts
+++ b/gateway-admin-ui/admin-ui/app/app.module.ts
@@ -48,6 +48,7 @@ import {ProviderConfigSelectorComponent} from
'./provider-config-selector/provid
import {NewDescWizardComponent} from
'./new-desc-wizard/new-desc-wizard.component';
import {ProviderConfigWizardComponent} from
'./provider-config-wizard/provider-config-wizard.component';
import {SessionInformationComponent} from
'./sessionInformation/session.information.component';
+import {SafeHtmlPipe} from
'./sessionInformation/session.information.component';
@NgModule({
imports: [BrowserModule,
@@ -76,7 +77,8 @@ import {SessionInformationComponent} from
'./sessionInformation/session.informat
ProviderConfigSelectorComponent,
NewDescWizardComponent,
ProviderConfigWizardComponent,
- SessionInformationComponent
+ SessionInformationComponent,
+ SafeHtmlPipe
],
providers: [TopologyService,
ServiceDefinitionService,
diff --git
a/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.html
b/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.html
index 77da6559e..9dd131f11 100644
---
a/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.html
+++
b/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.html
@@ -13,3 +13,5 @@
limitations under the License.
-->
<div style="text-align: right; color: rgb(130, 180, 93);">Logged in as {{
getUser() }}</div>
+<div style="margin-left: 15%; text-align: center; color: rgb(130,180, 93);
max-width: 70%; word-wrap: break-word;" [innerHTML]="getBannerText() |
safeHtml"></div>
+
diff --git
a/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.ts
b/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.ts
index 59ae3e549..e21e61264 100644
---
a/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.ts
+++
b/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.component.ts
@@ -14,10 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {Component, OnInit} from '@angular/core';
+import {Component, OnInit, Pipe, PipeTransform} from '@angular/core';
+import {DomSanitizer} from '@angular/platform-browser';
import {SessionInformationService} from './session.information.service';
import {SessionInformation} from './session.information';
+@Pipe({ name: 'safeHtml' })
+export class SafeHtmlPipe implements PipeTransform {
+ constructor(private sanitizer: DomSanitizer) {}
+
+ transform(value) {
+ return this.sanitizer.bypassSecurityTrustHtml(value);
+ }
+}
+
@Component({
selector: 'app-session-information',
templateUrl: './session.information.component.html',
@@ -42,6 +52,14 @@ export class SessionInformationComponent implements OnInit {
}
}
+ getBannerText() {
+ if (this.sessionInformation) {
+ console.debug('SessionInformationComponent --> getBannerHtml() -->
' + this.sessionInformation.bannerText);
+ return this.sessionInformation.bannerText;
+ }
+ return '';
+ }
+
ngOnInit(): void {
console.debug('SessionInformationComponent --> ngOnInit() --> ');
this.sessionInformationService.getSessionInformation()
diff --git
a/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.ts
b/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.ts
index 549bb09dd..8bdefe3d7 100644
--- a/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.ts
+++ b/gateway-admin-ui/admin-ui/app/sessionInformation/session.information.ts
@@ -20,4 +20,5 @@ export class SessionInformation {
logoutUrl: string;
logoutPageUrl: string;
globalLgoutPageUrl: string;
+ bannerText: string;
}
diff --git a/gateway-release/home/conf/topologies/manager.xml
b/gateway-release/home/conf/topologies/manager.xml
index 1634d0093..c2531f06f 100644
--- a/gateway-release/home/conf/topologies/manager.xml
+++ b/gateway-release/home/conf/topologies/manager.xml
@@ -86,6 +86,9 @@
<service>
<role>KNOX</role>
</service>
+ <service>
+ <role>KNOX-SESSION</role>
+ </service>
<application>
<name>admin-ui</name>
</application>
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
index a5d10a099..01858a597 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
@@ -324,6 +324,8 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
private static final String GLOBAL_LOGOUT_PAGE_URL =
"knox.global.logout.page.url";
private static final String KNOX_INCOMING_XFORWARDED_ENABLED =
"gateway.incoming.xforwarded.enabled";
+ private static final String UI_BANNER_TEXT = GATEWAY_CONFIG_FILE_PREFIX +
".ui.banner.text";
+
//Gateway Database related properties
public static final String GATEWAY_DATABASE_TYPE =
GATEWAY_CONFIG_FILE_PREFIX + ".database.type";
public static final String GATEWAY_DATABASE_CONN_URL =
GATEWAY_CONFIG_FILE_PREFIX + ".database.connection.url";
@@ -1571,4 +1573,9 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
return get(HTTP_CLIENT_COOKIE_SPEC);
}
+ @Override
+ public String getBannerText() {
+ return get(UI_BANNER_TEXT, "");
+ }
+
}
diff --git a/gateway-service-metadata/pom.xml b/gateway-service-metadata/pom.xml
index d4d2fc033..674e782ab 100644
--- a/gateway-service-metadata/pom.xml
+++ b/gateway-service-metadata/pom.xml
@@ -78,5 +78,9 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.kstruct</groupId>
+ <artifactId>gethostname4j</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
index c05c1487c..4935c4740 100644
---
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
+++
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/GeneralProxyInformation.java
@@ -31,6 +31,10 @@ public class GeneralProxyInformation {
@ApiModelProperty(value = "The version of this Knox Gateway")
private String version;
+ @XmlElement
+ @ApiModelProperty(value = "The name of the host where this Knox Gateway is
running")
+ private String hostname;
+
@XmlElement
@ApiModelProperty(value = "The Admin UI URL")
private String adminUiUrl;
@@ -59,6 +63,14 @@ public class GeneralProxyInformation {
this.version = version;
}
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
public String getAdminUiUrl() {
return adminUiUrl;
}
diff --git
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
index d50283c39..7af07fc0b 100644
---
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
+++
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
@@ -72,6 +72,8 @@ import org.apache.knox.gateway.topology.Topology;
import org.apache.knox.gateway.util.JsonUtils;
import org.apache.knox.gateway.util.X509CertificateUtil;
+import com.kstruct.gethostname4j.Hostname;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -101,6 +103,7 @@ public class KnoxMetadataResource {
final ServerInfoService serviceInfoService =
gatewayServices.getService(ServiceType.SERVER_INFO_SERVICE);
final String versionInfo = serviceInfoService.getBuildVersion() + "
(hash=" + serviceInfoService.getBuildHash() + ")";
proxyInfo.setVersion(versionInfo);
+ proxyInfo.setHostname(Hostname.getHostname());
proxyInfo.setAdminApiBookUrl(
String.format(Locale.ROOT,
"https://knox.apache.org/books/knox-%s/user-guide.html#Admin+API",
getAdminApiBookVersion(serviceInfoService.getBuildVersion())));
final GatewayConfig config = (GatewayConfig)
request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
diff --git
a/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionInformation.java
b/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionInformation.java
index d572ebf5d..638979e4b 100644
---
a/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionInformation.java
+++
b/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionInformation.java
@@ -40,6 +40,9 @@ public class SessionInformation {
@XmlElement
private String currentKnoxSsoCookieTokenId;
+ @XmlElement
+ private String bannerText;
+
public String getUser() {
return user;
}
@@ -88,4 +91,12 @@ public class SessionInformation {
this.currentKnoxSsoCookieTokenId = currentKnoxSsoCookieTokenId;
}
+ public String getBannerText() {
+ return bannerText;
+ }
+
+ public void setBannerText(String bannerText) {
+ this.bannerText = bannerText;
+ }
+
}
diff --git
a/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionResource.java
b/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionResource.java
index 2a2cd8602..610126145 100644
---
a/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionResource.java
+++
b/gateway-service-session/src/main/java/org/apache/knox/gateway/service/session/SessionResource.java
@@ -68,6 +68,7 @@ public class SessionResource {
}
sessionInfo.setCanSeeAllTokens(config != null ?
config.canSeeAllTokens(user) : false);
sessionInfo.setCurrentKnoxSsoCookieTokenId((String)
this.request.getAttribute(TokenUtils.ATTR_CURRENT_KNOXSSO_COOKIE_TOKEN_ID));
+ sessionInfo.setBannerText(config != null ? config.getBannerText() : "");
return sessionInfo;
}
diff --git
a/gateway-spi-common/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
b/gateway-spi-common/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
index b5a630300..b179b0a9c 100644
---
a/gateway-spi-common/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
+++
b/gateway-spi-common/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
@@ -1111,4 +1111,9 @@ public class GatewayTestConfig extends Configuration
implements GatewayConfig {
return null;
}
+ @Override
+ public String getBannerText() {
+ return null;
+ }
+
}
diff --git
a/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
b/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
index f2534dbb6..c2cbc3692 100644
---
a/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
+++
b/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
@@ -938,4 +938,10 @@ public interface GatewayConfig {
* @return CookieSpec for the HTTP client used by the dispatch, see
org.apache.http.client.config.CookieSpecs
*/
String getHttpClientCookieSpec();
+
+ /**
+ * @return a text that should be displayed on all Knox UIs within the banner
on the top.
+ */
+ String getBannerText();
+
}
diff --git
a/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
b/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
index cd2bb560e..213947342 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
@@ -27,6 +27,7 @@ import java.util.Set;
public class HomePageProfile {
static final String GPI_PREFIX = "gpi_";
static final String GPI_VERSION = GPI_PREFIX + "version";
+ static final String GPI_HOSTNAME = GPI_PREFIX + "hostname";
static final String GPI_CERT = GPI_PREFIX + "cert";
static final String GPI_ADMIN_UI = GPI_PREFIX + "admin_ui";
static final String GPI_ADMIN_API = GPI_PREFIX + "admin_api";
@@ -41,6 +42,7 @@ public class HomePageProfile {
public HomePageProfile(Collection<String> profileConfiguration) {
addElement(GPI_VERSION, profileConfiguration);
+ addElement(GPI_HOSTNAME, profileConfiguration);
addElement(GPI_CERT, profileConfiguration);
addElement(GPI_ADMIN_UI, profileConfiguration);
addElement(GPI_ADMIN_API, profileConfiguration);
@@ -73,14 +75,14 @@ public class HomePageProfile {
}
public static Collection<String> getFullProfileElements() {
- return Arrays.asList(GPI_VERSION, GPI_CERT, GPI_ADMIN_UI, GPI_ADMIN_API,
GPI_METADATA_API, GPI_TOKENS, GPI_WEBSHELL);
+ return Arrays.asList(GPI_VERSION, GPI_HOSTNAME, GPI_CERT, GPI_ADMIN_UI,
GPI_ADMIN_API, GPI_METADATA_API, GPI_TOKENS, GPI_WEBSHELL);
}
public static Collection<String> getThinProfileElemens() {
- return Arrays.asList(GPI_VERSION, GPI_CERT);
+ return Arrays.asList(GPI_VERSION, GPI_HOSTNAME, GPI_CERT);
}
public static Collection<String> getTokenProfileElements() {
- return Arrays.asList(GPI_VERSION, GPI_CERT, GPI_TOKENS);
+ return Arrays.asList(GPI_VERSION, GPI_HOSTNAME, GPI_CERT, GPI_TOKENS);
}
}
diff --git
a/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
b/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
index 67aff4d62..c52d5cd8f 100644
---
a/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
+++
b/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
@@ -32,7 +32,7 @@ public class HomePageProfileTest {
@Test
public void testEmptyConfiguration() throws Exception {
final HomePageProfile profile = new
HomePageProfile(Collections.emptySet());
- assertEquals(8, profile.getProfileElements().size());
+ assertEquals(9, profile.getProfileElements().size());
profile.getProfileElements().forEach((key, value) -> {
if (key.startsWith(HomePageProfile.GPI_PREFIX)) {
assertFalse(Boolean.parseBoolean(value));
@@ -75,7 +75,7 @@ public class HomePageProfileTest {
@Test
public void testTokenProfileElements() throws Exception {
final Collection<String> tokenProfileElements =
HomePageProfile.getTokenProfileElements();
- assertEquals(3, tokenProfileElements.size());
+ assertEquals(4, tokenProfileElements.size());
assertTrue(tokenProfileElements.containsAll(Arrays.asList(HomePageProfile.GPI_VERSION,
HomePageProfile.GPI_CERT, HomePageProfile.GPI_TOKENS)));
}
diff --git a/knox-homepage-ui/home/app/app.module.ts
b/knox-homepage-ui/home/app/app.module.ts
index 79019acd3..b59429edc 100644
--- a/knox-homepage-ui/home/app/app.module.ts
+++ b/knox-homepage-ui/home/app/app.module.ts
@@ -26,6 +26,7 @@ import {APP_BASE_HREF} from '@angular/common';
import {GeneralProxyInformationComponent} from
'./generalProxyInformation/general.proxy.information.component';
import {TopologyInformationsComponent} from
'./topologies/topology.information.component';
import {SessionInformationComponent} from
'./sessionInformation/session.information.component';
+import {SafeHtmlPipe} from
'./sessionInformation/session.information.component';
import {HomepageService} from './homepage.service';
@NgModule({
@@ -39,7 +40,8 @@ import {HomepageService} from './homepage.service';
],
declarations: [GeneralProxyInformationComponent,
TopologyInformationsComponent,
- SessionInformationComponent
+ SessionInformationComponent,
+ SafeHtmlPipe
],
providers: [HomepageService,
{
diff --git
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
index 0596cc516..8299e5ca1 100644
---
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
+++
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
@@ -26,6 +26,10 @@
<td>Knox Version</td>
<td>{{ getVersion() }}</td>
</tr>
+ <tr *ngIf="this['showKnoxHostname']">
+ <td>Hostname</td>
+ <td>{{ getHostname() }}</td>
+ </tr>
<tr *ngIf="this['showPublicCerts']">
<td>TLS Public Certificate</td>
<td>
diff --git
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
index b81bb60d1..3143ed4e1 100644
---
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
+++
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
@@ -33,6 +33,7 @@ export class GeneralProxyInformationComponent implements
OnInit {
constructor(private homepageService: HomepageService, private route:
ActivatedRoute) {
this['showGeneralProxyInformation'] = false;
this['showKnoxVersion'] = true;
+ this['showKnoxHostname'] = true;
this['showPublicCerts'] = true;
this['showAdminUI'] = true;
this['showAdminAPI'] = true;
@@ -48,6 +49,13 @@ export class GeneralProxyInformationComponent implements
OnInit {
return '';
}
+ getHostname() {
+ if (this.generalProxyInformation) {
+ return this.generalProxyInformation.hostname;
+ }
+ return '';
+ }
+
getAdminUiUrl() {
if (this.generalProxyInformation) {
return this.generalProxyInformation.adminUiUrl;
@@ -118,6 +126,7 @@ export class GeneralProxyInformationComponent implements
OnInit {
setProfileFlags(profile: JSON) {
console.debug('Setting GPI profile flags...');
this['showKnoxVersion'] = (profile['gpi_version'] === 'true');
+ this['showKnoxHostname'] = (profile['gpi_hostname'] === 'true');
this['showPublicCerts'] = (profile['gpi_cert'] === 'true');
this['showAdminUI'] = (profile['gpi_admin_ui'] === 'true');
this['showAdminAPI'] = (profile['gpi_admin_api'] === 'true');
diff --git
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.ts
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.ts
index cfdfd674d..3efe82389 100644
---
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.ts
+++
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.ts
@@ -17,6 +17,7 @@
export class GeneralProxyInformation {
version: string;
+ hostname: string;
adminUiUrl: string;
webShellUrl: string;
adminApiBookUrl: string;
diff --git
a/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
b/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
index 5a6e41991..2860a89e8 100644
---
a/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
+++
b/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
@@ -14,3 +14,4 @@
-->
<div style="text-align: right; color: rgb(130, 180, 93);">Welcome {{ getUser()
}}</div>
<div *ngIf="logoutSupported" style="text-align: right;"><a class="btn
btn-primary" (click)="logout()">logout</a></div>
+<div style="margin-left: 15%; text-align: center; color: rgb(130,180, 93);
max-width: 70%; word-wrap: break-word;" [innerHTML]="getBannerText() |
safeHtml"></div>
diff --git
a/knox-homepage-ui/home/app/sessionInformation/session.information.component.ts
b/knox-homepage-ui/home/app/sessionInformation/session.information.component.ts
index 75f3fe95b..0f7b63da9 100644
---
a/knox-homepage-ui/home/app/sessionInformation/session.information.component.ts
+++
b/knox-homepage-ui/home/app/sessionInformation/session.information.component.ts
@@ -14,10 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {Component, OnInit} from '@angular/core';
+import {Component, OnInit, Pipe, PipeTransform} from '@angular/core';
+import {DomSanitizer} from '@angular/platform-browser';
import {HomepageService} from '../homepage.service';
import {SessionInformation} from './session.information';
+@Pipe({ name: 'safeHtml' })
+export class SafeHtmlPipe implements PipeTransform {
+ constructor(private sanitizer: DomSanitizer) {}
+
+ transform(value) {
+ return this.sanitizer.bypassSecurityTrustHtml(value);
+ }
+}
+
@Component({
selector: 'app-session-information',
templateUrl: './session.information.component.html',
@@ -59,6 +69,14 @@ export class SessionInformationComponent implements OnInit {
return null;
}
+ getBannerText() {
+ if (this.sessionInformation) {
+ console.debug('SessionInformationComponent --> getBannerHtml() -->
' + this.sessionInformation.bannerText);
+ return this.sessionInformation.bannerText;
+ }
+ return '';
+ }
+
logout() {
console.debug('SessionInformationComponent --> attempting logout() -->
');
if (this.sessionInformation) {
diff --git
a/knox-homepage-ui/home/app/sessionInformation/session.information.ts
b/knox-homepage-ui/home/app/sessionInformation/session.information.ts
index 549bb09dd..8bdefe3d7 100644
--- a/knox-homepage-ui/home/app/sessionInformation/session.information.ts
+++ b/knox-homepage-ui/home/app/sessionInformation/session.information.ts
@@ -20,4 +20,5 @@ export class SessionInformation {
logoutUrl: string;
logoutPageUrl: string;
globalLgoutPageUrl: string;
+ bannerText: string;
}
diff --git a/knox-token-generation-ui/token-generation/app/app.module.ts
b/knox-token-generation-ui/token-generation/app/app.module.ts
index a5962de1d..1ff7d3044 100644
--- a/knox-token-generation-ui/token-generation/app/app.module.ts
+++ b/knox-token-generation-ui/token-generation/app/app.module.ts
@@ -21,13 +21,14 @@ import { TokenGenerationComponent } from
'./token-generation.component';
import { ReactiveFormsModule } from '@angular/forms';
import { TokenGenService } from './token-generation.service';
import { SessionInformationComponent } from './session.information.component';
+import { SafeHtmlPipe } from './session.information.component';
@NgModule({
imports: [BrowserModule,
HttpClientModule,
ReactiveFormsModule
],
- declarations: [TokenGenerationComponent, SessionInformationComponent],
+ declarations: [TokenGenerationComponent, SessionInformationComponent,
SafeHtmlPipe],
providers: [TokenGenService],
bootstrap: [TokenGenerationComponent, SessionInformationComponent]
})
diff --git
a/knox-token-generation-ui/token-generation/app/session.information.component.html
b/knox-token-generation-ui/token-generation/app/session.information.component.html
index c81cdcd1d..7250e0166 100644
---
a/knox-token-generation-ui/token-generation/app/session.information.component.html
+++
b/knox-token-generation-ui/token-generation/app/session.information.component.html
@@ -14,3 +14,4 @@
-->
<!-- The text color is the same as the Cloudera logo's color -->
<div style="text-align: right; color: rgb(130, 180, 93);">Logged in as {{
getUser() }}</div>
+<div style="margin-left: 15%; text-align: center; color: rgb(130,180, 93);
max-width: 70%; word-wrap: break-word;" [innerHTML]="getBannerText() |
safeHtml"></div>
diff --git
a/knox-token-generation-ui/token-generation/app/session.information.component.ts
b/knox-token-generation-ui/token-generation/app/session.information.component.ts
index 01d472804..618d67b5b 100644
---
a/knox-token-generation-ui/token-generation/app/session.information.component.ts
+++
b/knox-token-generation-ui/token-generation/app/session.information.component.ts
@@ -14,10 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {Component, OnInit} from '@angular/core';
+import {Component, OnInit, Pipe, PipeTransform} from '@angular/core';
+import {DomSanitizer} from '@angular/platform-browser';
import {TokenGenService} from './token-generation.service';
import {SessionInformation} from './token-generation.models';
+@Pipe({ name: 'safeHtml' })
+export class SafeHtmlPipe implements PipeTransform {
+ constructor(private sanitizer: DomSanitizer) {}
+
+ transform(value) {
+ return this.sanitizer.bypassSecurityTrustHtml(value);
+ }
+}
+
@Component({
selector: 'app-session-information',
templateUrl: './session.information.component.html',
@@ -42,6 +52,14 @@ export class SessionInformationComponent implements OnInit {
}
}
+ getBannerText() {
+ if (this.sessionInformation) {
+ console.debug('SessionInformationComponent --> getBannerHtml() -->
' + this.sessionInformation.bannerText);
+ return this.sessionInformation.bannerText;
+ }
+ return '';
+ }
+
ngOnInit(): void {
console.debug('SessionInformationComponent --> ngOnInit() --> ');
this.tokenGenerationService.getSessionInformation()
diff --git
a/knox-token-generation-ui/token-generation/app/token-generation.models.ts
b/knox-token-generation-ui/token-generation/app/token-generation.models.ts
index f419c800a..c14e6ea66 100644
--- a/knox-token-generation-ui/token-generation/app/token-generation.models.ts
+++ b/knox-token-generation-ui/token-generation/app/token-generation.models.ts
@@ -58,4 +58,5 @@ export class SessionInformation {
globalLgoutPageUrl: string;
canSeeAllTokens: boolean;
currentKnoxSsoCookieTokenId: string;
+ bannerText: string;
}
diff --git a/knox-token-management-ui/token-management/app/app.module.ts
b/knox-token-management-ui/token-management/app/app.module.ts
index 7ec5e55fe..f64a49437 100644
--- a/knox-token-management-ui/token-management/app/app.module.ts
+++ b/knox-token-management-ui/token-management/app/app.module.ts
@@ -33,6 +33,7 @@ import {FormsModule, ReactiveFormsModule} from
'@angular/forms';
import {TokenManagementComponent} from './token.management.component';
import {TokenManagementService} from './token.management.service';
import {SessionInformationComponent} from './session.information.component';
+import {SafeHtmlPipe} from './session.information.component';
@NgModule({
imports: [BrowserModule,
@@ -53,7 +54,7 @@ import {SessionInformationComponent} from
'./session.information.component';
MatSlideToggleModule,
MatCheckboxModule
],
- declarations: [TokenManagementComponent, SessionInformationComponent],
+ declarations: [TokenManagementComponent, SessionInformationComponent,
SafeHtmlPipe],
providers: [TokenManagementService],
bootstrap: [TokenManagementComponent, SessionInformationComponent]
})
diff --git
a/knox-token-management-ui/token-management/app/session.information.component.html
b/knox-token-management-ui/token-management/app/session.information.component.html
index c81cdcd1d..30a7de284 100644
---
a/knox-token-management-ui/token-management/app/session.information.component.html
+++
b/knox-token-management-ui/token-management/app/session.information.component.html
@@ -14,3 +14,5 @@
-->
<!-- The text color is the same as the Cloudera logo's color -->
<div style="text-align: right; color: rgb(130, 180, 93);">Logged in as {{
getUser() }}</div>
+<div style="margin-left: 15%; text-align: center; color: rgb(130,180, 93);
max-width: 70%; word-wrap: break-word;" [innerHTML]="getBannerText() |
safeHtml"></div>
+
diff --git
a/knox-token-management-ui/token-management/app/session.information.component.ts
b/knox-token-management-ui/token-management/app/session.information.component.ts
index 9c2038daa..3475d2202 100644
---
a/knox-token-management-ui/token-management/app/session.information.component.ts
+++
b/knox-token-management-ui/token-management/app/session.information.component.ts
@@ -14,10 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {Component, OnInit} from '@angular/core';
+import {Component, OnInit, Pipe, PipeTransform} from '@angular/core';
+import {DomSanitizer} from '@angular/platform-browser';
import {TokenManagementService} from './token.management.service';
import {SessionInformation} from './session.information';
+@Pipe({ name: 'safeHtml' })
+export class SafeHtmlPipe implements PipeTransform {
+ constructor(private sanitizer: DomSanitizer) {}
+
+ transform(value) {
+ return this.sanitizer.bypassSecurityTrustHtml(value);
+ }
+}
+
@Component({
selector: 'app-session-information',
templateUrl: './session.information.component.html',
@@ -42,6 +52,14 @@ export class SessionInformationComponent implements OnInit {
}
}
+ getBannerText() {
+ if (this.sessionInformation) {
+ console.debug('SessionInformationComponent --> getBannerHtml() -->
' + this.sessionInformation.bannerText);
+ return this.sessionInformation.bannerText;
+ }
+ return '';
+ }
+
ngOnInit(): void {
console.debug('SessionInformationComponent --> ngOnInit() --> ');
this.tokenManagementService.getSessionInformation()
diff --git
a/knox-token-management-ui/token-management/app/session.information.ts
b/knox-token-management-ui/token-management/app/session.information.ts
index 7d64b026b..5107aafad 100644
--- a/knox-token-management-ui/token-management/app/session.information.ts
+++ b/knox-token-management-ui/token-management/app/session.information.ts
@@ -22,4 +22,5 @@ export class SessionInformation {
globalLgoutPageUrl: string;
canSeeAllTokens: boolean;
currentKnoxSsoCookieTokenId: string;
+ bannerText: string;
}
diff --git a/pom.xml b/pom.xml
index f165c8004..5e23d2424 100644
--- a/pom.xml
+++ b/pom.xml
@@ -203,6 +203,7 @@
<findsecbugs-plugin.version>1.11.0</findsecbugs-plugin.version>
<forbiddenapis.version>3.1</forbiddenapis.version>
<frontend-maven-plugin.version>1.11.0</frontend-maven-plugin.version>
+ <gethostname4j.version>1.0.0</gethostname4j.version> <!-- See here:
https://github.com/mattsheppard/gethostname4j -->
<glassfish-jaxb.version>2.3.3</glassfish-jaxb.version>
<gson.version>2.8.9</gson.version>
<groovy.version>3.0.7</groovy.version>
@@ -1561,6 +1562,18 @@
<version>${gson.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.kstruct</groupId>
+ <artifactId>gethostname4j</artifactId>
+ <version>${gethostname4j.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>net.java.dev.jna</groupId>
+ <artifactId>jna-platform</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>