@Test public void parseBase64BinaryWhenReallyLongThenRemovesNewlineAndSpace() { String toParse = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\n NTY3ODk="; String expected = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; String actual = new String(LdapEncoder.parseBase64Binary(toParse)); assertThat(actual).isEqualTo(expected); }
public static byte[] parseBase64Binary(String val) { Assert.notNull(val, "val must not be null!"); int length = val.length(); StringBuilder sb = new StringBuilder(length); for (int i = 0, len = length; i < len; i++) { char c = val.charAt(i); if(c == '\n'){ if(i + 1 < len && val.charAt(i + 1) == ' ') { i++; } continue; } sb.append(c); } return DatatypeConverter.parseBase64Binary(sb.toString()); }
LdapEncoder { public static byte[] parseBase64Binary(String val) { Assert.notNull(val, "val must not be null!"); int length = val.length(); StringBuilder sb = new StringBuilder(length); for (int i = 0, len = length; i < len; i++) { char c = val.charAt(i); if(c == '\n'){ if(i + 1 < len && val.charAt(i + 1) == ' ') { i++; } continue; } sb.append(c); } return DatatypeConverter.parseBase64Binary(sb.toString()); } }
LdapEncoder { public static byte[] parseBase64Binary(String val) { Assert.notNull(val, "val must not be null!"); int length = val.length(); StringBuilder sb = new StringBuilder(length); for (int i = 0, len = length; i < len; i++) { char c = val.charAt(i); if(c == '\n'){ if(i + 1 < len && val.charAt(i + 1) == ' ') { i++; } continue; } sb.append(c); } return DatatypeConverter.parseBase64Binary(sb.toString()); } private  LdapEncoder(); }
LdapEncoder { public static byte[] parseBase64Binary(String val) { Assert.notNull(val, "val must not be null!"); int length = val.length(); StringBuilder sb = new StringBuilder(length); for (int i = 0, len = length; i < len; i++) { char c = val.charAt(i); if(c == '\n'){ if(i + 1 < len && val.charAt(i + 1) == ' ') { i++; } continue; } sb.append(c); } return DatatypeConverter.parseBase64Binary(sb.toString()); } private  LdapEncoder(); static String filterEncode(String value); static String nameEncode(String value); static String nameDecode(String value); static String printBase64Binary(byte[] val); static byte[] parseBase64Binary(String val); }
LdapEncoder { public static byte[] parseBase64Binary(String val) { Assert.notNull(val, "val must not be null!"); int length = val.length(); StringBuilder sb = new StringBuilder(length); for (int i = 0, len = length; i < len; i++) { char c = val.charAt(i); if(c == '\n'){ if(i + 1 < len && val.charAt(i + 1) == ' ') { i++; } continue; } sb.append(c); } return DatatypeConverter.parseBase64Binary(sb.toString()); } private  LdapEncoder(); static String filterEncode(String value); static String nameEncode(String value); static String nameDecode(String value); static String printBase64Binary(byte[] val); static byte[] parseBase64Binary(String val);  }