public Map<String, Object> get() { if (handleEndOfResults()) return null; try { Map<String, Object> entry = new LinkedHashMap<>(attributes.size() + 1); LDAPEntry en = null; en = lsr.next(); entry.put("dn", en.getDN()); if (attributes != null && attributes.size() > 0) { for (int col = 0; col < attributes.size(); col++) { Object val = readValue(en.getAttributeSet().getAttribute(attributes.get(col))); if (val != null) entry.put(attributes.get(col),val ); } } else { // make it dynamic Iterator<LDAPAttribute> iter = en.getAttributeSet().iterator(); while (iter.hasNext()) { LDAPAttribute attr = iter.next(); Object val = readValue(attr); if (val != null) entry.put(attr.getName(), readValue(attr)); } } //System.out.println("entry " + entry); return entry; } catch (LDAPException e) { e.printStackTrace(); throw new RuntimeException("Error getting next ldap entry " + e.getLDAPErrorMessage()); } }
/** * Returns an iterator over the elements of this set. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttributeSet.html#iterator()"> com.novell.ldap.LDAPAttributeSet.iterator()</a> */ public Iterator iterator() { return new WrappedIterator(this.attrSet.iterator()); }
/** * Returns a string representation of this LDAPAttributeSet * * @return a string representation of this LDAPAttributeSet */ public String toString() { StringBuffer retValue = new StringBuffer("LDAPAttributeSet: "); Iterator attrs = iterator(); boolean first = true; while( attrs.hasNext()) { if( ! first) { retValue.append(" "); } first = false; LDAPAttribute attr = (LDAPAttribute)attrs.next(); retValue.append(attr.toString()); } return retValue.toString(); }
/** * 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 { java.io.Writer out=new java.io.OutputStreamWriter(oout,"UTF-8"); out.write("<LDAPAttributeSet>"); Iterator i=iterator(); while (i.hasNext()){ writeAttribute((LDAPAttribute) i.next(),out); } newLine(0,out); out.write("</LDAPAttributeSet>"); out.close(); }
LDAPEntry entry1 = searchResults.next(); System.out.println("\n" + entry1.getDN()); System.out.println(" Attributes: "); LDAPAttributeSet attributeSet1 = entry1.getAttributeSet(); Iterator allAttributes1 = attributeSet1.iterator(); while(allAttributes1.hasNext()) { LDAPAttribute attribute = (LDAPAttribute)allAttributes1.next(); String attrName = attribute.getName(); System.out.println(" " + attrName); Enumeration allValues1 = attribute.getStringValues(); while(allValues1.hasMoreElements()) { oid = (String) allValues1.nextElement(); if ( (attrName.equalsIgnoreCase("supportedExtension")) || (attrName.equalsIgnoreCase("supportedControl"))) { System.out.println(" " + oid); } } }
(LDAPAttributeSet)LDAPAttributeSet.readDSML(istream); Iterator i = readObject.iterator(); while (i.hasNext()){ this.add( ((LDAPAttribute)i.next()).clone());
/** * Returns a deep copy of this attribute set. * * @return A deep copy of this attribute set. */ public Object clone() { try { Object newObj = super.clone(); ((LDAPAttributeSet)newObj).clear(); Iterator i = this.iterator(); while (i.hasNext()){ ((LDAPAttributeSet)newObj).add( ((LDAPAttribute)i.next()).clone()); } return newObj; } catch( CloneNotSupportedException ce) { throw new RuntimeException("Internal error, cannot create clone"); } }
private Element myWriteEntry( LDAPEntry entry, LDAPControl[] controls ) { Element e = doc.createElement("searchResultEntry"); e.setAttribute("dn", entry.getDN()); LDAPAttributeSet set = entry.getAttributeSet(); Iterator iterator = set.iterator(); while (iterator.hasNext()){ LDAPAttribute attr = (LDAPAttribute)iterator.next(); Element attribute = doc.createElement("attr"); writeAttribute(attribute, attr); e.appendChild(attribute); } if (controls != null) { writeControls(e, controls); } searchNode.appendChild( e); return e; }
/** * 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 { java.io.Writer out=new java.io.OutputStreamWriter(oout,"UTF-8"); out.write("<LDAPEntry dn=\""); out.write(getDN()); out.write("\">"); Iterator i = getAttributeSet().iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next(),out); } newLine(0,out); out.write("</LDAPEntry>"); out.close(); } /**
buff.append("<LDAPAttributeSet>"); Iterator i=iterator(); while (i.hasNext()){ writeAttribute((LDAPAttribute) i.next(),buff);
buff.append("\">"); Iterator i = getAttributeSet().iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next(),buff);
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; }
Iterator i = set.iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next());
buff.append("\">"); Iterator i = entry.getAttributeSet().iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next(),buff);
Iterator i = this.iterator();
/** * Build the attribuite list from an LDAPEntry. * * @param entry The LDAPEntry associated with this add request. */ private static final RfcAttributeList makeRfcAttrList( LDAPEntry entry) { // convert Java-API LDAPEntry to RFC2251 AttributeList LDAPAttributeSet attrSet = entry.getAttributeSet(); RfcAttributeList attrList = new RfcAttributeList(attrSet.size()); Iterator itr = attrSet.iterator(); while (itr.hasNext()) { LDAPAttribute attr = (LDAPAttribute)itr.next(); ASN1SetOf vals = new ASN1SetOf(attr.size()); Enumeration attrEnum = attr.getByteValues(); while(attrEnum.hasMoreElements()) { vals.add(new RfcAttributeValue((byte[])attrEnum.nextElement())); } attrList.add(new RfcAttributeTypeAndValues( new RfcAttributeDescription(attr.getName()), vals)); } return attrList; }
LDAPAttributeSet attrSet = entry.getAttributeSet(); Iterator<LDAPAttribute> allAttrs = attrSet.iterator(); while (allAttrs.hasNext()) { LDAPAttribute attr = allAttrs.next();
/** * Creates a ASN Encoded Sequence for the specified entry. * @param entry The LDAPEntry to be encoded. * @return ASN Encoded representation of the entry. */ private static ASN1Sequence getEntrySequence(LDAPEntry entry) { if (entry == null) { throw new IllegalArgumentException("Argument \"entry\" cannot be null"); } Iterator entryiterator = entry.getAttributeSet().iterator(); ASN1Sequence attributelistsequence = new ASN1Sequence(); while (entryiterator.hasNext()) { ASN1Sequence attributesequence = new ASN1Sequence(); LDAPAttribute attribute = (LDAPAttribute) entryiterator.next(); attributesequence.add(new ASN1OctetString(attribute.getName())); ASN1Set valueset = new ASN1Set(); String[] valueArray = attribute.getStringValueArray(); if (valueArray != null) for (int i = 0; i < valueArray.length; i++) { valueset.add(new ASN1OctetString(valueArray[i])); } attributesequence.add(valueset); attributelistsequence.add(attributesequence); } return attributelistsequence; } /**
Iterator allAttrs = attrSet.iterator();
add.setObjectClass(objectClass); Iterator it = entry.getAttributeSet().iterator();