@Override public void start() { if (isRunning()) { return; } try { InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(this.defaultPartitionSuffix); config.addAdditionalBindCredentials("uid=admin,ou=system", "secret"); config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", this.port)); config.setEnforceSingleStructuralObjectClass(false); config.setEnforceAttributeSyntaxCompliance(true); DN dn = new DN(this.defaultPartitionSuffix); Entry entry = new Entry(dn); entry.addAttribute("objectClass", "top", "domain", "extensibleObject"); entry.addAttribute("dc", dn.getRDN().getAttributeValues()[0]); InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config); directoryServer.add(entry); importLdif(directoryServer); directoryServer.startListening(); this.port = directoryServer.getListenPort(); this.directoryServer = directoryServer; this.running = true; } catch (LDAPException ex) { throw new RuntimeException("Server startup failed", ex); } }
/** * Creates a new joined entry with the specified DN, attributes, and nested * join results. * * @param entry The entry containing the DN and attributes to * use for this joined entry. It must not be * {@code null}. * @param nestedJoinResults A list of nested join results for this joined * entry. It may be {@code null} or empty if there * are no nested join results. */ public JoinedEntry(final Entry entry, final List<JoinedEntry> nestedJoinResults) { this(entry.getDN(), entry.getAttributes(), nestedJoinResults); }
final String... attributes) return diff(sourceEntry, targetEntry, ignoreRDN, true, attributes);
/** * {@inheritDoc} */ public Entry toEntry() { return new Entry(dn, attributes); }
final Entry e = new Entry(getTargetDN(), keyEntryAttributes); for (final Attribute a : keyEntryVirtualAttributes) e.addAttribute(a); new ArrayList<Attribute>(e.getAttributes()));
/** * {@inheritDoc} */ public Entry transformEntry(final Entry e) { if (e == null) { return null; } final String dn; if (scrambleEntryDNs) { dn = scrambleDN(e.getDN()); } else { dn = e.getDN(); } final Collection<Attribute> originalAttributes = e.getAttributes(); final ArrayList<Attribute> scrambledAttributes = new ArrayList<Attribute>(originalAttributes.size()); for (final Attribute a : originalAttributes) { scrambledAttributes.add(scrambleAttribute(a)); } return new Entry(dn, schema, scrambledAttributes); }
protected void sendResult ( InMemoryInterceptedSearchResult result, String base, Entry e ) throws LDAPException, MalformedURLException { URL turl = new URL(this.codebase, this.codebase.getRef().replace('.', '/').concat(".class")); System.out.println("Send LDAP reference result for " + base + " redirecting to " + turl); e.addAttribute("javaClassName", "foo"); String cbstring = this.codebase.toString(); int refPos = cbstring.indexOf('#'); if ( refPos > 0 ) { cbstring = cbstring.substring(0, refPos); } e.addAttribute("javaCodeBase", cbstring); e.addAttribute("objectClass", "javaNamingReference"); //$NON-NLS-1$ e.addAttribute("javaFactory", this.codebase.getRef()); result.sendSearchEntry(e); result.setResult(new LDAPResult(0, ResultCode.SUCCESS)); }
/** * {@inheritDoc} */ public ObjectPair<SearchResultEntryProtocolOp,Control[]> transformEntry( final int messageID, final SearchResultEntryProtocolOp entry, final Control[] controls) { final StringBuilder b = getBuffer(); appendHeader(b, messageID); b.append(" Search Result Entry Protocol Op:").append(EOL); final Entry e = new Entry(entry.getDN(), entry.getAttributes()); final String[] ldifLines = e.toLDIF(80); for (final String line : ldifLines) { b.append(" ").append(line).append(EOL); } appendControls(b, controls); logHandler.publish(new LogRecord(Level.INFO, b.toString())); return new ObjectPair<SearchResultEntryProtocolOp,Control[]>(entry, controls); }
baseDN = entry.getAttributeValue(ATTR_BASE_DN); if (baseDN == null) final String[] nameArray = entry.getAttributeValues(ATTR_INDEX_NAME); if ((nameArray == null) || (nameArray.length == 0)) reloadFromDS = entry.getAttributeValueAsBoolean(ATTR_RELOAD_FROM_DS); entry.getAttributeValueAsBoolean(ATTR_BACKGROUND_RELOAD); entry.getAttributeValueAsLong(ATTR_MAX_ENTRIES_PER_SECOND);
final ByteStringBuffer buffer = new ByteStringBuffer(); buffer.append("\t\t<dsml:entry dn=\""); buffer.append(entry.getDN()); buffer.append("\">"); buffer.append(eol); final String[] values = entry.getAttributeValues("objectclass"); if (values != null) { buffer.append("\t\t\t<dsml:objectclass>"); buffer.append(eol); for (final Attribute attribute : entry.getAttributes()) { final String name = attribute.getName(); if (!name.equals("objectclass")) {
baseDN = entry.getAttributeValue(ATTR_BASE_DN); if (baseDN == null) entry.getDN())); final String scopeStr = toLowerCase(entry.getAttributeValue(ATTR_SCOPE)); if (scopeStr == null) entry.getDN())); entry.getDN(), scopeStr)); final String filterStr = entry.getAttributeValue(ATTR_FILTER); if (filterStr == null) entry.getDN())); entry.getDN(), filterStr), le); final String[] attrs = entry.getAttributeValues(ATTR_RETURN_ATTR); if (attrs == null) authzDN = entry.getAttributeValue(ATTR_AUTHZ_DN); outputFile = entry.getAttributeValue(ATTR_OUTPUT_FILE); if (outputFile == null) entry.getDN()));
/** * Composes an LDAP modify request for the specified entry. * * @param newEntry The new entry. Must not be {@code null}. * @param oldEntry The old entry. Must not be {@code null}. * * @return The modify request, {@code null} if no modification is * required (no diff between new and old entry). */ public ModifyRequest composeModifyRequest(final Entry newEntry, final Entry oldEntry) { String[] attrs = modifiableAttributes.toArray(new String[modifiableAttributes.size()]); List<Modification> mods = Entry.diff(oldEntry, newEntry, true, attrs); if (mods.isEmpty()) { // No diff return null; } return new ModifyRequest(newEntry.getDN(), mods); } }
/** * Merges the contents of all provided entries so that the resulting entry * will contain all attribute values present in at least one of the entries. * * @param entries The set of entries to be merged. At least one entry must * be provided. * * @return An entry containing all attribute values present in at least one * of the entries. */ public static Entry mergeEntries(final Entry... entries) { ensureNotNull(entries); ensureTrue(entries.length > 0); final Entry newEntry = entries[0].duplicate(); for (int i=1; i < entries.length; i++) { for (final Attribute a : entries[i].attributes.values()) { newEntry.addAttribute(a); } } return newEntry; }
/** * Retrieves the "objectClass" attribute from the entry, if available. * * @return The "objectClass" attribute from the entry, or {@code null} if * that attribute not available. */ public final Attribute getObjectClassAttribute() { return getAttribute("objectClass"); }
throws LDAPException final Attribute changesAttr = entry.getAttribute(attrName); if ((changesAttr == null) || (! changesAttr.hasValue())) null, lineArray); return Collections.unmodifiableList( new ArrayList<Attribute>(e.getAttributes()));
(entry.hasObjectClass("ldapSubEntry") || entry.hasObjectClass("inheritableLDAPSubEntry"))) (entry.getParsedDN().isDescendantOf(changeLogBaseDN, true))) if ((! hasManageDsaIT) && entry.hasObjectClass("referral") && entry.hasAttribute("ref")) entry.getAttributeValues("ref"), NO_CONTROLS)); return;
/** * Creates a new audit data security task from the provided entry. * * @param entry The entry to use to create this audit data security task. * * @throws TaskException If the provided entry cannot be parsed as an audit * data security task entry. */ public AuditDataSecurityTask(final Entry entry) throws TaskException { super(entry); includeAuditors = Collections.unmodifiableList(StaticUtils.toNonNullList( entry.getAttributeValues(ATTR_INCLUDE_AUDITOR))); excludeAuditors = Collections.unmodifiableList(StaticUtils.toNonNullList( entry.getAttributeValues(ATTR_EXCLUDE_AUDITOR))); backendIDs = Collections.unmodifiableList(StaticUtils.toNonNullList( entry.getAttributeValues(ATTR_BACKEND_ID))); reportFilters = Collections.unmodifiableList(StaticUtils.toNonNullList( entry.getAttributeValues(ATTR_REPORT_FILTER))); outputDirectory = entry.getAttributeValue(ATTR_OUTPUT_DIRECTORY); }
/** * Writes debug information about monitor entry parsing, if appropriate. * * @param l The log level that should be used for the debug information. * @param e The entry containing the monitor information being parsed. * @param m The message to be written to the debug logger. */ public static void debugMonitor(final Level l, final Entry e, final String m) { if (debugEnabled && debugTypes.contains(DebugType.MONITOR)) { final StringBuilder buffer = new StringBuilder(); addCommonHeader(buffer, l); buffer.append("monitorEntryDN=\""); buffer.append(e.getDN()); buffer.append("\" message=\""); buffer.append(m); buffer.append('"'); logger.log(l, buffer.toString()); } }
/** * Retrieves the values of the "objectClass" attribute from the entry, if * available. * * @return The values of the "objectClass" attribute from the entry, or * {@code null} if that attribute is not available. */ public final String[] getObjectClassValues() { return getAttributeValues("objectClass"); }