Skip to content

Commit

Permalink
Add ability to disable admin console
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>
  • Loading branch information
avpinchuk committed Feb 18, 2024
1 parent 3f006ec commit f0bce2b
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 5 deletions.
2 changes: 2 additions & 0 deletions nucleus/core/kernel/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2024 Contributors to the Eclipse Foundation.
Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -211,6 +212,7 @@
<include>com/sun/enterprise/v3/**/downloadgui.html</include>
<include>com/sun/enterprise/v3/**/status.html</include>
<include>com/sun/enterprise/v3/**/statusNotDAS.html</include>
<include>com/sun/enterprise/v3/**/statusDisabled.html</include>
<include>com/sun/enterprise/v3/**/asynch-1F.gif</include>
<include>com/sun/enterprise/v3/**/backimage.jpg</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -164,7 +165,6 @@ public HttpHandler getHttpService() {
*/
@Override
public void service(Request req, Response res) {

bundle = getResourceBundle(req.getLocale());

Method method = req.getMethod();
Expand All @@ -174,11 +174,17 @@ public void service(Request req, Response res) {
res.setHeader("Allow", getAllowedHttpMethodsAsString());
return;
}

if (!env.isDas()) {
sendStatusNotDAS(req, res);
return;
}

if (loadingOption == ConsoleLoadingOption.NEVER) {
sendStatusDisabled(req, res);
return;
}

//This is needed to support the case where user update to 3.1 from previous release, and didn't run the upgrade tool.
if (adminConsoleConfigUpgrade == null) {
adminConsoleConfigUpgrade = habitat.getService(AdminConsoleConfigUpgrade.class);
Expand Down Expand Up @@ -715,6 +721,19 @@ private void sendStatusNotDAS(Request req, Response res) {
}
}

private void sendStatusDisabled(Request request, Response response) {
try {
String html = Utils.packageResource2String("statusDisabled.html");
OutputBuffer outputBuffer = getOutputBuffer(response);
byte[] page = replaceTokens(html, bundle).getBytes(StandardCharsets.UTF_8);
response.setContentLength(page.length);
outputBuffer.write(page);
outputBuffer.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* <p> This method returns the resource bundle for localized Strings used
* by the AdminConsoleAdapter.</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -29,7 +30,6 @@
import org.glassfish.server.ServerEnvironmentImpl;
import org.jvnet.hk2.annotations.Optional;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.config.types.Property;

@Service(name = "AdminConsoleStartupService")
@RunLevel(PostStartupRunLevel.VAL)
Expand Down Expand Up @@ -76,7 +76,6 @@ public void postConstruct() {
case RECENT:
handleRecent();
break;
case NEVER:
case DEFAULT:
handleDefault();
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
# Copyright (c) 2024 Contributors to the Eclipse Foundation.
# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -60,6 +61,7 @@ state.upgradeFailed=Upgrade of Admin Console failed. Check file or directory pe


statusNotAvailable.pageTitle=Administration Console Not Available
statusNotAvailable.text=The Administration Console is available only from the Domain Administration Server. It is not accessible from a Server Instance.
statusNotAvailable.notDas=The Administration Console is available only from the Domain Administration Server. It is not accessible from a Server Instance.
statusNotAvailable.disabled=The Administration Console is disabled.

http.bad.method=method is not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!--
Copyright (c) 2024 Contributors to the Eclipse Foundation.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>%%%status.pageTitle%%%</title>

<style type="text/css">
a:link {color:#003399;text-decoration:none}
a:visited {color:#003399;text-decoration:none}
a:hover {color:#003399;text-decoration:underline}
body {font-family:Arial,Helvetica,sans-serif;font-size:76%;margin:0px;padding:0px;background:#4a5c6a;}
h1 {padding-top:50px;margin-top:0px;color:#46626e;font-size:21px;}
h2 {color:#46626e;font-size:16px;}
h4 {font-style:normal;font-size:.9em;color:#666;}
* html body {overflow:hidden;}
* html #footer-wrapper {float:left;position:relative;width:100%;padding-bottom:10010px;margin-bottom:-10000px;background:#4a5c6a;}
.subtitle {color:#000000;font-size:16px;font-weight:bold;}
.container {overflow:hidden;text-align:center;background:#d4dbe1;height:435px;}
.container .column {text-align:left;height:435px;margin:auto;width:540px;padding-left:300px;padding-right:40px;background-image:url(/backimage.jpg);background-repeat:no-repeat;background-color:#FFFFFF;}
.container #fields {margin-left:22px;margin-top:1em;}
#footer {clear:both;}
#header, #footer {font-size:small;text-align:center;padding:0.3em 0;background:#4a5c6a;height:20px;color:#FFFFFF;font-weight:bold;}
</style>
</head>

<body>
<div id="header"></div>
<div class="container">
<div id="center" class="column">
<!-- <div id="page_content"> -->
<h1>%%%product.title%%%</h1>
<p> <span class="subtitle">%%%statusNotAvailable.pageTitle%%%</span>
<br>%%%statusNotAvailable.disabled%%%</p>
<!-- don't change the names -->
</div>
</div>
<div id="footer-wrapper">
<div id="footer">%%%thankYou%%%</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<!--
Copyright (c) 2024 Contributors to the Eclipse Foundation.
Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -55,7 +56,7 @@
<!-- <div id="page_content"> -->
<h1>%%%product.title%%%</h1>
<p> <span class="subtitle">%%%statusNotAvailable.pageTitle%%%</span>
<br>%%%statusNotAvailable.text%%%</p>
<br>%%%statusNotAvailable.notDas%%%</p>
<!-- don't change the names -->
</div>
</div>
Expand Down

0 comments on commit f0bce2b

Please sign in to comment.