@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); } }
@Override public boolean hasAttribute(String name) { return rdn.hasAttribute(name); } }
/** * Indicates whether the two provided strings represent the same RDN. * * @param s1 The string representation of the first RDN for which to make * the determination. It must not be {@code null}. * @param s2 The string representation of the second RDN for which to make * the determination. It must not be {@code null}. * * @return {@code true} if the provided strings represent the same RDN, or * {@code false} if not. * * @throws LDAPException If either of the provided strings cannot be parsed * as an RDN. */ public static boolean equals(final String s1, final String s2) throws LDAPException { return new RDN(s1).equals(new RDN(s2)); }
/** * Retrieves a normalized string representation of the RDN with the provided * string representation. * * @param s The string representation of the RDN to normalize. It must * not be {@code null}. * @param schema The schema to use to generate the normalized string * representation of the RDN. It may be {@code null} if no * schema is available. * * @return The normalized string representation of the RDN with the provided * string representation. * * @throws LDAPException If the provided string cannot be parsed as an RDN. */ public static String normalize(final String s, final Schema schema) throws LDAPException { return new RDN(s, schema).toNormalizedString(); }
/** * Compares the RDN values with the provided string representations to * determine their relative order in a sorted list. * * @param s1 The string representation of the first RDN to be compared. * It must not be {@code null}. * @param s2 The string representation of the second RDN to be compared. * It must not be {@code null}. * @param schema The schema to use to generate the normalized string * representations of the RDNs. It may be {@code null} if no * schema is available. * * @return A negative integer if the first RDN should come before the second * RDN in a sorted list, a positive integer if the first RDN should * come after the second RDN in a sorted list, or zero if the two RDN * values can be considered equal. * * @throws LDAPException If either of the provided strings cannot be parsed * as an RDN. */ public static int compare(final String s1, final String s2, final Schema schema) throws LDAPException { return new RDN(s1, schema).compareTo(new RDN(s2, schema)); } }
final RDN rdnObject = new RDN(rdn); final String[] values = rdnObject.getAttributeValues(); if (noTypes) final String[] names = rdnObject.getAttributeNames(); final String[] returnStrs = new String[names.length];
for (final String name : names) if (rdn.hasAttribute(name)) if (rdn.isMultiValued()) final String[] attrNames = rdn.getAttributeNames(); final byte[][] originalValues = rdn.getByteArrayAttributeValues(); final byte[][] newValues = new byte[originalValues.length][]; for (int i=0; i < attrNames.length; i++) dn = new DN(new RDN(attrNames, newValues, schema), parsedDN.getParent()).toString(); dn = new DN(new RDN(rdn.getAttributeNames()[0], newValue, schema), parsedDN.getParent()).toString();
for(String group : groups) { for (RDN rdn : new DN(group).getRDNs()) { if (rdn.hasAttribute("cn")) { roles.addAll(Arrays.asList(rdn.getAttributeValues())); break;
final String[] attributeNames = rdn.getAttributeNames(); final byte[][] attributeValues = rdn.getByteArrayAttributeValues(); for (int i=0; i < attributeNames.length; i++) rdn.getAttributeValues()[i], name));
final DN parsedOldSuperiorDN = parsedOldDN.getParent(); final RDN parsedNewRDN = new RDN(newRDN); final String[] oldNames = parsedOldRDN.getAttributeNames(); final byte[][] oldValues = parsedOldRDN.getByteArrayAttributeValues(); for (int i=0; i < oldNames.length; i++) if (! parsedNewRDN.hasAttributeValue(oldNames[i], oldValues[i])) final String[] newNames = parsedNewRDN.getAttributeNames(); final byte[][] newValues = parsedNewRDN.getByteArrayAttributeValues(); for (int i=0; i < newNames.length; i++) (! parsedOldRDN.hasAttributeValue(newNames[i], newValues[i])))
if ((rdn != null) && rdn.hasAttribute(name)) final String[] rdnAttrs = rdn.getAttributeNames(); final byte[][] rdnValues = rdn.getByteArrayAttributeValues(); for (int i=0; i < rdnAttrs.length; i++)
for (final RDN rdn : dn.getRDNs()) final String[] names = rdn.getAttributeNames(); final String[] values = rdn.getAttributeValues(); for (int i=0; i < names.length; i++)
for (final String s : rdns[i].getAttributeValues()) rdnStrings[i] = rdns[i].toString();
/** * Retrieves a hash code for this RDN. * * @return The hash code for this RDN. */ @Override() public int hashCode() { return toNormalizedString().hashCode(); }
for (int i=0; i < originalRDNs.length; i++) final String[] originalNames = originalRDNs[i].getAttributeNames(); final String[] newNames = new String[originalNames.length]; for (int j=0; j < originalNames.length; j++) new RDN(newNames, originalRDNs[i].getByteArrayAttributeValues());
if ((sourceRDN != null) && (sourceRDN.hasAttribute(a.getName()))) for (final ASN1OctetString value : values) if (! sourceRDN.hasAttributeValue(a.getName(), value.getValue())) if ((targetRDN != null) && (targetRDN.hasAttribute(a.getName()))) for (final ASN1OctetString value : values) if (! targetRDN.hasAttributeValue(a.getName(), value.getValue())) ((targetRDN != null) && targetRDN.hasAttribute(targetAttr.getName()))) sourceRDN.hasAttributeValue(sourceAttr.getName(), e.getValue().getValue())) targetIterator.next(); if ((targetRDN != null) && targetRDN.hasAttributeValue(targetAttr.getName(), e.getValue().getValue()))
final byte[] valueArray = RDN.readHexString(dnString, ++pos); value = new ASN1OctetString(valueArray); pos += (valueArray.length * 2); pos = RDN.readValueString(dnString, pos, buffer); value = new ASN1OctetString(buffer.toString()); rdnEndPos = pos; rdnList.add(new RDN(attrName, value, schema, getTrimmedRDN(dnString, rdnStartPos,rdnEndPos))); expectMore = false; rdnList.add(new RDN(attrName, value, schema, getTrimmedRDN(dnString, rdnStartPos,rdnEndPos))); pos++; final byte[] valueArray = RDN.readHexString(dnString, ++pos); value = new ASN1OctetString(valueArray); pos += (valueArray.length * 2); pos = RDN.readValueString(dnString, pos, buffer); value = new ASN1OctetString(buffer.toString()); rdnEndPos = pos; final ASN1OctetString[] values = valueList.toArray(new ASN1OctetString[valueList.size()]); rdnList.add(new RDN(names, values, schema, getTrimmedRDN(dnString, rdnStartPos,rdnEndPos))); expectMore = false;
final String[] names = rdn.getAttributeNames(); for (final String s : names) final Attribute[] originalAttrs = rdn.getAttributes(); final byte[][] scrambledValues = new byte[originalAttrs.length][]; for (int i=0; i < originalAttrs.length; i++) return new RDN(names, scrambledValues, schema);
/** * Retrieves the parsed new RDN value for the entry. * * @return The parsed new RDN value for the entry. * * @throws LDAPException If a problem occurs while trying to parse the new * RDN. */ public RDN getParsedNewRDN() throws LDAPException { if (parsedNewRDN == null) { parsedNewRDN = new RDN(newRDN); } return parsedNewRDN; }