/** * This method does DSML serialization of the instance. * * @param oout Outputstream where the serialzed data has to be written * * @throws IOException if write fails on OutputStream */ public void writeDSML(java.io.OutputStream oout) throws java.io.IOException { com.novell.ldap.util.DSMLWriter out=new com.novell.ldap.util.DSMLWriter(oout); try{ out.useIndent(true); out.setIndent(4); out.writeMessage(this); out.finish(); }catch(LDAPLocalException le){ } }
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; }
/** * Write an LDAP entry into LDIF file as LDAPContent data. * An LDAPEntry is written as a SearchResultEntry record. * * <p>You are not allowed to mix request data and content data</p> * * @param entry LDAPEntry object * * @throws IOException if an I/O error occurs. * * @see com.novell.ldap.LDAPEntry */ public void writeEntry( LDAPEntry entry) throws IOException, LDAPLocalException { checkState(true); writeEntry( entry, null, null); return; }
(messageToWrite instanceof LDAPSearchResult) || (messageToWrite instanceof LDAPSearchResultReference)){ checkState(true); } else {//must be a request checkState(false); newLine(1); writeTagWithID("searchRequest", messageToWrite); state = REQUEST_BATCH; writeSearchRequest((LDAPSearchRequest) messageToWrite); break; newLine(1); writeTagWithID("extendedRequest", messageToWrite); state = REQUEST_BATCH; writeExtendedRequest((LDAPExtendedRequest) messageToWrite); break; newLine(1); writeTagWithID("compareRequest", messageToWrite); state = REQUEST_BATCH; writeCompareRequest((LDAPCompareRequest) messageToWrite); break; newLine(1); writeTagWithID("addRequest", messageToWrite);
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; }
throws IOException, LDAPLocalException checkState(false); 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>");
/** * 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; }
checkState(true); } catch (LDAPLocalException lle){ 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; String msg = Integer.toString(le.getResultCode()) + ":" + le.getMessage(); out.write(makeXMLSafe(msg)); } else { out.write(makeXMLSafe(e.getMessage())); newLine(2); out.write("</message>"); newLine(1); out.write("</errorResponse>"); 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=\"");
writeControls(controls, indent); 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)); out.write("</errorMessage>");
DSMLWriter writer = new DSMLWriter(out); writer.writeMessage(message); writer.finish();
/** * 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>"); }
/** * 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; }
String matchedDN = ((LDAPResponse) message).getMatchedDN(); if (matchedDN != null && !matchedDN.equals("")){ out.write(" matchedDN=\"" + this.makeAttributeSafe(matchedDN) + "\""); out.write(" dn=\"" + this.makeAttributeSafe(dn) + "\""); out.write(" dn=\"" + this.makeAttributeSafe(dn) + "\""); out.write(" dn=\"" + this.makeAttributeSafe(dn) + "\""); out.write(" dn=\"" + this.makeAttributeSafe(dn) + "\""); out.write(" dn=\"" + this.makeAttributeSafe(dn) + "\""); out.write(" newrdn=\""); out.write(((LDAPModifyDNRequest) message).getNewRDN() + "\" deleteoldrdn=\""); out.write(" dn=\"" + this.makeAttributeSafe(dn) + "\""); switch(scope) { case LDAPConnection.SCOPE_BASE:
throws IOException, LDAPLocalException checkState(true); newLine(2); out.write("<searchResultEntry dn=\""); out.write(this.makeAttributeSafe(entry.getDN())); if( requestID != null) { out.write("\" requestID=\"" + requestID); Iterator i = set.iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next()); writeControls(controls, 3); newLine(2); out.write("</searchResultEntry>");
/** * Write an LDAP entry into LDIF file as LDAPContent data. * An LDAPEntry is written as a SearchResultEntry record. * * <p>You are not allowed to mix request data and content data</p> * * @param entry LDAPEntry object * * @param controls Controls that were returned with this entry * * @throws IOException if an I/O error occurs. * * @see com.novell.ldap.LDAPEntry */ public void writeEntry( LDAPEntry entry, LDAPControl[] controls) throws IOException, LDAPLocalException { checkState(true); writeEntry( entry, controls, null); return; }
throws IOException, LDAPLocalException checkState(false); LDAPModification[] modList=request.getModifications(); 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>"); String xmlvalue = makeAttributeSafe(values[j]); out.write(xmlvalue); out.write("</value>"); newLine(2); out.write("</modification>"); writeControls(controls, 3); newLine(1); out.write("</modifyRequest>"); return;
com.novell.ldap.util.DSMLWriter((ObjectOutputStream)out); writer.useIndent(true); writer.setIndent(4); out.writeUTF(header); writer.writeMessage(this); writer.finish(); out.writeUTF(tail);
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; }