Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -11,7 +11,7 @@
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2024 3A Systems LLC.
* Copyright 2024-2026 3A Systems LLC.
*/

package org.openidentityplatform.opendj.embedded;
Expand Down Expand Up @@ -69,12 +69,13 @@ public EmbeddedOpenDJ(Config config) {
logger.info("Create embedded OpenDJ instance: {}", config);

this.config = config;
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
File rootDirectory = new File(tempDirectory, "opendj");
try {
if(rootDirectory.exists()) {
FileUtils.deleteDirectory(rootDirectory);
}
// Create a fresh per-instance parent directory, only accessible by the
// current user, instead of the fixed shared {java.io.tmpdir}/opendj
// directory. The server root inside it must be named "opendj" because
// setup from an archive requires the server root directory to match the
// root directory contained in the archive.
File rootDirectory = new File(Files.createTempDirectory("opendj").toFile(), "opendj");
rootDirectory.mkdir();

File configDirectory = new File(rootDirectory, "config");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.guitools.controlpanel;

Expand All @@ -23,6 +24,7 @@

import java.io.File;
import java.io.PrintStream;
import java.nio.file.Files;

import javax.swing.SwingUtilities;

Expand Down Expand Up @@ -64,7 +66,7 @@ public static void main(String[] args)
{
try {
ControlPanelLog.initLogFileHandler(
File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX));
Files.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX).toFile());
} catch (Throwable t) {
System.err.println("Unable to initialize log");
t.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.guitools.controlpanel.ui;

Expand All @@ -28,6 +29,7 @@
import java.awt.event.ItemListener;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -1239,7 +1241,7 @@ private String generateLdifFile(final File templateFile)
final TemplateFile generator = new TemplateFile(resourceDir.getAbsolutePath(), new Random(0));
generator.parse(templateFile.getAbsolutePath(), Collections.<LocalizableMessage>emptyList());

final File tempFile = File.createTempFile("opendj-control-panel", ".ldif");
final File tempFile = Files.createTempFile("opendj-control-panel", ".ldif").toFile();
tempFile.deleteOnExit();
final String generatedLdifFilePath = tempFile.getAbsolutePath();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.quicksetup;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Date;
import java.text.DateFormat;

Expand Down Expand Up @@ -51,7 +53,7 @@
{
try
{
return new TempLogFile(File.createTempFile(prefix, ".log"));
return new TempLogFile(Files.createTempFile(prefix, ".log").toFile());
}
catch (final IOException e)
{
Expand Down Expand Up @@ -85,7 +87,7 @@
ErrorLogger.getInstance().addLogPublisher(startupErrorLogPublisher);
DebugLogPublisher startupDebugLogPublisher = DebugLogger.getInstance().addPublisherIfRequired(writer);

localizedLogger.info(LocalizableMessage.raw("QuickSetup application launched " + DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(new Date()), null));

Check warning on line 90 in opendj-server-legacy/src/main/java/org/opends/quicksetup/TempLogFile.java

View workflow job for this annotation

GitHub Actions / build-maven (macos-latest, 11)

non-varargs call of varargs method with inexact argument type for last parameter;

Check warning on line 90 in opendj-server-legacy/src/main/java/org/opends/quicksetup/TempLogFile.java

View workflow job for this annotation

GitHub Actions / build-maven (windows-latest, 11)

non-varargs call of varargs method with inexact argument type for last parameter;

Check warning on line 90 in opendj-server-legacy/src/main/java/org/opends/quicksetup/TempLogFile.java

View workflow job for this annotation

GitHub Actions / build-maven (ubuntu-latest, 11)

non-varargs call of varargs method with inexact argument type for last parameter;

Check warning on line 90 in opendj-server-legacy/src/main/java/org/opends/quicksetup/TempLogFile.java

View workflow job for this annotation

GitHub Actions / build-maven (ubuntu-latest, 17)

non-varargs call of varargs method with inexact argument type for last parameter;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.quicksetup.installer;

Expand All @@ -33,6 +34,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -272,7 +274,7 @@ public File createBaseEntryTempFile(String baseDn)
File ldifFile;
try
{
ldifFile = File.createTempFile("opendj-base-entry", ".ldif");
ldifFile = Files.createTempFile("opendj-base-entry", ".ldif").toFile();
ldifFile.deleteOnExit();
} catch (IOException ioe)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.File;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
Expand Down Expand Up @@ -112,14 +113,14 @@
public static void main(String[] args) {
Properties properties = System.getProperties();
generationDir = properties.getProperty("GenerationDir");
if (generationDir == null) {
// Default dir is prefixed by the system-dependent default temporary dir
generationDir = System.getProperty("java.io.tmpdir") + File.separator +
CONFIG_GUIDE_DIR;
}
// Create new dir if necessary
try {
new File(generationDir).mkdir();
if (generationDir == null) {
// Default dir is a fresh temporary dir, only accessible by the current user
generationDir = Files.createTempDirectory(CONFIG_GUIDE_DIR).toString();
} else {
// Create new dir if necessary
new File(generationDir).mkdir();

Check notice

Code scanning / CodeQL

Ignored error status of call Note documentation

Method main ignores exceptional return value of File.mkdir.
}
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.nio.file.Files;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -425,7 +426,7 @@ private static boolean isUnderAnyOf(DN dn, List<DN> branches)

private File exportBranches(List<DN> includeBranches, List<DN> excludeBranches) throws Exception
{
final File migrationFile = File.createTempFile("import-migration-", ".ldif");
final File migrationFile = Files.createTempFile("import-migration-", ".ldif").toFile();
final LDIFExportConfig exportConfig =
new LDIFExportConfig(migrationFile.getAbsolutePath(), ExistingFileBehavior.OVERWRITE);
exportConfig.setIncludeBranches(includeBranches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.server.schema;

Expand Down Expand Up @@ -725,7 +726,7 @@ private File writeTempSchemaFile(Schema schema, Collection<Attribute> extraAttri
}

// Create a temporary file to which we can write the schema entry.
File tempFile = File.createTempFile(schemaFile, "temp");
File tempFile = Files.createTempFile(schemaFile, "temp").toFile();
LDIFExportConfig exportConfig =
new LDIFExportConfig(tempFile.getAbsolutePath(),
ExistingFileBehavior.OVERWRITE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2012-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.server.tools;

Expand All @@ -28,6 +29,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.PrivilegedExceptionAction;
import java.security.SecureRandom;
Expand Down Expand Up @@ -1892,7 +1894,7 @@ else if (lowerName.equals(SASL_PROPERTY_REALM))
String configFileName;
try
{
File tempFile = File.createTempFile("login", "conf");
File tempFile = Files.createTempFile("login", "conf").toFile();
configFileName = tempFile.getAbsolutePath();
tempFile.deleteOnExit();
try (BufferedWriter w = new BufferedWriter(new FileWriter(tempFile, false))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Copyright 2007-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyright 2012 profiq s.r.o.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.server.tools.dsreplication;

Expand Down Expand Up @@ -46,6 +47,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -364,7 +366,7 @@ public static int mainCLI(String[] args, boolean initializeServer,
try
{
ControlPanelLog.initLogFileHandler(
File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX));
Files.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX).toFile());
} catch (Throwable t) {
System.err.println("Unable to initialize log");
t.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
Expand Down Expand Up @@ -166,7 +167,7 @@ public static int mainCLI(String[] args, OutputStream outStream, OutputStream er

try {
ControlPanelLog.initLogFileHandler(
File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX));
Files.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX).toFile());
ControlPanelLog.initPackage("org.opends.server.tools.status");
} catch (Throwable t) {
System.err.println("Unable to initialize log");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyrighted 2026 3A Systems, LLC.
*/
package org.opends.server.util;

Expand All @@ -23,6 +24,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
Expand Down Expand Up @@ -149,7 +151,7 @@ public static File createTemplateFile(Set<String> baseDNs,
int numEntries)
throws IOException
{
File templateFile = File.createTempFile("opendj-install", ".template");
File templateFile = Files.createTempFile("opendj-install", ".template").toFile();
templateFile.deleteOnExit();

LinkedList<String> lines = new LinkedList<>();
Expand Down
Loading