Search in sources :

Example 71 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class ModifyDnRequestImplTest method getRequest.

/**
 * Constructs a ModifyDnrequest to test.
 *
 * @return the request
 */
private ModifyDnRequestImpl getRequest() {
    // Construct the ModifyDn request to test
    ModifyDnRequestImpl request = new ModifyDnRequestImpl();
    request.setMessageId(45);
    request.setDeleteOldRdn(true);
    try {
        request.setName(new Dn("dc=admins,dc=apache,dc=org"));
        request.setNewRdn(new Rdn("dc=administrators"));
        request.setNewSuperior(new Dn("dc=groups,dc=apache,dc=org"));
    } catch (LdapException ine) {
    // do nothing
    }
    return request;
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) Rdn(org.apache.directory.api.ldap.model.name.Rdn) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 72 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class ModifyDnRequestImplTest method testNotEqualDiffNewSuperior.

/**
 * Test for inequality when only the newSuperior DNs are different.
 */
@Test
public void testNotEqualDiffNewSuperior() throws LdapException {
    ModifyDnRequestImpl req0 = getRequest();
    req0.setNewSuperior(new Dn("cn=admin,dc=example,dc=com"));
    ModifyDnRequestImpl req1 = getRequest();
    req1.setNewSuperior(new Dn("cn=admin,dc=apache,dc=org"));
    assertFalse(req0.equals(req1));
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 73 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class SearchResultEntryImplTest method testNotEqualDiffObjectName.

/**
 * Tests for inequality when the objectName dn is not the same.
 */
@Test
public void testNotEqualDiffObjectName() throws LdapException {
    SearchResultEntryImpl resp0 = new SearchResultEntryImpl(5);
    resp0.setEntry(getEntry());
    resp0.setObjectName(new Dn("dc=apache,dc=org"));
    SearchResultEntryImpl resp1 = new SearchResultEntryImpl(5);
    resp1.setEntry(getEntry());
    resp1.setObjectName(new Dn("dc=example,dc=com"));
    assertFalse("different object names should not be equal", resp1.equals(resp0));
    assertFalse("different object names should not be equal", resp0.equals(resp1));
}
Also used : SearchResultEntryImpl(org.apache.directory.api.ldap.model.message.SearchResultEntryImpl) Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 74 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class BaseSubtreeSpecification method toString.

/**
 * @see Object#toString()
 */
@Override
public String toString() {
    StringBuilder buffer = new StringBuilder();
    boolean isFirst = true;
    buffer.append('{');
    // The base
    if (!base.isEmpty()) {
        buffer.append(" base \"");
        buffer.append(base.getName());
        buffer.append('"');
        isFirst = false;
    }
    // The minimum
    if (minBaseDistance > 0) {
        if (isFirst) {
            isFirst = false;
            buffer.append(" ");
        } else {
            buffer.append(", ");
        }
        buffer.append("minimum ");
        buffer.append(minBaseDistance);
    }
    // The maximum
    if (maxBaseDistance > UNBOUNDED_MAX) {
        if (isFirst) {
            isFirst = false;
            buffer.append(" ");
        } else {
            buffer.append(", ");
        }
        buffer.append("maximum ");
        buffer.append(maxBaseDistance);
    }
    // The chopBefore exclusions
    if (((chopBefore != null) && !chopBefore.isEmpty()) || ((chopAfter != null) && !chopAfter.isEmpty())) {
        if (isFirst) {
            isFirst = false;
            buffer.append(" ");
        } else {
            buffer.append(", ");
        }
        buffer.append("specificExclusions { ");
        boolean isFirstExclusion = true;
        if (chopBefore != null) {
            for (Dn exclusion : chopBefore) {
                if (isFirstExclusion) {
                    isFirstExclusion = false;
                } else {
                    buffer.append(", ");
                }
                buffer.append("chopBefore: \"");
                buffer.append(exclusion.getName());
                buffer.append('"');
            }
        }
        if (chopAfter != null) {
            for (Dn exclusion : chopAfter) {
                if (isFirstExclusion) {
                    isFirstExclusion = false;
                } else {
                    buffer.append(", ");
                }
                buffer.append("chopAfter: \"");
                buffer.append(exclusion.getName());
                buffer.append('"');
            }
        }
        buffer.append(" }");
    }
    if (refinement != null) {
        if (isFirst) {
            buffer.append(" ");
        } else {
            buffer.append(", ");
        }
        buffer.append("specificationFilter ");
        buffer.append(refinement.toString());
    }
    buffer.append(" }");
    return buffer.toString();
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn)

Example 75 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class QuirkySchemaTest method createFakeConnection.

private LdapConnection createFakeConnection(final String schemaFileName) {
    return new LdapConnection() {

        @Override
        public void unBind() throws LdapException {
        }

        @Override
        public void setTimeOut(long timeOut) {
        }

        @Override
        public void setSchemaManager(SchemaManager schemaManager) {
        }

        @Override
        public void setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetecter) {
        }

        @Override
        public SearchCursor search(SearchRequest searchRequest) throws LdapException {
            return null;
        }

        @Override
        public EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException {
            return null;
        }

        @Override
        public EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException {
            return null;
        }

        @Override
        public void rename(Dn entryDn, Rdn newRdn, boolean deleteOldRdn) throws LdapException {
        }

        @Override
        public void rename(String entryDn, String newRdn, boolean deleteOldRdn) throws LdapException {
        }

        @Override
        public void rename(Dn entryDn, Rdn newRdn) throws LdapException {
        }

        @Override
        public void rename(String entryDn, String newRdn) throws LdapException {
        }

        @Override
        public void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn) throws LdapException {
        }

        @Override
        public void moveAndRename(Dn entryDn, Dn newDn, boolean deleteOldRdn) throws LdapException {
        }

        @Override
        public void moveAndRename(String entryDn, String newDn) throws LdapException {
        }

        @Override
        public void moveAndRename(Dn entryDn, Dn newDn) throws LdapException {
        }

        @Override
        public void move(Dn entryDn, Dn newSuperiorDn) throws LdapException {
        }

        @Override
        public void move(String entryDn, String newSuperiorDn) throws LdapException {
        }

        @Override
        public ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException {
            return null;
        }

        @Override
        public ModifyResponse modify(ModifyRequest modRequest) throws LdapException {
            return null;
        }

        @Override
        public void modify(Entry entry, ModificationOperation modOp) throws LdapException {
        }

        @Override
        public void modify(String dn, Modification... modifications) throws LdapException {
        }

        @Override
        public void modify(Dn dn, Modification... modifications) throws LdapException {
        }

        @Override
        public Entry lookup(String dn, Control[] controls, String... attributes) throws LdapException {
            return lookup(new Dn(dn));
        }

        @Override
        public Entry lookup(String dn, String... attributes) throws LdapException {
            return lookup(new Dn(dn));
        }

        @Override
        public Entry lookup(Dn dn, Control[] controls, String... attributes) throws LdapException {
            return lookup(dn);
        }

        @Override
        public Entry lookup(Dn dn, String... attributes) throws LdapException {
            return lookup(dn);
        }

        @Override
        public Entry lookup(String dn) throws LdapException {
            return lookup(new Dn(dn));
        }

        @Override
        public Entry lookup(Dn dn) throws LdapException {
            if (dn.isRootDse()) {
                Entry entry = new DefaultEntry(dn);
                entry.add(SchemaConstants.SUBSCHEMA_SUBENTRY_AT, SCHEMA_DN);
                return entry;
            } else if (dn.toString().equals(SCHEMA_DN)) {
                Entry entry = loadSchemaEntry(schemaFileName);
                return entry;
            } else {
                throw new UnsupportedOperationException("Unexpected DN " + dn);
            }
        }

        @Override
        public void loadSchemaRelaxed() throws LdapException {
        }

        @Override
        public void loadSchema() throws LdapException {
        }

        @Override
        public boolean isRequestCompleted(int messageId) {
            return true;
        }

        @Override
        public boolean isControlSupported(String controlOID) throws LdapException {
            return true;
        }

        @Override
        public boolean isConnected() {
            return true;
        }

        @Override
        public boolean isAuthenticated() {
            return false;
        }

        @Override
        public List<String> getSupportedControls() throws LdapException {
            return null;
        }

        @Override
        public SchemaManager getSchemaManager() {
            return null;
        }

        @Override
        public Entry getRootDse(String... attributes) throws LdapException {
            return lookup(Dn.ROOT_DSE);
        }

        @Override
        public Entry getRootDse() throws LdapException {
            return lookup(Dn.ROOT_DSE);
        }

        @Override
        public LdapApiService getCodecService() {
            return null;
        }

        @Override
        public BinaryAttributeDetector getBinaryAttributeDetector() {
            return null;
        }

        @Override
        public ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException {
            return null;
        }

        @Override
        public ExtendedResponse extended(Oid oid, byte[] value) throws LdapException {
            return null;
        }

        @Override
        public ExtendedResponse extended(Oid oid) throws LdapException {
            return null;
        }

        @Override
        public ExtendedResponse extended(String oid, byte[] value) throws LdapException {
            return null;
        }

        @Override
        public ExtendedResponse extended(String oid) throws LdapException {
            return null;
        }

        @Override
        public boolean exists(Dn dn) throws LdapException {
            return false;
        }

        @Override
        public boolean exists(String dn) throws LdapException {
            return false;
        }

        @Override
        public boolean doesFutureExistFor(int messageId) {
            return false;
        }

        @Override
        public DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException {
            return null;
        }

        @Override
        public void delete(Dn dn) throws LdapException {
        }

        @Override
        public void delete(String dn) throws LdapException {
        }

        @Override
        public boolean connect() throws LdapException {
            return true;
        }

        @Override
        public CompareResponse compare(CompareRequest compareRequest) throws LdapException {
            return null;
        }

        @Override
        public boolean compare(Dn dn, String attributeName, byte[] value) throws LdapException {
            return false;
        }

        @Override
        public boolean compare(Dn dn, String attributeName, String value) throws LdapException {
            return false;
        }

        @Override
        public boolean compare(String dn, String attributeName, byte[] value) throws LdapException {
            return false;
        }

        @Override
        public boolean compare(String dn, String attributeName, String value) throws LdapException {
            return false;
        }

        @Override
        public void close() throws IOException {
        }

        @Override
        public BindResponse bind(BindRequest bindRequest) throws LdapException {
            return null;
        }

        @Override
        public void bind(Dn name, String credentials) throws LdapException {
        }

        @Override
        public void bind(Dn name) throws LdapException {
        }

        @Override
        public void bind(String name, String credentials) throws LdapException {
        }

        @Override
        public void bind(String name) throws LdapException {
        }

        @Override
        public void bind() throws LdapException {
        }

        @Override
        public void anonymousBind() throws LdapException {
        }

        @Override
        public AddResponse add(AddRequest addRequest) throws LdapException {
            return null;
        }

        @Override
        public void add(Entry entry) throws LdapException {
        }

        @Override
        public void abandon(AbandonRequest abandonRequest) {
        }

        @Override
        public void abandon(int messageId) {
        }

        @Override
        public boolean compare(String dn, String attributeName, Value value) throws LdapException {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public boolean compare(Dn dn, String attributeName, Value value) throws LdapException {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public BindResponse bind(SaslRequest saslRequest) throws LdapException {
            // TODO Auto-generated method stub
            return null;
        }
    };
}
Also used : SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) Modification(org.apache.directory.api.ldap.model.entry.Modification) BindRequest(org.apache.directory.api.ldap.model.message.BindRequest) AbandonRequest(org.apache.directory.api.ldap.model.message.AbandonRequest) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Dn(org.apache.directory.api.ldap.model.name.Dn) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) ModifyRequest(org.apache.directory.api.ldap.model.message.ModifyRequest) Oid(org.apache.directory.api.asn1.util.Oid) BinaryAttributeDetector(org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector) AddRequest(org.apache.directory.api.ldap.model.message.AddRequest) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) ModificationOperation(org.apache.directory.api.ldap.model.entry.ModificationOperation) ExtendedRequest(org.apache.directory.api.ldap.model.message.ExtendedRequest) SearchScope(org.apache.directory.api.ldap.model.message.SearchScope) Value(org.apache.directory.api.ldap.model.entry.Value) Rdn(org.apache.directory.api.ldap.model.name.Rdn) DeleteRequest(org.apache.directory.api.ldap.model.message.DeleteRequest)

Aggregations

Dn (org.apache.directory.api.ldap.model.name.Dn)307 Test (org.junit.Test)183 Rdn (org.apache.directory.api.ldap.model.name.Rdn)63 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)50 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)39 Entry (org.apache.directory.api.ldap.model.entry.Entry)34 DnNode (org.apache.directory.api.ldap.util.tree.DnNode)30 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)20 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)19 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)17 Modification (org.apache.directory.api.ldap.model.entry.Modification)17 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)16 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)10 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)10 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)10 Referral (org.apache.directory.api.ldap.model.message.Referral)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)8 Value (org.apache.directory.api.ldap.model.entry.Value)8