/** * Writes the specified strings as XML comments. * @param lines Comments to be written */ public void writeComments(String lines) throws IOException { newLine(1); out.write("<!-- "); out.write(lines); out.write(" -->"); return; }
/** * Writes referrences that are returned from a search. * @param ref search reference */ private void writeSearchResultReference(LDAPSearchResultReference ref) throws IOException { String[] refs = ref.getReferrals(); newLine(2); writeTagWithID("searchResultReference", ref); //out.write("<searchResultReference>"); for(int i=0; i< refs.length; i++){ newLine(3); out.write("<ref>"); out.write(refs[i]); out.write("</ref>"); } newLine(2); out.write("</searchResultReference>"); }
newLine(2); out.write("<attributes>"); String[] attrs = request.getAttributes(); for(int i=0; i< attrs.length; i++){ newLine(3); out.write("<attribute name=\""); out.write(attrs[i]); out.write("\"/>"); newLine(2); out.write("</attributes>"); newLine(2); out.write("<filter>"); Iterator itr=request.getSearchFilter(); writeFilter(itr); newLine(2); out.write("</filter>"); writeControls(controls, 3); newLine(1); out.write("</searchRequest>");
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>"); } /*
/** * Writes a control in DSML. * <p>Used by writeResult and by the searchResponse case in writeMessage. * @param controls Controls to be written * @param indent Size of indentation for writting. */ private void writeControls(LDAPControl[] controls, int indent) throws IOException { for(int i=0; i<controls.length; i++){ newLine(indent); out.write("<control type=\""); out.write(controls[i].getID()); out.write("\" criticality=\""+controls[i].isCritical()+ "\""); byte value[] = controls[i].getValue(); if (value == null){ out.write(" / >"); } else { out.write(">"); newLine(indent+1); out.write("<controlValue xsi:type=\"xsd:base64Binary\">"); out.write(Base64.encode(value)); out.write("</controlValue>"); newLine(indent); out.write("</control>"); } } return; }
private void writeModifyDNRequestEntry( LDAPModifyDNRequest request, LDAPControl[] controls, String requestID) throws IOException, LDAPLocalException { checkState(false); // added this fix for OCT' 04 NDK if( (controls !=null) && (controls.length != 0)) { writeControls(controls, 3); } newLine(1); out.write("</modDNRequest>"); return; }
private void writeDeleteRequestEntry( LDAPDeleteRequest request, LDAPControl[] controls, String requestID) throws IOException, LDAPLocalException { checkState(false); // added this fix for OCT' 04 NDK if( (controls !=null) && (controls.length != 0)) { writeControls(controls, 3); } newLine(1); out.write("</delRequest>"); return; }
switch (op){ case RfcFilter.AND: newLine(3); out.write("<and>"); break; case RfcFilter.OR: newLine(3); out.write("<or>"); break; case RfcFilter.NOT: newLine(3); out.write("<not>"); break; case RfcFilter.EQUALITY_MATCH:{ newLine(4); out.write("<equalityMatch name=\""); out.write((String)itr.next()); out.write("\">"); byte[] value = (byte[])itr.next(); newLine(5); out.write("<value>"); out.write(byteString(value)); out.write("</value>"); newLine(4); out.write("</equalityMatch>"); break; newLine(4); out.write("<greaterOrEqual name=\"");
/** * Used to write an attribute and its values. * @param attr Attribute to be written. */ private void writeAttribute(LDAPAttribute attr) throws IOException { newLine(3); out.write("<attr name=\""); out.write(attr.getName()); out.write("\">"); String values[] = attr.getStringValueArray(); byte bytevalues[][] = attr.getByteValueArray(); for(int i=0; i<values.length; i++){ newLine(4); if (Base64.isValidUTF8(bytevalues[i],true) && this.isXMLSafe(bytevalues[i])){ out.write("<value>"); String xmlvalue = makeAttributeSafe(values[i]); out.write(xmlvalue); out.write("</value>"); } else { out.write("<value xsi:type=\"xsd:base64Binary\">"); out.write(Base64.encode(bytevalues[i])); out.write("</value>"); } } newLine(3); out.write("</attr>"); return; }
throw new IOException(lle.toString()); newLine(1); out.write("<errorResponse type=\""); if (e instanceof LDAPException){ out.write("other\">"); newLine(2); out.write("<message>"); newLine(3); if (e instanceof LDAPException) { LDAPException le = (LDAPException) e; out.write(makeXMLSafe(e.getMessage())); newLine(2); out.write("</message>"); newLine(1); out.write("</errorResponse>"); return;
private void writeExtendedRequestEntry( LDAPExtendedRequest request, LDAPControl[] controls, String requestID) throws IOException, LDAPLocalException { checkState(false); newLine(2); out.write("<requestName>"); out.write(request.getExtendedOperation().getID()); out.write("</requestName>"); byte[] vals=request.getExtendedOperation().getValue(); if( vals != null) { newLine(2); out.write("<requestValue xsi:type=\"xsd:base64Binary\">"); out.write(Base64.encode(vals)); out.write("</requestValue>"); } // added this fix for OCT' 04 NDK if( (controls !=null) && (controls.length != 0)) { writeControls(controls, 3); } newLine(1); out.write("</extendedRequest>"); return; }
if (referrals != null){ for(int i=0; i<referrals.length; i++){ newLine(indent); out.write("<referral>"+referrals[i]+"</referral>"); newLine(indent); out.write("<resultCode code=\""); out.write(new Integer(result.getResultCode()).toString()); newLine(indent); out.write("<errorMessage>"); out.write(makeXMLSafe(temp));
for(int i=0; i< modList.length; i++){ LDAPAttribute attr=modList[i].getAttribute(); newLine(2); out.write("<modification name=\""); out.write(attr.getName()); byte bytevalues[][] = attr.getByteValueArray(); for(int j=0; j<values.length; j++){ newLine(3); if (Base64.isValidUTF8(bytevalues[j], false)){ out.write("<value>"); newLine(2); out.write("</modification>"); newLine(1); out.write("</modifyRequest>"); return;
private void writeAddRequestEntry( LDAPAddRequest request, LDAPControl[] controls, String requestID) throws IOException, LDAPLocalException { checkState(false); LDAPEntry entry=request.getEntry(); LDAPAttributeSet set = entry.getAttributeSet(); Iterator i = set.iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next()); } if( (controls !=null) && (controls.length != 0)) { writeControls(controls, 3); } newLine(1); out.write("</addRequest>"); return; }
newLine(1); writeTagWithID("searchRequest", messageToWrite); state = REQUEST_BATCH; newLine(1); writeTagWithID("extendedRequest", messageToWrite); state = REQUEST_BATCH; newLine(1); writeTagWithID("compareRequest", messageToWrite); state = REQUEST_BATCH; newLine(1); writeTagWithID("addRequest", messageToWrite); state = REQUEST_BATCH; newLine(1); writeTagWithID("modifyRequest", messageToWrite); state = REQUEST_BATCH; newLine(1); writeTagWithID("modDNRequest", messageToWrite); state = REQUEST_BATCH; newLine(1); writeTagWithID("delRequest", messageToWrite); state = REQUEST_BATCH; newLine(1);