/** * Returns a string representation of this class. * * @return The string representation of this class. */ public String toString() { StringBuffer result = new StringBuffer("LDAPControl: "); result.append("((oid="+getID()+""); result.append(",critical="+isCritical()+")"); result.append("(value="+getValue()+"))"); return result.toString(); } /**
private void writeControls(Element e, LDAPControl[] controls) { for (int i=0; i< controls.length; i++){ Element el = doc.createElement("control"); el.setAttribute("NumericOID", controls[i].getID()); el.setAttribute("criticality", ""+controls[i].isCritical()); byte byteValue[] = controls[i].getValue(); if (byteValue!= null){ Element value = doc.createElement("controlValue"); value.setAttribute("xsi:type", "base64Binary"); Text text = doc.createTextNode( Base64.encode(byteValue)); value.appendChild(text); el.appendChild(value); } e.appendChild( el ); } }
/** * Constructs a control from a com.novell.ldap.LDAPControl object */ protected LDAPControl( com.novell.ldap.LDAPControl control) { super( control.getID(), control.isCritical(), control.getValue()); return; }
private void writeControl(LDAPControl control, StringBuffer buff) throws java.io.IOException { buff.append("<control type=\""); buff.append(control.getID()); buff.append("\" criticality=\""+ control.isCritical()+ "\""); byte value[] = control.getValue(); if (value == null){ buff.append("/>"); } else { buff.append(">"); buff.append(ValueXMLhandler.newLine(2)); buff.append("<controlValue xsi:type=\"xsd:base64Binary\">"); buff.append(Base64.encode(value)); buff.append("</controlValue>"); buff.append(ValueXMLhandler.newLine(1)); buff.append("</control>"); } buff.append(ValueXMLhandler.newLine(0)); }
out.write("\" criticality=\""+isCritical()+ "\""); byte value[] = getValue(); if (value == null){ out.write("/>");
/** * 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; }
buff.append("\" criticality=\""+isCritical()+ "\""); byte value[] = getValue(); if (value == null){ buff.append("/>");
LDAPControl readObject = (LDAPControl)LDAPControl.readDSML(istream); byte[] vals = readObject.getValue(); if( vals == null) { this.control = new RfcControl( new RfcLDAPOID(readObject.getID()),
/** * Write control line(s). * * @param ctrls LDAPControl array object */ private void writeControls(LDAPControl[] ctrls) throws IOException { for ( int i = 0; i < ctrls.length; i++ ) { // get control value byte[] cVal = ctrls[i].getValue(); // write control value writeLine( (cVal != null && cVal.length > 0)? "control: " + ctrls[i].getID() + " " + ctrls[i].isCritical() + ":: " + Base64.encode(cVal): "control: " + ctrls[i].getID() + " " + ctrls[i].isCritical() ); } return; }
/** * Returns a copy of the current LDAPControl object. * * @return A copy of the current LDAPControl object. */ public Object clone() { LDAPControl cont; try { cont = (LDAPControl)super.clone(); } catch( CloneNotSupportedException ce) { throw new RuntimeException("Internal error, cannot create clone"); } byte[] vals = this.getValue(); byte[] twin = null; if( vals != null) { //is this necessary? // Yes even though the contructor above allocates a // new ASN1OctetString, vals in that constuctor // is only copied by reference twin = new byte[vals.length]; for(int i = 0; i < vals.length; i++){ twin[i]=vals[i]; } cont.control = new RfcControl( new RfcLDAPOID(getID()), new ASN1Boolean(isCritical()), new ASN1OctetString(twin)); } return cont; }