Package javax.naming.directory

Examples of javax.naming.directory.BasicAttributes


    List<ColumnReference> insertElementList = ((Insert)command).getColumns();
    List<Expression> insertValueList = ((ExpressionValueSource)((Insert)command).getValueSource()).getValues();
    // create a new attribute list with case ignored in attribute
    // names
    Attributes insertAttrs = new BasicAttributes(true);
    Attribute insertAttr; // what we will use to populate the attribute list
    ColumnReference insertElement;
    String nameInsertElement;
    Object insertValue;
    String distinguishedName = null;
    // The IInsert interface uses separate List objects for
    // the element names and values to be inserted, limiting
    // the potential for code reuse in reading them (since all
    // other interfaces use ICriteria-based mechanisms for such
    // input).
    for (int i=0; i < insertElementList.size(); i++) {
      insertElement = insertElementList.get(i);
      // call utility class to get NameInSource/Name of element
      nameInsertElement = getNameFromElement(insertElement);
      // special handling for DN attribute - use it to set
      // distinguishedName value.
      if (nameInsertElement.toUpperCase().equals("DN")) {  //$NON-NLS-1$
        insertValue = ((Literal)insertValueList.get(i)).getValue();
        if (insertValue == null) {
                final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNNullError"); //$NON-NLS-1$
          throw new TranslatorException(msg);
        }
        if (!(insertValue instanceof java.lang.String)) {
                final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNTypeError"); //$NON-NLS-1$
          throw new TranslatorException(msg);
        }
        distinguishedName = (String)insertValue;
      }
      // for other attributes specified in the insert command,
      // create a new
      else {
        insertAttr = new BasicAttribute(nameInsertElement);
        insertValue = ((Literal)insertValueList.get(i)).getValue();
        insertAttr.add(insertValue);
        insertAttrs.put(insertAttr);
      }
    }
    // if the DN is not specified, we don't know enough to attempt
    // the LDAP add operation, so throw an exception
    if (distinguishedName == null) {
View Full Code Here


     
      Attribute currMembers = fetchMembers(ctx);
      String failer = containsName(ctx, currMembers, dn);
      if (failer == null) {
        currMembers.add(dn);
        Attributes attrs = new BasicAttributes();
        attrs.put(currMembers);
       
        ctx.modifyAttributes(this.dn, DirContext.REPLACE_ATTRIBUTE, attrs);
        return true;
      }
 
View Full Code Here

 
      Attribute currMembers = fetchMembers(ctx);
      String result = containsName(ctx, currMembers, dn);
      if (result != null) {
        currMembers.remove(result);
        Attributes attrs = new BasicAttributes();
        attrs.put(currMembers);
     
        ctx.modifyAttributes(this.dn, DirContext.REPLACE_ATTRIBUTE, attrs);
       
        return true;
      }
View Full Code Here

          }
        }
        else if (requestNode.getNodeName().equals(SEARCH_ATTRIBUTES))
        {
          children = requestNode.getChildNodes();
          attrs = new BasicAttributes();
          for (int j = 0; j < children.getLength(); j++)
          {
            child = children.item(j);
            if (child.getNodeType() == Element.ELEMENT_NODE)
            {
View Full Code Here

  /// @synopsis Attributes(boolean ignoreCase, attribute, ...)
  /// @param attributes Map (id=>value) or instance of Attribute
  public static final Any newInstance(Context context, Any[] values)
  {
    boolean ignoreCase = false;
    BasicAttributes attrs = new BasicAttributes(ignoreCase);
    int n = values.length;
    int i =0;
    if (n > 0) {
      if (values[0].isBoolean()) {
        ignoreCase = values[0].toBoolean();
        i++;
      }
    }
    for(; i<n; i++) {
      Any value = values[i];
      if (value.isMap()) {
        AnyMap map = value.toMap();
        attrs.put(map.getLeft().toString(), map.getRight().toObject());
      } else if (value instanceof AnyAttribute) {
        attrs.put((Attribute)value.toObject());
      }
    }
    return new AnyAttributes(attrs);
  }
View Full Code Here

        indexedAttrs.add("objectClass");
        indexedAttrs.add("o");
        pcfg.setIndexedAttributes(indexedAttrs);

        // Create a first entry associated to the partition
        Attributes attrs = new BasicAttributes(true);

        // First, the objectClass attribute
        Attribute attr = new BasicAttribute("objectClass");
        attr.add("top");
        attr.add("organization");
        attrs.put(attr);

        // The the 'Organization' attribute
        attr = new BasicAttribute("o");
        attr.add("sevenseas");
        attrs.put(attr);

        // Associate this entry to the partition
        pcfg.setContextEntry(attrs);

        // As we can create more than one partition, we must store
View Full Code Here

            // Connect to LDAP.
            DirContext ctx = LDAPUserManager.bindAsAdmin();

            // Make the attributes.
            Attributes attrs = new BasicAttributes();

            attrs.put(new BasicAttribute("turbineRoleName", roleName));
            attrs.put(new BasicAttribute("objectClass", "turbineUserGroup"));
            attrs.put(new BasicAttribute("turbineUserUniqueId", userName));
            try
            {
                // Add the turbineUserGroup.
                ctx.bind(dn, null, attrs);
            }
            catch (NameAlreadyBoundException ex)
            {
                // Since turbineUserGroup had already been created
                // then just add the role name attribute.
                attrs = new BasicAttributes();
                attrs.put(new BasicAttribute("turbineRoleName", roleName));
                ctx.modifyAttributes(dn, DirContext.ADD_ATTRIBUTE, attrs);
            }

        }
        catch (NamingException ex)
View Full Code Here

                    + LDAPSecurityConstants.getNameAttribute()
                    + "=" + userName + ","
                    + LDAPSecurityConstants.getBaseSearch();

            // Make the attributes.
            Attributes attrs = new BasicAttributes();

            attrs.put(new BasicAttribute("turbineRoleName", roleName));

            // Connect to LDAP.
            DirContext ctx = LDAPUserManager.bindAsAdmin();

            // Remove the role.
View Full Code Here

            // Make the distinguished name.
            String dn = "turbineRoleName=" + roleName + ","
                    + LDAPSecurityConstants.getBaseSearch();

            // Make the attributes.
            Attributes attrs = new BasicAttributes();

            attrs.put(new BasicAttribute("turbinePermissionName", permName));

            // Connect to LDAP.
            DirContext ctx = LDAPUserManager.bindAsAdmin();

            // Add the permission.
View Full Code Here

            // Make the distinguished name.
            String dn = "turbineRoleName=" + roleName + ","
                    + LDAPSecurityConstants.getBaseSearch();

            // Make the attributes.
            Attributes attrs = new BasicAttributes();

            attrs.put(new BasicAttribute("turbinePermissionName", permName));

            // Connect to LDAP.
            DirContext ctx = LDAPUserManager.bindAsAdmin();

            // Remove the permission.
View Full Code Here

TOP

Related Classes of javax.naming.directory.BasicAttributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.