From 66d95bc1e5ed202eb42a2bbf02e96d8f8722e5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 26 Aug 2024 19:09:21 +0200 Subject: [PATCH] The common-util: Fixed dependencies on default charset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The asenv.conf file must be UTF-8 by default - it is provided by us. - Property files are Latin1 aka ISO-8859-1 by default. - ProcessStreamDrainerWorker still uses default charset but was formatted. - XmlParserHelper was not used so I deleted it - FileUtils - Explicit usage of GC allowed here - Fixed dependencies on system default charset - added parameter - However line endings are still taken from system; it is ok for all actual usages (PEM file allows CRLF, CR, LF, pid file doesn't have line ending) and I added that to javadoc. - PayloadImpl now converts string to utf8 byte array, not system default charset - ServerDirs - local paswordfile is UTF-8 encoded, not system default charset - SSHUtil - PEM files use Latin1 and all types of line endings are allowed. - AsadminInput - still use system defaut charset. Controversial. - FileRealmHelper - Using UTF-8 Signed-off-by: David Matějček --- .../servermgmt/services/WindowsService.java | 5 +- .../glassfish/cluster/ssh/util/SSHUtil.java | 13 +-- .../com/sun/appserv/server/util/Version.java | 6 +- .../security/store/PasswordAdapter.java | 7 +- .../glassfish/ASenvPropertyReader.java | 4 +- .../universal/process/ProcessManager.java | 8 +- .../process/ProcessStreamDrainerWorker.java | 57 ++++++------ .../universal/process/ProcessUtils.java | 7 +- .../universal/xml/MiniXmlParser.java | 5 +- .../universal/xml/XmlParserHelper.java | 71 --------------- .../com/sun/enterprise/util/io/FileUtils.java | 11 ++- .../sun/enterprise/util/io/ServerDirs.java | 6 +- .../glassfish/admin/payload/PayloadImpl.java | 20 ++--- .../common/util/admin/AsadminInput.java | 12 +-- .../common/util/admin/ManPageFinder.java | 29 ++++--- .../security/common/FileRealmHelper.java | 75 +++++----------- .../security/common/LocalStrings.properties | 2 +- .../payload/PayloadFilesManagerTest.java | 43 ++-------- .../admin/payload/PayloadImplTest.java | 20 +++-- .../util/admin/locking/FileLockTest.java | 86 ++++++++++--------- .../src/main/resources/config/asenv.bat | 2 + .../src/main/resources/config/asenv.conf | 2 + 22 files changed, 192 insertions(+), 299 deletions(-) delete mode 100644 nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/XmlParserHelper.java diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/WindowsService.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/WindowsService.java index 11acfd7dc88..462beac2e46 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/WindowsService.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/WindowsService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -39,6 +39,7 @@ import static com.sun.enterprise.admin.servermgmt.services.Constants.START_ARG_START; import static com.sun.enterprise.admin.servermgmt.services.Constants.STOP_ARG_END; import static com.sun.enterprise.admin.servermgmt.services.Constants.STOP_ARG_START; +import static java.nio.charset.StandardCharsets.UTF_8; /** * Warning: there is lots of file twiddling going on in this class. It is the nature of the beast. @@ -300,7 +301,7 @@ private void install() throws ProcessManagerException { if (info.dryRun) { try { // dry-run not so useful on Windows. Very useful on UNIX... - xmlFileCopy = Strings.get("xmlfiledump") + FileUtils.readSmallFile(targetXml); + xmlFileCopy = Strings.get("xmlfiledump") + FileUtils.readSmallFile(targetXml, UTF_8); } catch (IOException ex) { // oh well.... } diff --git a/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/SSHUtil.java b/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/SSHUtil.java index 35df2c71a17..93c9b0eff4b 100644 --- a/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/SSHUtil.java +++ b/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/SSHUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -29,13 +29,14 @@ import org.glassfish.api.admin.CommandException; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + /** * @author Rajiv Mordani */ public class SSHUtil { private static final List activeConnections = new ArrayList<>(); - private static final String NL = System.lineSeparator(); /** * Registers a connection for cleanup when the plugin is stopped. @@ -98,9 +99,9 @@ public static File getDefaultKeyFile() { public static boolean isEncryptedKey(File keyFile) throws CommandException { boolean res = false; try { - String f = FileUtils.readSmallFile(keyFile); + String f = FileUtils.readSmallFile(keyFile, ISO_8859_1).trim(); if (f.startsWith("-----BEGIN ") && f.contains("ENCRYPTED") - && f.endsWith(" PRIVATE KEY-----" + NL)) { + && f.endsWith(" PRIVATE KEY-----")) { res=true; } } @@ -124,11 +125,11 @@ public static boolean validateKeyFile(File file) throws CommandException { if (!file.getName().endsWith(".pub")) { String key = null; try { - key = FileUtils.readSmallFile(file); + key = FileUtils.readSmallFile(file, ISO_8859_1).trim(); } catch (IOException ioe) { throw new CommandException(Strings.get("unable.to.read.key", file, ioe.getMessage())); } - if (!key.startsWith("-----BEGIN ") && !key.endsWith(" PRIVATE KEY-----" + NL)) { + if (!key.startsWith("-----BEGIN ") && !key.endsWith(" PRIVATE KEY-----")) { throw new CommandException(Strings.get("invalid.key.file", file)); } } diff --git a/nucleus/common/common-util/src/main/java/com/sun/appserv/server/util/Version.java b/nucleus/common/common-util/src/main/java/com/sun/appserv/server/util/Version.java index 3244c5d0263..e167cf5ba8e 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/appserv/server/util/Version.java +++ b/nucleus/common/common-util/src/main/java/com/sun/appserv/server/util/Version.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 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 @@ -31,6 +31,8 @@ import java.util.Map; import java.util.Properties; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + /** * This class provides static methods to make accessible the version as well as * the individual parts that make up the version @@ -232,7 +234,7 @@ private static Properties loadVersionProp() { File directory = new File(installRoot).toPath().resolve(Path.of("config", "branding")).toFile(); if (directory.isDirectory()) { for (File file : directory.listFiles(f1 -> f1.getName().endsWith(".properties") && f1.canRead())) { - try (FileReader fr = new FileReader(file)) { + try (FileReader fr = new FileReader(file, ISO_8859_1)) { Properties p = new Properties(); p.load(fr); VERSION_PROPERTIES.add(p); diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/PasswordAdapter.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/PasswordAdapter.java index 56d892858d1..bc439741d20 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/PasswordAdapter.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/PasswordAdapter.java @@ -1,4 +1,5 @@ /* + * 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 @@ -20,6 +21,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.Charset; import java.security.Key; import java.security.KeyStore; import java.security.KeyStoreException; @@ -131,7 +133,7 @@ public synchronized String getPasswordForAlias(final String alias) final Key key = _pwdStore.getKey(alias, getMasterPassword()); if (key != null) { - passwordString = new String(key.getEncoded()); + passwordString = new String(key.getEncoded(), Charset.defaultCharset()); } return passwordString; @@ -251,8 +253,7 @@ private KeyStore duplicateKeyStore(final char[] newMasterPassword) */ private static void writeKeyStoreToFile(final KeyStore keyStore, final File file, final char[] masterPassword) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { - final FileOutputStream out = new FileOutputStream(file); - try (out) { + try (FileOutputStream out = new FileOutputStream(file)) { keyStore.store(out, masterPassword); } } diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java index 69590ad6370..9d0336cccfe 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -40,6 +41,7 @@ import static com.sun.enterprise.util.SystemPropertyConstants.PRODUCT_ROOT_PROPERTY; import static com.sun.enterprise.util.SystemPropertyConstants.UNIX_ASENV_FILENAME; import static com.sun.enterprise.util.SystemPropertyConstants.WINDOWS_ASENV_FILENAME; +import static java.nio.charset.StandardCharsets.UTF_8; /** * Class ASenvPropertyReader @@ -237,7 +239,7 @@ private void setProperties(File configDir) { BufferedReader reader = null; try { - reader = new BufferedReader(new FileReader(asenv)); + reader = new BufferedReader(new FileReader(asenv, UTF_8)); String line; while ((line = reader.readLine()) != null) { setProperty(line); diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessManager.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessManager.java index a402847d2c1..1bc04fa38c5 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessManager.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -27,6 +27,7 @@ import java.io.PrintWriter; import java.lang.System.Logger; import java.lang.System.Logger.Level; +import java.nio.charset.Charset; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -186,7 +187,8 @@ private void writeStdin(Process process) throws ProcessManagerException { if (process == null) { throw new ProcessManagerException("Parameter process was null."); } - try (PrintWriter pipe = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream())))) { + try (PrintWriter pipe = new PrintWriter( + new BufferedWriter(new OutputStreamWriter(process.getOutputStream(), Charset.defaultCharset())))) { for (String stdinLine : stdinLines) { LOG.log(Level.DEBUG, "InputLine --> {0} <--", stdinLine); pipe.println(stdinLine); @@ -224,7 +226,7 @@ static class ReaderThread extends Thread { ReaderThread(InputStream stream, boolean echo, String threadName, Thread threadWaitingForProcess, String textToWaitFor) { setName(threadName); - this.reader = new BufferedReader(new InputStreamReader(stream)); + this.reader = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset())); this.sb = new StringBuilder(); this.echo = echo; this.threadWaitingForProcess = threadWaitingForProcess; diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessStreamDrainerWorker.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessStreamDrainerWorker.java index 4d141f59db7..e74839f5854 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessStreamDrainerWorker.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessStreamDrainerWorker.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -20,57 +21,53 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; +import java.nio.charset.Charset; +class ProcessStreamDrainerWorker implements Runnable { -/////////////////////////////////////////////////////////////////////////// + private final BufferedInputStream reader; + private final PrintStream redirect; + private StringBuilder sb; -class ProcessStreamDrainerWorker implements Runnable -{ - ProcessStreamDrainerWorker(InputStream in, PrintStream Redirect, boolean save) - { - if(in == null) + ProcessStreamDrainerWorker(InputStream in, PrintStream Redirect, boolean save) { + if (in == null) { throw new NullPointerException("InputStream argument was null."); + } reader = new BufferedInputStream(in); redirect = Redirect; - if(save) { + if (save) { sb = new StringBuilder(); } } - public void run() - { - if(reader == null) + + @Override + public void run() { + if (reader == null) { return; + } - try - { + try { + byte[] buffer = new byte[8192]; + Charset charset = Charset.defaultCharset(); int count = 0; - byte[] buffer = new byte[4096]; - - while ((count = reader.read(buffer)) != -1) - { - if(redirect != null) + while ((count = reader.read(buffer)) != -1) { + if (redirect != null) { redirect.write(buffer, 0, count); + } - if(sb != null) - sb.append(new String(buffer, 0, count)); + if (sb != null) { + sb.append(new String(buffer, 0, count, charset)); + } } - } - catch (IOException e) - { + } catch (IOException e) { } } + String getString() { - if(sb != null) - return sb.toString(); - else - return ""; + return sb == null ? "" : sb.toString(); } - - private final BufferedInputStream reader; - private final PrintStream redirect; - private StringBuilder sb; } diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessUtils.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessUtils.java index fad21e7fba8..a70c18a6a49 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessUtils.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/ProcessUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -39,6 +39,7 @@ import static java.lang.System.Logger.Level.DEBUG; import static java.lang.System.Logger.Level.INFO; import static java.lang.System.Logger.Level.TRACE; +import static java.nio.charset.StandardCharsets.ISO_8859_1; /** * Includes a somewhat kludgy way to get the pid for "me". Another casualty of @@ -86,7 +87,7 @@ public static File getExe(String name) { * @throws IOException */ public static void saveCurrentPid(final File pidFile) throws IOException { - FileUtils.writeStringToFile(Long.toString(ProcessHandle.current().pid()), pidFile); + FileUtils.writeStringToFile(Long.toString(ProcessHandle.current().pid()), pidFile, ISO_8859_1); } @@ -135,7 +136,7 @@ public static boolean isAlive(final long pid) { */ public static long loadPid(final File pidFile) throws IllegalArgumentException { try { - return Long.parseLong(FileUtils.readSmallFile(pidFile).trim()); + return Long.parseLong(FileUtils.readSmallFile(pidFile, ISO_8859_1).trim()); } catch (NumberFormatException | IOException e) { throw new IllegalArgumentException("Could not parse the PID file: " + pidFile, e); } diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java index 2e6ab6c477d..ea2c1510adb 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -44,6 +44,7 @@ import org.glassfish.main.jul.handler.GlassFishLogHandlerProperty; +import static java.nio.charset.StandardCharsets.UTF_8; import static javax.xml.stream.XMLStreamConstants.END_DOCUMENT; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; @@ -277,7 +278,7 @@ private void read() throws XMLStreamException, EndDocumentException, FileNotFoun } private void createParser() throws FileNotFoundException, XMLStreamException { - reader = new InputStreamReader(new FileInputStream(domainXml)); + reader = new InputStreamReader(new FileInputStream(domainXml), UTF_8); XMLInputFactory xif = getXmlInputFactory(); // Set the resolver so that any external entity references, such // as a reference to a DTD, return an empty file. The domain.xml diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/XmlParserHelper.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/XmlParserHelper.java deleted file mode 100644 index 72e7f4b6448..00000000000 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/XmlParserHelper.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2023 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 - * 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 - */ - -package com.sun.enterprise.universal.xml; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStreamReader; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * A place to put all the ugly boiler plate for parsing an XML file. - * @author Byron Nevins - */ -public final class XmlParserHelper { - - public XmlParserHelper(final File f) throws FileNotFoundException, XMLStreamException { - reader = new InputStreamReader(new FileInputStream(f)); - parser = XMLInputFactory.newFactory().createXMLStreamReader( - f.toURI().toString(), reader); - } - - public XMLStreamReader get() { - return parser; - } - - /** - * Don't forget to call this method when finished! - * Closes the parser and the stream - */ - public void stop() { - // yes -- you **do** need to close BOTH of them! - try { - if (parser != null) { - parser.close(); - } - } - catch (Exception e) { - // ignore - } - try { - if (reader != null) { - reader.close(); - } - } - catch (Exception e) { - // ignore - } - } - - private final XMLStreamReader parser; - private final InputStreamReader reader; -} diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/FileUtils.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/FileUtils.java index 713da728702..2a73086c5ca 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/FileUtils.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/FileUtils.java @@ -38,6 +38,7 @@ import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.Collection; @@ -945,14 +946,15 @@ public static boolean renameFile(File fromFile, File toFile) { * file to be read is small . * * @param file Absolute path of the file + * @param charset file charset * @return String representing the contents of the file. Lines are separated by * {@link System#lineSeparator()}. * @throws java.io.IOException if there is an i/o error. * @throws java.io.FileNotFoundException if the file could not be found */ - public static String readSmallFile(final File file) throws IOException { + public static String readSmallFile(final File file, final Charset charset) throws IOException { final StringBuilder sb = new StringBuilder(); - try (BufferedReader bf = new BufferedReader(new FileReader(file))) { + try (BufferedReader bf = new BufferedReader(new FileReader(file, charset))) { String line; while ((line = bf.readLine()) != null) { sb.append(line); @@ -970,10 +972,11 @@ public static String readSmallFile(final File file) throws IOException { * * @param s The String to write to the file * @param f The file to write the String to + * @param charset file charset * @throws IOException if any errors */ - public static void writeStringToFile(String s, File f) throws IOException { - try (Writer writer = new PrintWriter(f)) { + public static void writeStringToFile(String s, File f, Charset charset) throws IOException { + try (Writer writer = new PrintWriter(f, charset)) { writer.write(s); } finally { f.setReadable(true); diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java index fe5480cc70b..e8d9ebaa232 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -26,6 +26,8 @@ import java.io.FileReader; import java.io.IOException; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * The hierarchy of directories above a running DAS or server instance can get * messy to deal with -- thus this class. This class is a bullet-proof holder of @@ -127,7 +129,7 @@ public ServerDirs(final File serverDir) throws IOException { localPasswordFile = new File(configDir, "local-password"); if (localPasswordFile.exists()) { - try (BufferedReader r = new BufferedReader(new FileReader(localPasswordFile))) { + try (BufferedReader r = new BufferedReader(new FileReader(localPasswordFile, UTF_8))) { localPassword = r.readLine(); } } else { diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/admin/payload/PayloadImpl.java b/nucleus/common/common-util/src/main/java/org/glassfish/admin/payload/PayloadImpl.java index 0d742df0899..085ad929e4f 100644 --- a/nucleus/common/common-util/src/main/java/org/glassfish/admin/payload/PayloadImpl.java +++ b/nucleus/common/common-util/src/main/java/org/glassfish/admin/payload/PayloadImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation. + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -34,6 +34,8 @@ import org.glassfish.api.admin.Payload; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Abstract implementation of the Payload API. * @@ -47,7 +49,7 @@ public abstract static class Outbound implements Payload.Outbound { */ private final ArrayList parts = new ArrayList<>(); - private boolean dirty = false; + private boolean dirty; @Override public int size() { @@ -643,11 +645,9 @@ public static Part newInstance( @Override public void copy(final OutputStream os) throws IOException { int bytesRead; - byte [] buffer = new byte[1024]; + byte[] buffer = new byte[8192]; final InputStream is = getInputStream(); - /* - * Directory entries can have null input streams. - */ + // Directory entries can have null input streams. if (is != null) { while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); @@ -689,7 +689,7 @@ public InputStream getInputStream() { */ static class Buffered extends PayloadImpl.Part { private final String content; - private ByteArrayInputStream is = null; + private ByteArrayInputStream is; /** * Creates a new buffer-based Part. @@ -712,7 +712,7 @@ static class Buffered extends PayloadImpl.Part { public ByteArrayInputStream getInputStream() { if (is == null) { // Some parts might not have content. - final byte[] data = content == null ? new byte[0] : content.getBytes(); + final byte[] data = content == null ? new byte[0] : content.getBytes(UTF_8); is = new ByteArrayInputStream(data); } return is; @@ -785,8 +785,8 @@ private InputStream dummyStream() { private static class SelfClosingInputStream extends InputStream { private final InputStream wrappedStream; - private boolean isWrappedStreamClosed = false; - private boolean isExternallyClosed = false; + private boolean isWrappedStreamClosed; + private boolean isExternallyClosed; private SelfClosingInputStream(final InputStream wrappedStream) { this.wrappedStream = wrappedStream; diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/AsadminInput.java b/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/AsadminInput.java index 3e9f33933c9..ff5cf16aec7 100644 --- a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/AsadminInput.java +++ b/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/AsadminInput.java @@ -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 @@ -25,6 +26,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URISyntaxException; +import java.nio.charset.Charset; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; @@ -70,7 +72,7 @@ public class AsadminInput { private final static LocalStringManager localStrings = new LocalStringManagerImpl(AsadminInput.class); public interface InputReader { - public Map settings(); + Map settings(); } /** @@ -96,13 +98,11 @@ public static InputReader reader(final String inputPath) throws URISyntaxExcepti } /** - * Returns a reader that can consume the specified version of asadmin input - * - * @return + * @return reader that can consume the specified version of asadmin input * @throws IOException */ public static InputReader reader(final InputStream is) throws IOException { - final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + final BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.defaultCharset())); final String version = readVersionFromFirstLine(reader); return newReader(reader, version); } @@ -139,7 +139,7 @@ private InputReader_1_0(final BufferedReader reader) throws IOException { } private Map loadSettings() throws IOException { - final Map result = new HashMap(); + final Map result = new HashMap<>(); final Properties entireContent = new Properties(); entireContent.load(reader); for (String propName : entireContent.stringPropertyNames()) { diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/ManPageFinder.java b/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/ManPageFinder.java index 5faa73ecb82..38b33e90944 100644 --- a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/ManPageFinder.java +++ b/nucleus/common/common-util/src/main/java/org/glassfish/common/util/admin/ManPageFinder.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -19,8 +20,6 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -30,6 +29,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * A utility class that gets the plain text man page for the * given command. It searches (using Class.getResource()) for @@ -83,15 +84,10 @@ public static BufferedReader getCommandManPage( s = classLoader.getResourceAsStream((String)it.next()); } - if (s == null) + if (s == null) { return null; - Reader r; - try { - r = new InputStreamReader(s, "utf-8"); - } catch (UnsupportedEncodingException ex) { - r = new InputStreamReader(s); } - return new BufferedReader(r); + return new BufferedReader(new InputStreamReader(s, UTF_8)); } private static Iterator getPossibleLocations(final String cmdName, @@ -100,13 +96,15 @@ private static Iterator getPossibleLocations(final String cmdName, final String[] locales = getLocaleLocations(locale); private int i = 0; private int j = 0; - private String helpdir = getHelpDir(cmdClass); - private String commandName = cmdName; + private final String helpdir = getHelpDir(cmdClass); + private final String commandName = cmdName; + @Override public boolean hasNext() { return i < locales.length && j < sections.length; } + @Override public Object next() throws NoSuchElementException{ if (!hasNext()) { throw new NoSuchElementException(); @@ -116,13 +114,15 @@ public Object next() throws NoSuchElementException{ if (j == sections.length) { i++; - if (i < locales.length) + if (i < locales.length) { j = 0; + } } logger.log(Level.FINE, "Trying to get this manpage: {0}", result); return result; } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -141,15 +141,16 @@ private static String[] getLocaleLocations(Locale locale) { String language = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); - List l = new ArrayList(); + List l = new ArrayList<>(); l.add(""); if (language != null && language.length() > 0) { l.add("/" + language); if (country != null && country.length() > 0) { l.add("/" + language + "_" + country); - if (variant != null && variant.length() > 0) + if (variant != null && variant.length() > 0) { l.add("/" + language + "_" + country + "_" + variant); + } } } Collections.reverse(l); diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/security/common/FileRealmHelper.java b/nucleus/common/common-util/src/main/java/org/glassfish/security/common/FileRealmHelper.java index 987f4867a7a..4791dc75f62 100644 --- a/nucleus/common/common-util/src/main/java/org/glassfish/security/common/FileRealmHelper.java +++ b/nucleus/common/common-util/src/main/java/org/glassfish/security/common/FileRealmHelper.java @@ -34,6 +34,7 @@ import java.util.Set; import java.util.StringTokenizer; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.glassfish.security.common.SharedSecureRandom.SECURE_RANDOM; @@ -218,7 +219,7 @@ public String[] authenticate(String user, char[] password) return ud.getGroups(); } - /* + /** * Test whether their is a user in the FileRealm that has a password that * has been set, i.e., something other than the resetKey. */ @@ -232,17 +233,13 @@ public boolean hasAuthenticatableUser() return false; } - //--------------------------------------------------------------------- - // File realm maintenance methods for admin. - - /** * Return false if any char of the string is not alphanumeric or space * or other permitted character. * For a username it will allow an @ symbol. To allow for the case of type * username@foo.com. It will not allow the same symbol for a group name - * @param String the name to be validated - * @param boolean true if the string is a username, false if it is + * @param s the name to be validated + * @param userName true if the string is a username, false if it is * a group name * */ @@ -374,7 +371,7 @@ public static void validateGroupName(String group) * of the groupList. * * @param groupList Array of group names to validate. - * @throws IASSecurityException Thrown if the value is not valid. + * @throws IllegalArgumentException Thrown if the value is not valid. * * */ @@ -450,7 +447,7 @@ public synchronized void removeUser(String name) * @param password Cleartext password for the user. If non-null the user * password is changed to this value. If null, the original password * is retained. - * @param groupList List of groups to which user belongs. + * @param groups List of groups to which user belongs. * @throws IllegalArgumentException If there are problems adding user. */ public synchronized void updateUser(String name, String newName, char[] password, @@ -521,36 +518,21 @@ public synchronized void updateUser(String name, String newName, char[] password * file locking or revision management as deemed necessary. * @throws IOException if there is a failure */ - public void persist() throws IOException { - synchronized (FileRealmHelper.class) { - FileOutputStream out = null; - try { - out = new FileOutputStream(keyfile); - - for (Map.Entry uval : userTable.entrySet()) { - String algo = uval.getValue().getAlgo(); - String entry = encodeUser(uval.getKey(), uval.getValue(),algo); - out.write(entry.getBytes()); - } - } catch (IOException e) { - throw e; - - } catch (Exception e) { - String msg = sm.getString("filerealm.badwrite", e.toString()); - throw new IOException(msg); - } finally { - if (out != null) { - out.close(); - } + public synchronized void persist() throws IOException { + try (FileOutputStream out = new FileOutputStream(keyfile)) { + for (Map.Entry uval : userTable.entrySet()) { + String algo = uval.getValue().getAlgo(); + String entry = encodeUser(uval.getKey(), uval.getValue(), algo); + out.write(entry.getBytes(UTF_8)); } + } catch (IOException e) { + throw e; + } catch (Exception e) { + String msg = sm.getString("filerealm.badwrite", keyfile); + throw new IOException(msg, e); } } - - //--------------------------------------------------------------------- - // Private methods. - - /** * Add group names to the groups table. It is assumed all entries are * valid group names. @@ -597,33 +579,18 @@ private void changeGroups(String[] oldGroupList, String[] newGroupList) { /** * Load keyfile from config and populate internal cache. - * */ - private void loadKeyFile() throws IOException - { - BufferedReader input = null; - - try { - input = new BufferedReader(new FileReader(keyfile)); + private void loadKeyFile() throws IOException { + try (BufferedReader input = new BufferedReader(new FileReader(keyfile, UTF_8));) { while (input.ready()) { - String line = input.readLine(); - if (line != null && - !line.startsWith(COMMENT) && - line.indexOf(FIELD_SEP) >= 0) { + if (line != null && !line.startsWith(COMMENT) && line.indexOf(FIELD_SEP) >= 0) { User ud = decodeUser(line, groupSizeMap); userTable.put(ud.getName(), ud); } } } catch (Exception e) { - throw new IOException(e.toString()); - } finally { - if (input != null) { - try { - input.close(); - } catch(Exception ex) { - } - } + throw new IOException("Could not load key file " + keyfile, e); } } diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/security/common/LocalStrings.properties b/nucleus/common/common-util/src/main/java/org/glassfish/security/common/LocalStrings.properties index cb16aa0e3e9..6548a73188a 100644 --- a/nucleus/common/common-util/src/main/java/org/glassfish/security/common/LocalStrings.properties +++ b/nucleus/common/common-util/src/main/java/org/glassfish/security/common/LocalStrings.properties @@ -21,7 +21,7 @@ filerealm.emptypwd=Password given is null. filerealm.badspacespwd=Invalid surrounding whitespace in password. filerealm.dupuser=User {0} already exists. filerealm.nouser=No such user [{0}]. -filerealm.badwrite=Error writing keyfile: {0} +filerealm.badwrite=Error writing to keyfile {0} filerealm.syntaxerror=Format error in keyfile line [{0}] filerealm.badchars=Invalid characters in group: {0}. filerealm.nogroup=Empty group name given. diff --git a/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadFilesManagerTest.java b/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadFilesManagerTest.java index 812ee932531..0cc4b88a459 100644 --- a/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadFilesManagerTest.java +++ b/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadFilesManagerTest.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 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 @@ -25,12 +25,12 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -1021,12 +1021,12 @@ private static void cleanup(final File... files) { } } - private void writeFile(final File file, final String... content) throws FileNotFoundException { - PrintStream ps = new PrintStream(file); - for (String s : content) { - ps.println(s); + private void writeFile(final File file, final String... content) throws IOException { + try (PrintStream ps = new PrintStream(file, StandardCharsets.UTF_8)) { + for (String s : content) { + ps.println(s); + } } - ps.close(); } private Properties fileXferProps() { @@ -1035,37 +1035,12 @@ private Properties fileXferProps() { return props; } -// private void testForBadChars(String initialPath) { -// URI uri = null; -// URI targetDirURI = null; -// try { -// PayloadFilesManager.Temp instance = new PayloadFilesManager.Temp(Logger.getAnonymousLogger()); -// uri = URI.create(initialPath.replace(File.separator, "/")); -// targetDirURI = instance.getTargetDir().toURI(); -// -// //System.out.println(" " + initialPath + " -> " + uri.toASCIIString()); -// String uriString = targetDirURI.relativize(uri).toASCIIString(); -// -// // trim the trailing slash for the directory -// if (uriString.endsWith("/")) { -// uriString = uriString.substring(0, uriString.length() - 1); -// } -// assertFalse("path " + uriString + " still contains bad character(s)", -// uriString.contains("/") || -// uriString.contains("\\") || -// (uriString.contains(":") && File.separatorChar == '\\')); } catch (Exception e) { -// fail("unexpected exception " + e.getMessage()); -// } -// } - private abstract class CommonTest { protected final static String payloadType = "application/zip"; - protected abstract void addParts(final Payload.Outbound ob, - final PayloadFilesManager instance) throws Exception; + protected abstract void addParts(Payload.Outbound ob, PayloadFilesManager instance) throws Exception; - protected abstract void checkResults(final Payload.Inbound ib, - final PayloadFilesManager instance) throws Exception; + protected abstract void checkResults(Payload.Inbound ib, PayloadFilesManager instance) throws Exception; protected abstract PayloadFilesManager instance() throws IOException; diff --git a/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadImplTest.java b/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadImplTest.java index fac671b65a6..0dfcedddfe6 100644 --- a/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadImplTest.java +++ b/nucleus/common/common-util/src/test/java/org/glassfish/admin/payload/PayloadImplTest.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 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 @@ -41,6 +41,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -175,7 +176,8 @@ public void testSingleFileReplaceRequest() throws Exception { try { Payload.Outbound outboundPayload = PayloadImpl.Outbound.newInstance(); - newVersion = populateFile(File.createTempFile("payload",".txt"), REPLACED_FILE_X.content); + newVersion = File.createTempFile("payload",".txt"); + populateFile(newVersion, REPLACED_FILE_X.content); outboundPayload.requestFileReplacement("application/octet-stream", new URI(REPLACED_FILE_X.path), "replacement", null, newVersion, false); @@ -211,7 +213,8 @@ public void testAddFiles() throws Exception { File zipFile = null; try { Payload.Outbound outboundPayload = PayloadImpl.Outbound.newInstance(); - fileToBeAddedToPayload = populateFile(File.createTempFile("payload",".txt"), ADDED_FILE_Z.content); + fileToBeAddedToPayload = File.createTempFile("payload",".txt"); + populateFile(fileToBeAddedToPayload, ADDED_FILE_Z.content); log(" Populated " + fileToBeAddedToPayload.getAbsolutePath()); /* @@ -278,7 +281,7 @@ private File writePayloadToFile(final Payload.Outbound ob, final File f) throws private String readFromFile(final File f) throws FileNotFoundException, IOException { final StringBuilder sb = new StringBuilder(); - final LineNumberReader r = new LineNumberReader(new FileReader(f)); + final LineNumberReader r = new LineNumberReader(new FileReader(f, UTF_8)); try { String line; while ((line = r.readLine()) != null) { @@ -341,11 +344,10 @@ private File createSubdir(final File parent, final String subdirPath) throws IOE return f; } - private File populateFile(final File f, final String content) throws FileNotFoundException { - final PrintStream ps = new PrintStream(f); - ps.println(content); - ps.close(); - return f; + private void populateFile(final File f, final String content) throws IOException { + try (PrintStream ps = new PrintStream(f, UTF_8)) { + ps.println(content); + } } private void cleanDir(final File d) { diff --git a/nucleus/common/common-util/src/test/java/org/glassfish/common/util/admin/locking/FileLockTest.java b/nucleus/common/common-util/src/test/java/org/glassfish/common/util/admin/locking/FileLockTest.java index f7e8a9c98ac..9cef2fc2bf7 100644 --- a/nucleus/common/common-util/src/test/java/org/glassfish/common/util/admin/locking/FileLockTest.java +++ b/nucleus/common/common-util/src/test/java/org/glassfish/common/util/admin/locking/FileLockTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 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 @@ -44,6 +44,7 @@ import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -257,49 +258,50 @@ public Void call() throws Exception { } } + @Test public void lockAndReadTest() throws Exception { - File f = File.createTempFile("common-util-FileLockTest", "tmp"); - try { - // Now let's try to write the file. - try (FileWriter fw = new FileWriter(f)) { - fw.append("FileLockTest reading passed !"); - } - - final ManagedFile managed = new ManagedFile(f, 1000, 1000); - Lock fl = managed.accessRead(); - try (FileReader fr = new FileReader(f)) { - char[] chars = new char[1024]; - fr.read(chars); - } - - fl.unlock(); - } finally { - f.delete(); - } - } - - - @Test - @DisabledOnOs(OS.WINDOWS) - public void lockForReadAndWriteTest_Unix() throws Exception { - final File file = File.createTempFile("common-util-FileLockTest", "tmp"); - final Path filePath = file.toPath(); - try { - // Now let's try to write the file. - final String message = "lockForReadAndWriteTest passed!"; - Files.writeString(filePath, message); - assertEquals(message, Files.readString(filePath)); - - final ManagedFile managed = new ManagedFile(file, 1000, 1000); - final Lock fl = managed.accessRead(); - - final String message2 = "\nlockForReadAndWriteTest passed!"; - Files.writeString(filePath, message2, StandardOpenOption.APPEND); - fl.unlock(); - - assertThat(Files.readString(filePath), equalTo(message + message2)); - } finally { + File f = File.createTempFile("common-util-FileLockTest", "tmp"); + try { + // Now let's try to write the file. + try (FileWriter fw = new FileWriter(f, UTF_8)) { + fw.append("FileLockTest reading passed !"); + } + + final ManagedFile managed = new ManagedFile(f, 1000, 1000); + Lock fl = managed.accessRead(); + try (FileReader fr = new FileReader(f, UTF_8)) { + char[] chars = new char[1024]; + fr.read(chars); + } + + fl.unlock(); + } finally { + f.delete(); + } + } + + + @Test + @DisabledOnOs(OS.WINDOWS) + public void lockForReadAndWriteTest_Unix() throws Exception { + final File file = File.createTempFile("common-util-FileLockTest", "tmp"); + final Path filePath = file.toPath(); + try { + // Now let's try to write the file. + final String message = "lockForReadAndWriteTest passed!"; + Files.writeString(filePath, message); + assertEquals(message, Files.readString(filePath)); + + final ManagedFile managed = new ManagedFile(file, 1000, 1000); + final Lock fl = managed.accessRead(); + + final String message2 = "\nlockForReadAndWriteTest passed!"; + Files.writeString(filePath, message2, StandardOpenOption.APPEND); + fl.unlock(); + + assertThat(Files.readString(filePath), equalTo(message + message2)); + } finally { file.delete(); } } diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat index 79845792e47..20642050f73 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat @@ -1,4 +1,5 @@ REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation. REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. REM REM This program and the accompanying materials are made available under the @@ -35,6 +36,7 @@ REM installation directory of GlassFish, and such resolution will not work REM correctly unless the script happens to be run from the GlassFish installation REM directory. REM +REM This file uses UTF-8 character encoding. set AS_IMQ_LIB=..\..\mq\lib set AS_IMQ_BIN=..\..\mq\bin diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf index 62d766eca97..2f6bffd19df 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf @@ -1,4 +1,5 @@ # +# Copyright (c) 2024 Contributors to the Eclipse Foundation. # Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -34,6 +35,7 @@ # correctly unless the script happens to be run from the GlassFish installation # directory. # +# This file uses UTF-8 character encoding. AS_IMQ_LIB="../../mq/lib" AS_IMQ_BIN="../../mq/bin"