Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPSERV-54 Print a Warning if No Encryption Key Present #4542

Merged
merged 4 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2020] [Payara Foundation and/or its affiliates]

package org.glassfish.admingui.common.handlers;

Expand Down Expand Up @@ -272,6 +273,7 @@ public static void updateEntity(HandlerContext handlerCtx) {
return;
}

parseResponse(response, handlerCtx, endpoint, attrs, false, true);
handlerCtx.setOutputValue("result", endpoint);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2019 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2019-2020 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -147,6 +147,10 @@ protected static void assertSuccess(CommandResult result) {
}
}

protected static void assertWarning(CommandResult result) {
assertEquals(ExitStatus.WARNING, result.getExitStatus());
}

protected static void assertContains(String expected, String actual) {
assertThat(actual, CoreMatchers.containsString(expected));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2019 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2019-2020 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -68,4 +68,15 @@ public void autoIncrementPort() {
assertSuccess(result);
assertFalse(config.getAutoIncrementPort());
}

@Test
public void dataGridEncryptionWarning() {
CommandResult result = asadmin("set-hazelcast-configuration",
"--encryptdatagrid", "true");
assertWarning(result);
assertContains("Could not find datagrid-key", result.getOutput());
result = asadmin("set-hazelcast-configuration",
"--encryptdatagrid", "false");
assertSuccess(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import fish.payara.nucleus.hazelcast.HazelcastCore;
import fish.payara.nucleus.hazelcast.HazelcastRuntimeConfiguration;
import java.beans.PropertyVetoException;
import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
Expand Down Expand Up @@ -392,6 +393,10 @@ public Object run(final HazelcastConfigSpecificConfiguration hazelcastRuntimeCon
}
}

if (encryptDatagrid != null && encryptDatagrid) {
checkForDatagridKey(actionReport);
}

}

}
Expand Down Expand Up @@ -471,4 +476,13 @@ public String getTarget(ParameterMap pm) {
}
return result;
}

private void checkForDatagridKey(ActionReport actionReport) {
File datagridKey = new File(server.getConfigDirPath().getPath() + File.separator + "datagrid-key");
if (!datagridKey.exists()) {
actionReport.setActionExitCode(ActionReport.ExitCode.WARNING);
actionReport.appendMessage("Could not find datagrid-key in domain config directory. Please ensure" +
" that you generate one before restarting the domain.");
}
}
}