@Nullable public String getNameSecure () { return FilenameHelper.getAsSecureValidFilename (m_sName); }
@Nonnull public static File getUniqueFile (@Nonnull final File aDir, @Nullable final String sFilename) { final String sBaseFilename = FilenameHelper.getAsSecureValidFilename (sFilename); int nCounter = -1; while (true) { final File aTest = new File (aDir, nCounter == -1 ? sBaseFilename : sBaseFilename + "." + Integer.toString (nCounter)); if (!aTest.exists ()) return aTest; nCounter++; } }
@Nullable public String getNameSecure () { final String sSecureName = FilenameHelper.getAsSecureValidFilename (m_sFilename); if (!EqualsHelper.equals (sSecureName, m_sFilename)) if (LOGGER.isInfoEnabled ()) LOGGER.info ("FileItem filename was changed from '" + m_sFilename + "' to '" + sSecureName + "'"); return sSecureName; }
public JettyStarter (@Nonnull @Nonempty final String sAppName) { ValueEnforcer.notEmpty (sAppName, "AppName"); m_sAppName = sAppName; m_sDirBaseName = FilenameHelper.getAsSecureValidFilename (sAppName); if (StringHelper.hasNoText (m_sDirBaseName)) throw new IllegalStateException ("FolderName for application name '" + sAppName + "' is empty."); // Must be directly called on System to have an effect! System.setProperty ("log4j2.disable.jmx", "true"); }
/** * @since 2007-06-01 * @param aMsg * The source message * @param sFileParam * The parameter name including the filename * @param sAction * Action name * @return File The {@link File} to be used * @throws IOException * In case of IO error * @throws OpenAS2Exception * In case of error */ protected File getFile (final IMessage aMsg, final String sFileParam, final String sAction) throws IOException, OpenAS2Exception { final String sFilename = getFilename (aMsg, sFileParam, sAction); // make sure the parent directories exist final File aFile = new File (sFilename); AS2IOHelper.getFileOperationManager ().createDirRecursiveIfNotExisting (aFile.getParentFile ()); // don't overwrite existing files return AS2IOHelper.getUniqueFile (aFile.getParentFile (), FilenameHelper.getAsSecureValidFilename (aFile.getName ())); }
final String sFilenameToUse = FilenameHelper.getWithoutPath (FilenameHelper.getAsSecureValidFilename (sFilename)); if (!sFilename.equals (sFilenameToUse)) logWarn ("Content-Dispostion filename was internally modified from '" +
final String sErrorDirectory = aParams.format (getAttributeAsStringRequired (ATTR_ERROR_DIRECTORY)); final File aMsgErrorFile = AS2IOHelper.getUniqueFile (AS2IOHelper.getDirectoryFile (sErrorDirectory), FilenameHelper.getAsSecureValidFilename (sErrorFilename));