Search in sources :

Example 81 with Attributes

use of javax.naming.directory.Attributes in project directory-ldap-api by apache.

the class LdifUtilsTest method testConvertAttributesfromLdif.

/**
 * Test a conversion of an attributes from a LDIF file
 * @throws org.apache.directory.api.ldap.model.ldif.LdapLdifException
 */
@Test
public void testConvertAttributesfromLdif() throws LdapException, LdapLdifException {
    Attributes attributes = new BasicAttributes(true);
    Attribute oc = new BasicAttribute("objectclass");
    oc.add("top");
    oc.add("person");
    oc.add("inetorgPerson");
    attributes.put(oc);
    attributes.put("cn", "Saarbrucken");
    attributes.put("sn", "test");
    String ldif = LdifUtils.convertToLdif(attributes, (Dn) null, 15);
    Attributes result = LdifUtils.getJndiAttributesFromLdif(ldif);
    assertEquals(attributes, result);
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) Test(org.junit.Test)

Example 82 with Attributes

use of javax.naming.directory.Attributes in project directory-ldap-api by apache.

the class TriggerUtils method loadEntryTriggerSpecification.

/**
 * Load the trigger specification entry
 *
 * @param ctx The context
 * @param triggerSpec The trigger specification
 * @throws NamingException If the operation failed
 */
public static void loadEntryTriggerSpecification(LdapContext ctx, String triggerSpec) throws NamingException {
    Attributes changes = new BasicAttributes(SchemaConstants.ENTRY_TRIGGER_SPECIFICATION_AT, triggerSpec, true);
    ctx.modifyAttributes("", DirContext.ADD_ATTRIBUTE, changes);
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) BasicAttributes(javax.naming.directory.BasicAttributes)

Example 83 with Attributes

use of javax.naming.directory.Attributes in project directory-ldap-api by apache.

the class TriggerUtils method loadPrescriptiveTriggerSpecification.

/**
 * Load an prescriptive trigger specification
 *
 * @param apCtx The administrative point context
 * @param subentryCN The subentry CN
 * @param triggerSpec The trigger specification
 * @throws NamingException If the operation failed
 */
public static void loadPrescriptiveTriggerSpecification(LdapContext apCtx, String subentryCN, String triggerSpec) throws NamingException {
    Attributes changes = new BasicAttributes(SchemaConstants.PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT, triggerSpec, true);
    apCtx.modifyAttributes("cn=" + subentryCN, DirContext.ADD_ATTRIBUTE, changes);
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) BasicAttributes(javax.naming.directory.BasicAttributes)

Example 84 with Attributes

use of javax.naming.directory.Attributes in project directory-ldap-api by apache.

the class TriggerUtils method defineTriggerExecutionSpecificPoint.

/**
 * Defines the Administration point and administrative role for the TriggerExecution specific point
 * @param apCtx The administrative point context
 * @throws NamingException If the operation failed
 */
public static void defineTriggerExecutionSpecificPoint(LdapContext apCtx) throws NamingException {
    Attributes ap = apCtx.getAttributes("", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT });
    Attribute administrativeRole = ap.get(SchemaConstants.ADMINISTRATIVE_ROLE_AT);
    if (administrativeRole == null || !AttributeUtils.containsValueCaseIgnore(administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA)) {
        Attributes changes = new BasicAttributes(SchemaConstants.ADMINISTRATIVE_ROLE_AT, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true);
        apCtx.modifyAttributes("", DirContext.ADD_ATTRIBUTE, changes);
    }
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) Attributes(javax.naming.directory.Attributes) BasicAttributes(javax.naming.directory.BasicAttributes)

Example 85 with Attributes

use of javax.naming.directory.Attributes in project directory-ldap-api by apache.

the class JavaStoredProcUtils method loadStoredProcedureClass.

/**
 * Loads a Java class's stream data as a subcontext of an LdapContext given.
 *
 * @param ctx
 *           The parent context of the Java class entry to be loaded.
 * @param clazz
 *           Class to be loaded.
 * @throws NamingException
 *           If an error occurs during creating the subcontext.
 */
public static void loadStoredProcedureClass(LdapContext ctx, Class<?> clazz) throws NamingException {
    byte[] buf = getClassFileAsStream(clazz);
    String fullClassName = clazz.getName();
    Attributes attributes = new BasicAttributes(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true);
    attributes.get(SchemaConstants.OBJECT_CLASS_AT).add("storedProcUnit");
    attributes.get(SchemaConstants.OBJECT_CLASS_AT).add("javaStoredProcUnit");
    attributes.put("storedProcLangId", "Java");
    attributes.put("storedProcUnitName", fullClassName);
    attributes.put("javaByteCode", buf);
    ctx.createSubcontext("storedProcUnitName=" + fullClassName, attributes);
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes)

Aggregations

Attributes (javax.naming.directory.Attributes)252 Attribute (javax.naming.directory.Attribute)135 SearchResult (javax.naming.directory.SearchResult)87 NamingException (javax.naming.NamingException)84 BasicAttributes (javax.naming.directory.BasicAttributes)72 ArrayList (java.util.ArrayList)61 BasicAttribute (javax.naming.directory.BasicAttribute)56 SearchControls (javax.naming.directory.SearchControls)55 DirContext (javax.naming.directory.DirContext)49 NamingEnumeration (javax.naming.NamingEnumeration)44 Test (org.junit.Test)34 InitialDirContext (javax.naming.directory.InitialDirContext)32 LdapContext (javax.naming.ldap.LdapContext)29 HashMap (java.util.HashMap)25 InitialLdapContext (javax.naming.ldap.InitialLdapContext)24 Hashtable (java.util.Hashtable)20 HashSet (java.util.HashSet)18 Map (java.util.Map)17 IOException (java.io.IOException)16 Identity (org.olat.core.id.Identity)16