@Test public void buildCipherSuites_CipherSuiteContainsNonMicrofocusAccepted_ValidResult() throws Exception { final String unknownCipher = "asd"; final String cipherSuite = CipherSuites.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + ", \n\t" + unknownCipher; List<String> result = InputBuilderUtils.buildAllowedCiphers(cipherSuite); assertEquals(CipherSuites.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, result.get(0)); assertEquals(unknownCipher, result.get(1)); }
public static List<String> buildAllowedCiphers(String allowedCiphersInput) throws Exception { if (StringUtils.isEmpty(allowedCiphersInput)) { return Collections.emptyList(); } String[] cipherSuites = allowedCiphersInput.replaceAll("\\s+", StringUtils.EMPTY).split(","); List<String> allowedCiphers = Arrays.asList(cipherSuites); for(String cipher : allowedCiphers) { if(!CipherSuites.validate(cipher)) { throw new IllegalArgumentException("Illegal value of input '" + InputNames.ENCRYPTION_ALGORITHM + "'"); } } return allowedCiphers; }
InputBuilderUtils { public static List<String> buildAllowedCiphers(String allowedCiphersInput) throws Exception { if (StringUtils.isEmpty(allowedCiphersInput)) { return Collections.emptyList(); } String[] cipherSuites = allowedCiphersInput.replaceAll("\\s+", StringUtils.EMPTY).split(","); List<String> allowedCiphers = Arrays.asList(cipherSuites); for(String cipher : allowedCiphers) { if(!CipherSuites.validate(cipher)) { throw new IllegalArgumentException("Illegal value of input '" + InputNames.ENCRYPTION_ALGORITHM + "'"); } } return allowedCiphers; } }
InputBuilderUtils { public static List<String> buildAllowedCiphers(String allowedCiphersInput) throws Exception { if (StringUtils.isEmpty(allowedCiphersInput)) { return Collections.emptyList(); } String[] cipherSuites = allowedCiphersInput.replaceAll("\\s+", StringUtils.EMPTY).split(","); List<String> allowedCiphers = Arrays.asList(cipherSuites); for(String cipher : allowedCiphers) { if(!CipherSuites.validate(cipher)) { throw new IllegalArgumentException("Illegal value of input '" + InputNames.ENCRYPTION_ALGORITHM + "'"); } } return allowedCiphers; }  }
InputBuilderUtils { public static List<String> buildAllowedCiphers(String allowedCiphersInput) throws Exception { if (StringUtils.isEmpty(allowedCiphersInput)) { return Collections.emptyList(); } String[] cipherSuites = allowedCiphersInput.replaceAll("\\s+", StringUtils.EMPTY).split(","); List<String> allowedCiphers = Arrays.asList(cipherSuites); for(String cipher : allowedCiphers) { if(!CipherSuites.validate(cipher)) { throw new IllegalArgumentException("Illegal value of input '" + InputNames.ENCRYPTION_ALGORITHM + "'"); } } return allowedCiphers; }  static String buildHostname(String hostname); static Short buildPort(String port, boolean mandatory); static Map<String, Object> buildPortAndProtocol(String protocol, String port); static String buildUsername(String username, boolean mandatory); static String buildPassword(String password); static boolean buildTrustAllRoots(String trustAllRoots); static boolean buildEnableTLS(String enableTLS); static boolean buildEnableSSL(String enableSSL); static boolean buildDeleteUponRetrieval(String deleteUponRetrieval); static String buildKeystore(String keystore); static int buildTimeout(String timeout); static Map<String, String> buildDecryptionKeystore(String decryptionKeystore, String decryptionKeyAlias,
                                                              String decryptionKeystorePassword); static List<String> buildTlsVersions(String tlsVersionInput); static List<String> buildAllowedCiphers(String allowedCiphersInput); }
InputBuilderUtils { public static List<String> buildAllowedCiphers(String allowedCiphersInput) throws Exception { if (StringUtils.isEmpty(allowedCiphersInput)) { return Collections.emptyList(); } String[] cipherSuites = allowedCiphersInput.replaceAll("\\s+", StringUtils.EMPTY).split(","); List<String> allowedCiphers = Arrays.asList(cipherSuites); for(String cipher : allowedCiphers) { if(!CipherSuites.validate(cipher)) { throw new IllegalArgumentException("Illegal value of input '" + InputNames.ENCRYPTION_ALGORITHM + "'"); } } return allowedCiphers; }  static String buildHostname(String hostname); static Short buildPort(String port, boolean mandatory); static Map<String, Object> buildPortAndProtocol(String protocol, String port); static String buildUsername(String username, boolean mandatory); static String buildPassword(String password); static boolean buildTrustAllRoots(String trustAllRoots); static boolean buildEnableTLS(String enableTLS); static boolean buildEnableSSL(String enableSSL); static boolean buildDeleteUponRetrieval(String deleteUponRetrieval); static String buildKeystore(String keystore); static int buildTimeout(String timeout); static Map<String, String> buildDecryptionKeystore(String decryptionKeystore, String decryptionKeyAlias,
                                                              String decryptionKeystorePassword); static List<String> buildTlsVersions(String tlsVersionInput); static List<String> buildAllowedCiphers(String allowedCiphersInput);  }