return( isLDIFSafe(str.getBytes("UTF-8"))); } catch( UnsupportedEncodingException ue) { throw new RuntimeException(
/** * Write the DN to the outputStream. If the DN characters are unsafe, * the DN is encoded. * * @param dn the DN to write */ private void writeDN(String dn) throws IOException { writeLine(Base64.isLDIFSafe(dn)? "dn: "+dn: "dn:: "+ Base64.encode(dn)); return; }
/** * Write attribute name and value into outputStream. * * <p>Check if attrVal starts with NUL, LF, CR, ' ', ':', or '<' * or contains any NUL, LF, or CR, and then write it out</p> */ private void writeAttribute(String attrName, String attrVal) throws IOException { if (attrVal != null) { writeLine( Base64.isLDIFSafe(attrVal)? attrName + ": " + attrVal : attrName + ":: " + Base64.encode(attrVal) ); } return; }
/** * Write attribute name and value into outputStream. * * <p>Check if attribute value contains NON-SAFE-INIT-CHAR or * NON-SAFE-CHAR. if it does, it needs to be base64 encoded and then * write it out</p> */ private void writeAttribute(String attrName, byte[] attrVal) throws IOException { if (attrVal != null) { writeLine( (Base64.isLDIFSafe(attrVal) && isPrintable(attrVal))? attrName + ": " + new String(attrVal, "UTF-8"): attrName + ":: " + Base64.encode(attrVal) ); } return; }
private void writeCompareRequestEntry( LDAPCompareRequest request, LDAPControl[] controls, String requestID) throws IOException, LDAPLocalException { checkState(false); newLine(2); out.write("<assertion name=\"" + request.getAttributeDescription()); out.write("\">"); newLine(3); out.write("<value>"); byte[] vals=request.getAssertionValue(); if (Base64.isLDIFSafe(vals)) out.write(new String(vals,"UTF-8")); else out.write(Base64.encode(vals)); out.write("</value>"); newLine(2); out.write("</assertion>"); // added this fix for OCT' 04 NDK if( (controls !=null) && (controls.length != 0)) { writeControls(controls, 3); } newLine(1); out.write("</compareRequest>"); } /*
writeLine( Base64.isLDIFSafe(newRDN)? "newrdn: " + newRDN: "newrdn:: " + Base64.encode(newRDN)); writeLine( Base64.isLDIFSafe(newSuperior)? "newsuperior: " + newSuperior: "newsuperior:: " + Base64.encode(newSuperior));