Search in sources :

Example 41 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class SchemaAwareEntryTest method createEntry.

/**
 * Helper method which creates an entry with 4 attributes.
 */
private Entry createEntry() {
    try {
        Entry entry = new DefaultEntry(exampleDn);
        Attribute attrOC = new DefaultAttribute("objectClass", "top", "person");
        Attribute attrCN = new DefaultAttribute("cn", "test1", "test2");
        Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2");
        Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2);
        entry.put(attrOC, attrCN, attrSN, attrPWD);
        return entry;
    } catch (LdapException ne) {
        // Do nothing
        return null;
    }
}
Also used : DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 42 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class SearchRequestTest method testRequestWithAttributes1Attribute.

/**
 * Test parsing of a request with an Attributes element with 1 Attribute element
 * @throws NamingException
 */
@Test
public void testRequestWithAttributes1Attribute() throws LdapException {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(SearchRequestTest.class.getResource("request_with_attributes_1_attribute.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
    List<String> attributes = searchRequest.getAttributes();
    assertEquals(1, attributes.size());
    String attribute = attributes.get(0);
    assertEquals("sn", attribute);
}
Also used : SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Example 43 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DefaultSchemaLoader method loadDitStructureRules.

private void loadDitStructureRules(Attribute ditStructureRules) throws LdapException {
    if (ditStructureRules == null) {
        return;
    }
    for (Value value : ditStructureRules) {
        String desc = value.getValue();
        try {
            DitStructureRule ditStructureRule = DSR_DESCR_SCHEMA_PARSER.parseDITStructureRuleDescription(desc);
            updateSchemas(ditStructureRule);
        } catch (ParseException pe) {
            throw new LdapException(pe);
        }
    }
}
Also used : DitStructureRule(org.apache.directory.api.ldap.model.schema.DitStructureRule) Value(org.apache.directory.api.ldap.model.entry.Value) ParseException(java.text.ParseException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 44 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DefaultSchemaLoader method loadObjectClasses.

private void loadObjectClasses(Attribute objectClasses) throws LdapException {
    if (objectClasses == null) {
        return;
    }
    for (Value value : objectClasses) {
        String desc = value.getValue();
        try {
            ObjectClass objectClass = OC_DESCR_SCHEMA_PARSER.parseObjectClassDescription(desc);
            updateSchemas(objectClass);
        } catch (ParseException pe) {
            throw new LdapException(pe);
        }
    }
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Value(org.apache.directory.api.ldap.model.entry.Value) ParseException(java.text.ParseException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 45 with LdapException

use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.

the class DefaultSchemaLoader method loadNameForms.

private void loadNameForms(Attribute nameForms) throws LdapException {
    if (nameForms == null) {
        return;
    }
    for (Value value : nameForms) {
        String desc = value.getValue();
        try {
            NameForm nameForm = NF_DESCR_SCHEMA_PARSER.parseNameFormDescription(desc);
            updateSchemas(nameForm);
        } catch (ParseException pe) {
            throw new LdapException(pe);
        }
    }
}
Also used : NameForm(org.apache.directory.api.ldap.model.schema.NameForm) Value(org.apache.directory.api.ldap.model.entry.Value) ParseException(java.text.ParseException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Aggregations

LdapException (org.apache.directory.api.ldap.model.exception.LdapException)329 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)159 ArrayList (java.util.ArrayList)93 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)91 FinderException (org.apache.directory.fortress.core.FinderException)73 Entry (org.apache.directory.api.ldap.model.entry.Entry)63 Modification (org.apache.directory.api.ldap.model.entry.Modification)63 IOException (java.io.IOException)54 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)51 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)50 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)49 UpdateException (org.apache.directory.fortress.core.UpdateException)41 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)35 Dn (org.apache.directory.api.ldap.model.name.Dn)34 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)25 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)25 DecoderException (org.apache.directory.api.asn1.DecoderException)22 LdapNoPermissionException (org.apache.directory.api.ldap.model.exception.LdapNoPermissionException)22 LdapOtherException (org.apache.directory.api.ldap.model.exception.LdapOtherException)22 ConnectException (java.net.ConnectException)21