### Question:
TlsHelper { public static final String escapeFilename(String filename) { return filename.replaceAll("[^\\w\\.\\-\\=]+", "_"); } private  TlsHelper(); static boolean isUnlimitedStrengthCryptographyEnabled(); static String writeKeyStore(KeyStore keyStore, OutputStreamFactory outputStreamFactory, File file, String password, boolean generatedPassword); static byte[] calculateHMac(String token, PublicKey publicKey); static byte[] getKeyIdentifier(PublicKey publicKey); static String pemEncodeJcaObject(Object object); static JcaPKCS10CertificationRequest parseCsr(String pemEncodedCsr); static X509Certificate parseCertificate(Reader pemEncodedCertificate); static KeyPair parseKeyPair(Reader pemEncodedKeyPair); static T parsePem(Class<T> clazz, Reader pemReader); static KeyPair generateKeyPair(String algorithm, int keySize); static JcaPKCS10CertificationRequest generateCertificationRequest(String requestedDn, String domainAlternativeNames,
                                                                             KeyPair keyPair, String signingAlgorithm); static Extensions createDomainAlternativeNamesExtensions(String domainAlternativeNames, String requestedDn); static final String escapeFilename(String filename); static final String JCE_URL; static final String ILLEGAL_KEY_SIZE; }### Answer:
@Test public void testEscapeAliasFilenameWithForwardSlashes() { String result = TlsHelper.escapeFilename("my/silly/filename.pem"); assertEquals("my_silly_filename.pem", result); }
@Test public void testEscapeAliasFilenameWithBackSlashes() { String result = TlsHelper.escapeFilename("my\\silly\\filename.pem"); assertEquals("my_silly_filename.pem", result); }
@Test public void testEscapeAliasFilenameWithDollarSign() { String result = TlsHelper.escapeFilename("my$illyfilename.pem"); assertEquals("my_illyfilename.pem", result); }
@Test public void testEscapeAliasFilenameTwoSymbolsInARow() { String result = TlsHelper.escapeFilename("my!?sillyfilename.pem"); assertEquals("my_sillyfilename.pem", result); }
@Test public void testEscapeAliasFilenameKeepHyphens() { String result = TlsHelper.escapeFilename("my-silly-filename.pem"); assertEquals("my-silly-filename.pem", result); }
@Test public void testEscapeAliasFilenameDoubleSpaces() { String result = TlsHelper.escapeFilename("my silly filename.pem"); assertEquals("my_silly_filename.pem", result); }
@Test public void testEscapeAliasFilenameSymbols() { String result = TlsHelper.escapeFilename("./\\!@#$%^&*()_-+=.pem"); assertEquals(".__-_=.pem", result); }
@Test public void testClientDnFilenameSlashes() throws Exception { String clientDn = "OU=NiFi/Organisation,CN=testuser"; String escapedClientDn = TlsHelper.escapeFilename(CertificateUtils.reorderDn(clientDn)); assertEquals("CN=testuser_OU=NiFi_Organisation", escapedClientDn); }
@Test public void testClientDnFilenameSpecialChars() throws Exception { String clientDn = "OU=NiFi#!Organisation,CN=testuser"; String escapedClientDn = TlsHelper.escapeFilename(CertificateUtils.reorderDn(clientDn)); assertEquals("CN=testuser_OU=NiFi_Organisation", escapedClientDn); }