Package org.nasutekds.server.types

Examples of org.nasutekds.server.types.AttributeType


    DN dn = resourceEntry.getDN();
    List<Modification> modifications = container.getModifications();
    for (Modification m : modifications)
    {
      Attribute modAttr = m.getAttribute();
      AttributeType modAttrType = modAttr.getAttributeType();

      if (modAttrType.equals(aciType))
      {
        /*
         * Check that the operation has modify privileges if it contains
         * an "aci" attribute type.
         */
        if (!operation.getClientConnection().hasPrivilege(
            Privilege.MODIFY_ACL, operation))
        {
          Message message =
              INFO_ACI_MODIFY_FAILED_PRIVILEGE.get(String
                  .valueOf(container.getResourceDN()), String
                  .valueOf(container.getClientDN()));
          logError(message);
          return false;
        }
      }
      // This access check handles the case where all attributes of this
      // type are being replaced or deleted. If only a subset is being
      // deleted than this access check is skipped.
      ModificationType modType = m.getModificationType();
      if (((modType == ModificationType.DELETE) && modAttr.isEmpty())
          || ((modType == ModificationType.REPLACE)
              || (modType == ModificationType.INCREMENT)))
      {
        /*
         * Check if we have rights to delete all values of an attribute
         * type in the resource entry.
         */
        if (resourceEntry.hasAttribute(modAttrType))
        {
          container.setCurrentAttributeType(modAttrType);
          List<Attribute> attrList =
              resourceEntry.getAttribute(modAttrType, modAttr
                  .getOptions());
          if (attrList != null)
          {
            for (Attribute a : attrList)
            {
              for (AttributeValue v : a)
              {
                container.setCurrentAttributeValue(v);
                container.setRights(ACI_WRITE_DELETE);
                if (!skipAccessCheck && !accessAllowed(container))
                {
                  return false;
                }
              }
            }
          }
        }
      }

      if (!modAttr.isEmpty())
      {
        for (AttributeValue v : modAttr)
        {
          container.setCurrentAttributeType(modAttrType);
          switch (m.getModificationType())
          {
          case ADD:
          case REPLACE:
            container.setCurrentAttributeValue(v);
            container.setRights(ACI_WRITE_ADD);
            if (!skipAccessCheck && !accessAllowed(container))
            {
              return false;
            }
            break;
          case DELETE:
            container.setCurrentAttributeValue(v);
            container.setRights(ACI_WRITE_DELETE);
            if (!skipAccessCheck && !accessAllowed(container))
            {
              return false;
            }
            break;
          case INCREMENT:
            Entry modifiedEntry = operation.getModifiedEntry();
            List<Attribute> modifiedAttrs =
                modifiedEntry.getAttribute(modAttrType, modAttr
                    .getOptions());
            if (modifiedAttrs != null)
            {
              for (Attribute attr : modifiedAttrs)
              {
                for (AttributeValue val : attr)
                {
                  container.setCurrentAttributeValue(val);
                  container.setRights(ACI_WRITE_ADD);
                  if (!skipAccessCheck && !accessAllowed(container))
                  {
                    return false;
                  }
                }
              }
            }
            break;
          }
          /*
           * Check if the modification type has an "aci" attribute type.
           * If so, check the syntax of that attribute value. Fail the
           * the operation if the syntax check fails.
           */
          if (modAttrType.equals(aciType)
              || modAttrType.equals(globalAciType))
          {
            try
            {
              // A global ACI needs a NULL DN, not the DN of the
              // modification.
              if (modAttrType.equals(globalAciType))
              {
                dn = DN.nullDN();
              }
              Aci.decode(v.getValue(), dn);
            }
View Full Code Here


    boolean ret = false;
    int numAVAs = rdn.getNumValues();
    container.setRights(right);
    for (int i = 0; i < numAVAs; i++)
    {
      AttributeType type = rdn.getAttributeType(i);
      AttributeValue value = rdn.getAttributeValue(i);
      container.setCurrentAttributeType(type);
      container.setCurrentAttributeValue(value);
      if (!(ret = accessAllowed(container)))
      {
View Full Code Here

     * When a search is not all attributes returned, the "objectclass"
     * attribute type is missing from the entry.
     */
    if (attr != null)
    {
      AttributeType ocType = attr.getAttributeType();
      typeList.add(ocType);
    }
    typeList.addAll(attrMap.keySet());
    typeList.addAll(opAttrMap.keySet());
    return typeList;
View Full Code Here

      ret = testFilter(container, f);
      break;
    }
    default:
    {
      AttributeType attrType = filter.getAttributeType();
      container.setCurrentAttributeType(attrType);
      ret = accessAllowed(container);
    }
    }
    return ret;
View Full Code Here

    ensureNotNull(groupEntry);


    // Get the target group DN attribute from the entry, if there is one.
    DN targetDN = null;
    AttributeType targetType =
         DirectoryServer.getAttributeType(ATTR_TARGET_GROUP_DN, true);
    List<Attribute> attrList = groupEntry.getAttribute(targetType);
    if (attrList != null)
    {
      for (Attribute a : attrList)
View Full Code Here


    // Get the memberURL attribute from the entry, if there is one, and parse
    // out the LDAP URLs that it contains.
    LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<LDAPURL>();
    AttributeType memberURLType =
         DirectoryConfig.getAttributeType(ATTR_MEMBER_URL_LC, true);
    List<Attribute> attrList = groupEntry.getAttribute(memberURLType);
    if (attrList != null)
    {
      for (Attribute a : attrList)
View Full Code Here

                                          String.valueOf(invalidReason)));
      }

      for (int i=0; i < newRDNValues; i++)
      {
        AttributeType at = newRDN.getAttributeType(i);
        if (at.isObsolete())
        {
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                       ERR_MODDN_NEWRDN_ATTR_IS_OBSOLETE.get(
                                            String.valueOf(entryDN),
                                            at.getNameOrOID()));
        }
      }
    }
  }
View Full Code Here

      {
        Iterator<AttributeType> iterator =
             entry.getUserAttributes().keySet().iterator();
        while (iterator.hasNext())
        {
          AttributeType attrType = iterator.next();
          if (! preReadRequest.allowsAttribute(attrType))
          {
            iterator.remove();
          }
        }
      }

      if (! preReadRequest.returnAllOperationalAttributes())
      {
        Iterator<AttributeType> iterator =
             entry.getOperationalAttributes().keySet().iterator();
        while (iterator.hasNext())
        {
          AttributeType attrType = iterator.next();
          if (! preReadRequest.allowsAttribute(attrType))
          {
            iterator.remove();
          }
        }
      }

      // Check access controls on the entry and strip out
      // any not allowed attributes.
      SearchResultEntry searchEntry =
        AccessControlConfigManager.getInstance().
        getAccessControlHandler().filterEntry(this, entry);
      LDAPPreReadResponseControl responseControl =
           new LDAPPreReadResponseControl(preReadRequest.isCritical(),
                                          searchEntry);

      addResponseControl(responseControl);
    }

    if (postReadRequest != null)
    {
      Entry entry = newEntry.duplicate(true);

      if (! postReadRequest.allowsAttribute(
                 DirectoryServer.getObjectClassAttributeType()))
      {
        entry.removeAttribute(
             DirectoryServer.getObjectClassAttributeType());
      }

      if (! postReadRequest.returnAllUserAttributes())
      {
        Iterator<AttributeType> iterator =
             entry.getUserAttributes().keySet().iterator();
        while (iterator.hasNext())
        {
          AttributeType attrType = iterator.next();
          if (! postReadRequest.allowsAttribute(attrType))
          {
            iterator.remove();
          }
        }
      }

      if (! postReadRequest.returnAllOperationalAttributes())
      {
        Iterator<AttributeType> iterator =
             entry.getOperationalAttributes().keySet().iterator();
        while (iterator.hasNext())
        {
          AttributeType attrType = iterator.next();
          if (! postReadRequest.allowsAttribute(attrType))
          {
            iterator.remove();
          }
        }
View Full Code Here

      new LinkedHashMap<AttributeType,List<Attribute>>();
    HashMap<AttributeType,List<Attribute>> operationalAttrs =
      new LinkedHashMap<AttributeType,List<Attribute>>();

    // subSchemaSubentry
    AttributeType aType =
      DirectoryServer.getAttributeType(ATTR_SUBSCHEMA_SUBENTRY_LC);
    if (aType == null)
      aType = DirectoryServer.getDefaultAttributeType(ATTR_SUBSCHEMA_SUBENTRY);
    Attribute a = Attributes.create(ATTR_SUBSCHEMA_SUBENTRY,
        ConfigConstants.DN_DEFAULT_SCHEMA_ROOT);
    List<Attribute> attrList = Collections.singletonList(a);
    if (aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      userAttrs.put(aType, attrList);

    // TODO:numSubordinates

    // hasSubordinates
    if (hasSubordinates)
    {
      aType = DirectoryServer.getAttributeType("hassubordinates");
      if (aType == null)
        aType = DirectoryServer.getDefaultAttributeType("hasSubordinates");
      a = Attributes.create("hasSubordinates", "true");
      attrList = Collections.singletonList(a);
      if (aType.isOperational())
        operationalAttrs.put(aType, attrList);
      else
        userAttrs.put(aType, attrList);
    }

    // entryDN
    aType = DirectoryServer.getAttributeType("entrydn");
    if (aType == null)
      aType = DirectoryServer.getDefaultAttributeType("entryDN");
    a = Attributes.create("entryDN", rootBaseDN.toNormalizedString());
    attrList = Collections.singletonList(a);
    if (aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      userAttrs.put(aType, attrList);

    Entry e = new Entry(this.rootBaseDN, oclasses, userAttrs, operationalAttrs);
View Full Code Here

      int draftChangenumber,
      String changetype,
      String delInitiatorsName)
  throws DirectoryException
  {
    AttributeType aType;

    String dnString = "";
    String pattern;
    if (draftChangenumber == 0)
    {
      // Draft uncompat mode
      dnString = "replicationcsn="+ changeNumber +"," + serviceID
      + "," + ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT;
    }
    else
    {
      // Draft compat mode
      dnString = "changenumber="+ draftChangenumber + "," +
      ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT;
    }

    // Objectclass
    HashMap<ObjectClass,String> oClasses =
      new LinkedHashMap<ObjectClass,String>(3);
    oClasses.putAll(eclObjectClasses);

    ObjectClass extensibleObjectOC =
      DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC, true);
    oClasses.put(extensibleObjectOC, OC_EXTENSIBLE_OBJECT);

    HashMap<AttributeType,List<Attribute>> uAttrs =
      new LinkedHashMap<AttributeType,List<Attribute>>();

    HashMap<AttributeType,List<Attribute>> operationalAttrs =
      new LinkedHashMap<AttributeType,List<Attribute>>();

    // Operational standard attributes

    // subSchemaSubentry
    aType = DirectoryServer.getAttributeType(ATTR_SUBSCHEMA_SUBENTRY_LC);
    if (aType == null)
    aType = DirectoryServer.getDefaultAttributeType(ATTR_SUBSCHEMA_SUBENTRY_LC);
    Attribute a = Attributes.create(ATTR_SUBSCHEMA_SUBENTRY_LC,
        ConfigConstants.DN_DEFAULT_SCHEMA_ROOT);
    List<Attribute> attrList = Collections.singletonList(a);
    if (aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    // numSubordinates
    aType = DirectoryServer.getAttributeType("numsubordinates");
    if (aType == null)
      aType = DirectoryServer.getDefaultAttributeType("numSubordinates");
    a = Attributes.create("numSubordinates", "0");
    attrList = Collections.singletonList(a);
    if (aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    // hasSubordinates
    aType = DirectoryServer.getAttributeType("hassubordinates");
    if (aType == null)
      aType = DirectoryServer.getDefaultAttributeType("hasSubordinates");
    a = Attributes.create("hasSubordinates", "false");
    attrList = Collections.singletonList(a);
    if (aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    // entryDN
    aType = DirectoryServer.getAttributeType("entrydn");
    if (aType == null)
      aType = DirectoryServer.getDefaultAttributeType("entryDN");
    a = Attributes.create("entryDN", dnString);
    attrList = Collections.singletonList(a);
    if (aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    // REQUIRED attributes

    // ECL Changelog draft change number
    if((aType = DirectoryServer.getAttributeType("changenumber")) == null)
      aType = DirectoryServer.getDefaultAttributeType("changenumber");
    a = Attributes.create("changenumber", String.valueOf(draftChangenumber));
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    //
    if((aType = DirectoryServer.getAttributeType("changetime")) == null)
      aType = DirectoryServer.getDefaultAttributeType("changetime");
    SimpleDateFormat dateFormat;
    dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME);
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // ??
    a = Attributes.create(aType,
        dateFormat.format(new Date(changeNumber.getTime())));
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    /* Change time in a friendly format
    Date date = new Date(changeNumber.getTime());
    a = Attributes.create("clearChangeTime", date.toString());
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    uAttrs.put(a.getAttributeType(), attrList);
     */

    //
    if((aType = DirectoryServer.getAttributeType("changetype")) == null)
      aType = DirectoryServer.getDefaultAttributeType("changetype");
    a = Attributes.create(aType, changetype);
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    //
    if((aType = DirectoryServer.getAttributeType("targetdn")) == null)
      aType = DirectoryServer.getDefaultAttributeType("targetdn");
    a = Attributes.create(aType, targetDN.toNormalizedString());
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    // NON REQUESTED attributes

    if((aType = DirectoryServer.getAttributeType("replicationcsn")) == null)
      aType = DirectoryServer.getDefaultAttributeType("replicationcsn");
    a = Attributes.create(aType, changeNumber.toString());
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    //
    if((aType = DirectoryServer.getAttributeType("replicaidentifier")) == null)
      aType = DirectoryServer.getDefaultAttributeType("replicaidentifier");
    a = Attributes.create(aType, Integer.toString(changeNumber.getServerId()));
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    if (clearLDIFchanges != null)
    {
      if (changetype.equals("add"))
      {
        if((aType = DirectoryServer.getAttributeType("changes")) == null)
          aType = DirectoryServer.getDefaultAttributeType("changes");

        a = Attributes.create(aType, clearLDIFchanges + "\n");
        // force base64
        attrList = new ArrayList<Attribute>(1);
        attrList.add(a);
        if(aType.isOperational())
          operationalAttrs.put(aType, attrList);
        else
          uAttrs.put(aType, attrList);

        pattern = "creatorsName: ";
        try
        {
          int att_cr = clearLDIFchanges.indexOf(pattern);
          if (att_cr>0)
          {
            int start_val_cr = clearLDIFchanges.indexOf(':', att_cr);
            int end_val_cr = clearLDIFchanges.indexOf(EOL, att_cr);
            String creatorsName =
              clearLDIFchanges.substring(start_val_cr+2, end_val_cr);

            if((aType =
              DirectoryServer.getAttributeType("changeInitiatorsName")) == null)
              aType =
                DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
            a = Attributes.create(aType, creatorsName);
            attrList = new ArrayList<Attribute>(1);
            attrList.add(a);
            if(aType.isOperational())
              operationalAttrs.put(aType, attrList);
            else
              uAttrs.put(aType, attrList);
          }
        }
        catch(Exception e)
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
          logError(Message.raw(Category.SYNC, Severity.MILD_ERROR,
              "Error in External Change Log when looking for pattern \""
              + pattern + "\" in string \""+
              clearLDIFchanges + "\" for change " + dnString));
        }
      }
      else if (changetype.equals("modify")||changetype.equals("modrdn"))
      {
        if (changetype.equals("modify"))
        {
          if((aType = DirectoryServer.getAttributeType("changes")) == null)
            aType = DirectoryServer.getDefaultAttributeType("changes");

          a = Attributes.create(aType, clearLDIFchanges + "\n");
          // force base64
          attrList = new ArrayList<Attribute>(1);
          attrList.add(a);
          if(aType.isOperational())
            operationalAttrs.put(aType, attrList);
          else
            uAttrs.put(aType, attrList);
        }

        pattern = "modifiersName: ";
        try
        {
          int att_cr = clearLDIFchanges.indexOf(pattern);
          if (att_cr>0)
          {
            int start_val_cr = att_cr + pattern.length();
            int end_val_cr = clearLDIFchanges.indexOf(EOL, att_cr);
            String modifiersName =
              clearLDIFchanges.substring(start_val_cr, end_val_cr);

            if((aType =
              DirectoryServer.getAttributeType("changeInitiatorsName")) == null)
              aType =
                DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
            a = Attributes.create(aType, modifiersName);
            attrList = new ArrayList<Attribute>(1);
            attrList.add(a);
            if(aType.isOperational())
              operationalAttrs.put(aType, attrList);
            else
              uAttrs.put(aType, attrList);
          }
        }
        catch(Exception e)
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
          logError(Message.raw(Category.SYNC, Severity.MILD_ERROR,
              "Error in External Change Log when looking for pattern \""
              + pattern + "\" in string \""+
              clearLDIFchanges + "\" for change " + dnString));
        }
      }
    }

    if (changetype.equals("delete") && (delInitiatorsName!=null))
    {
      if((aType = DirectoryServer.getAttributeType("changeInitiatorsName"))
          == null)
        aType = DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
      a = Attributes.create(aType, delInitiatorsName);
      attrList = new ArrayList<Attribute>(1);
      attrList.add(a);
      if(aType.isOperational())
        operationalAttrs.put(aType, attrList);
      else
        uAttrs.put(aType, attrList);
    }

    if (targetUUID != null)
    {
      if((aType = DirectoryServer.getAttributeType("targetentryuuid")) == null)
        aType = DirectoryServer.getDefaultAttributeType("targetentryuuid");
      a = Attributes.create(aType, targetUUID);
      attrList = new ArrayList<Attribute>(1);
      attrList.add(a);
      if(aType.isOperational())
        operationalAttrs.put(aType, attrList);
      else
        uAttrs.put(aType, attrList);

      if (draftChangenumber>0)
      {
        // compat mode
        if((aType = DirectoryServer.getAttributeType("targetuniqueid")) == null)
          aType = DirectoryServer.getDefaultAttributeType("targetuniqueid");
        String dseeValue = null;
        try
        {
          dseeValue = ECLSearchOperation.openDsToSunDseeNsUniqueId(targetUUID);
        }
        catch(Exception e)
        {
          Message errMessage =
            NOTE_ERR_ENTRY_UID_DSEE_MAPPING.get(
                targetDN.toNormalizedString(),
                targetUUID,
                e.getLocalizedMessage());
          logError(errMessage);
          if (debugEnabled())
            TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }

        // If the mapping fails, we don't want to stop the operation
        // or not return this entry.
        if (dseeValue != null)
        {
          a = Attributes.create(aType, dseeValue);
          attrList = new ArrayList<Attribute>(1);
          attrList.add(a);
          if(aType.isOperational())
            operationalAttrs.put(aType, attrList);
          else
            uAttrs.put(aType, attrList);
        }
      }
    }

    if((aType = DirectoryServer.getAttributeType("changelogcookie")) == null)
      aType = DirectoryServer.getDefaultAttributeType("changelogcookie");
    a = Attributes.create(aType, cookie);
    attrList = new ArrayList<Attribute>(1);
    attrList.add(a);
    if(aType.isOperational())
      operationalAttrs.put(aType, attrList);
    else
      uAttrs.put(aType, attrList);

    if (histEntryAttributes != null)
    {
      for (RawAttribute ra : histEntryAttributes)
      {
        try
        {
          String attrName = ra.getAttributeType().toLowerCase();
          String eclName = "target" + attrName;
          AttributeBuilder builder = new AttributeBuilder(
              DirectoryServer.getDefaultAttributeType(eclName));
          AttributeType at = builder.getAttributeType();
          builder.setOptions(ra.toAttribute().getOptions());
          builder.addAll(ra.toAttribute());
          attrList = new ArrayList<Attribute>(1);
          attrList.add(builder.toAttribute());
          uAttrs.put(at, attrList);
View Full Code Here

TOP

Related Classes of org.nasutekds.server.types.AttributeType

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.