Package org.nasutekds.server.types

Examples of org.nasutekds.server.types.AttributeBuilder$RealAttribute


    }

    // Object classes and user atributes.
    Iterator<NdbResultSet> ocRsIterator = ocRsList.iterator();
    NdbResultSet ocRs = ocRsIterator.next();
    AttributeBuilder attrBuilder = new AttributeBuilder();
    for (ObjectClass oc : objectClasses.keySet()) {
      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }
      while (ocRs.next()) {
        int mid = ocRs.getInt(BackendImpl.MID);
        for (AttributeType reqAttr : oc.getRequiredAttributes()) {
          String attrName = reqAttr.getNameOrOID();
          byte[] attrValBytes = null;
          NdbBlob blob = null;
          if (BackendImpl.blobAttributes.contains(attrName)) {
            Map<String, NdbBlob> attr2Blob =
              blobMap.get(objectClasses.get(oc));
            blob = attr2Blob.get(attrName);
          } else {
            attrValBytes = ocRs.getStringBytes(attrName);
            if (ocRs.wasNull()) {
              continue;
            }
          }
          AttributeType attributeType =
            DirectoryServer.getAttributeType(
            BackendImpl.attrName2LC.get(attrName), true);
          List<Attribute> attrList = userAttributes.get(attributeType);
          if (attrList == null) {
            attrList = new ArrayList<Attribute>();
          }
          Attribute attr = null;
          LinkedHashSet<String> options = null;
          Map<Integer, LinkedHashSet<String>> mid2tagMap =
            attr2tagMap.get(attrName);
          if (mid2tagMap != null) {
            options = mid2tagMap.get(mid);
          }
          if ((options == null) && !attrList.isEmpty()) {
            attr = attrList.get(attrList.size() - 1);
          }
          if (attr == null) {
            attrBuilder.setAttributeType(attributeType, attrName);
          } else {
            attrBuilder = new AttributeBuilder(attr);
          }
          if (blob != null) {
            if (blob.getNull()) {
              continue;
            }
            int len = blob.getLength().intValue();
            byte[] buf = new byte[len];
            blob.readData(buf, len);
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(buf)));
          } else {
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(attrValBytes)));
          }

          // Create or update an attribute.
          if (options != null) {
            attrBuilder.setOptions(options);
          }
          attr = attrBuilder.toAttribute();
          if (attrList.isEmpty()) {
            attrList.add(attr);
          } else {
            attrList.set(attrList.size() - 1, attr);
          }

          userAttributes.put(attributeType, attrList);
        }
        for (AttributeType optAttr : oc.getOptionalAttributes()) {
          String attrName = optAttr.getNameOrOID();
          byte[] attrValBytes = null;
          NdbBlob blob = null;
          if (BackendImpl.blobAttributes.contains(attrName)) {
            Map<String, NdbBlob> attr2Blob =
              blobMap.get(objectClasses.get(oc));
            blob = attr2Blob.get(attrName);
          } else {
            attrValBytes = ocRs.getStringBytes(attrName);
            if (ocRs.wasNull()) {
              continue;
            }
          }
          AttributeType attributeType =
            DirectoryServer.getAttributeType(
            BackendImpl.attrName2LC.get(attrName), true);
          List<Attribute> attrList = userAttributes.get(attributeType);
          if (attrList == null) {
            attrList = new ArrayList<Attribute>();
          }
          Attribute attr = null;
          LinkedHashSet<String> options = null;
          Map<Integer, LinkedHashSet<String>> mid2tagMap =
            attr2tagMap.get(attrName);
          if (mid2tagMap != null) {
            options = mid2tagMap.get(mid);
          }
          if ((options == null) && !attrList.isEmpty()) {
            attr = attrList.get(attrList.size() - 1);
          }
          if (attr == null) {
            attrBuilder.setAttributeType(attributeType, attrName);
          } else {
            attrBuilder = new AttributeBuilder(attr);
          }
          if (blob != null) {
            if (blob.getNull()) {
              continue;
            }
            int len = blob.getLength().intValue();
            byte[] buf = new byte[len];
            blob.readData(buf, len);
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(buf)));
          } else {
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(attrValBytes)));
          }

          // Create or update an attribute.
          if (options != null) {
            attrBuilder.setOptions(options);
          }
          attr = attrBuilder.toAttribute();
          if (attrList.isEmpty()) {
            attrList.add(attr);
          } else {
            attrList.set(attrList.size() - 1, attr);
          }

          userAttributes.put(attributeType, attrList);
        }
      }
      if (ocRsIterator.hasNext()) {
        ocRs = ocRsIterator.next();
      }
    }

    // Operational attributes.
    if (ocRs.next()) {
      for (String attrName : BackendImpl.operationalAttributes) {
        byte[] attrValBytes = ocRs.getStringBytes(attrName);
        if (ocRs.wasNull()) {
          continue;
        }
        AttributeType attributeType =
          DirectoryServer.getAttributeType(
          BackendImpl.attrName2LC.get(attrName), true);
        attrBuilder.setAttributeType(attributeType, attrName);
        attrBuilder.add(AttributeValues.create(attributeType,
          ByteString.wrap(attrValBytes)));
        Attribute attr = attrBuilder.toAttribute();
        List<Attribute> attrList = opAttributes.get(attributeType);
        if (attrList == null) {
          attrList = new ArrayList<Attribute>();
          attrList.add(attr);
          opAttributes.put(attributeType, attrList);
View Full Code Here


      if (attrType.isOperational())
      {
        List<Attribute> attrList = operationalAttributes.get(attrType);
        if ((attrList == null) || attrList.isEmpty())
        {
          AttributeBuilder builder = new AttributeBuilder(attrType, attrName);
          builder.add(attrValue);
          attrList = new ArrayList<Attribute>(1);
          attrList.add(builder.toAttribute());
          operationalAttributes.put(attrType, attrList);
        }
        else
        {
          AttributeBuilder builder = new AttributeBuilder(attrList.get(0));
          builder.add(attrValue);
          attrList.set(0, builder.toAttribute());
        }
      }
      else
      {
        List<Attribute> attrList = userAttributes.get(attrType);
        if ((attrList == null) || attrList.isEmpty())
        {
          AttributeBuilder builder = new AttributeBuilder(attrType, attrName);
          builder.add(attrValue);
          attrList = new ArrayList<Attribute>(1);
          attrList.add(builder.toAttribute());
          userAttributes.put(attrType, attrList);
        }
        else
        {
          AttributeBuilder builder = new AttributeBuilder(attrList.get(0));
          builder.add(attrValue);
          attrList.set(0, builder.toAttribute());
        }
      }
    }

View Full Code Here

      }
    }

    AttributeType attrType =
        DirectoryServer.getDefaultAttributeType("connection");
    AttributeBuilder builder = new AttributeBuilder(attrType);
    for (ClientConnection conn : connMap.values())
    {
      builder.add(AttributeValues.create(attrType, conn
          .getMonitorSummary()));
    }

    ArrayList<Attribute> attrs = new ArrayList<Attribute>(1);
    attrs.add(builder.toAttribute());
    return attrs;
  }
View Full Code Here

      attrType =
           DirectoryServer.getDefaultAttributeType(name, attribute.getSyntax());
    }

    ArrayList<Attribute> attrs = new ArrayList<Attribute>(2);
    AttributeBuilder builder = new AttributeBuilder(attrType, name);
    builder.addAll(attribute.getActiveValues());
    attrs.add(builder.toAttribute());
    if (attribute.hasPendingValues())
    {
      builder = new AttributeBuilder(attrType, name);
      builder.setOption(OPTION_PENDING_VALUES);
      builder.addAll(attribute.getPendingValues());
      attrs.add(builder.toAttribute());
    }

    entry.putAttribute(attrType, attrs);
  }
View Full Code Here

    /* get the Server State */
    final String ATTR_SERVER_STATE = "server-state";
    AttributeType type =
      DirectoryServer.getDefaultAttributeType(ATTR_SERVER_STATE);
    AttributeBuilder builder = new AttributeBuilder(type, ATTR_SERVER_STATE);
    for (String str : domain.getServerState().toStringSet())
    {
      builder.add(AttributeValues.create(type,str));
    }
    attributes.add(builder.toAttribute());

    attributes.add(Attributes.create("ssl-encryption",
        String.valueOf(domain.isSessionEncrypted())));

    attributes.add(Attributes.create("generation-id",
        String.valueOf(domain.getGenerationID())));

    /*
     * Add import/export monitoring attribute
     */
    if (domain.importInProgress())
    {
      addMonitorData(attributes, "total-update", "import");
      addMonitorData(
          attributes, "total-update-entry-count", domain.getTotalEntryCount());
      addMonitorData(
          attributes, "total-update-entry-left", domain.getLeftEntryCount());
    }
    if (domain.exportInProgress())
    {
      addMonitorData(attributes, "total-update", "export");
      addMonitorData(
          attributes, "total-update-entry-count", domain.getTotalEntryCount());
      addMonitorData(
          attributes, "total-update-entry-left", domain.getLeftEntryCount());
    }


    /* Add the concrete Domain attributes */
    Collection<Attribute> additionalMonitoring =
      domain.getAdditionalMonitoring();
    attributes.addAll(additionalMonitoring);

    /*
     * Add assured replication related monitoring fields
     * (see domain.getXXX() method comment for field meaning)
     */

    addMonitorData(attributes, "assured-sr-sent-updates",
      domain.getAssuredSrSentUpdates());

    addMonitorData(attributes, "assured-sr-acknowledged-updates",
      domain.getAssuredSrAcknowledgedUpdates());

    addMonitorData(attributes, "assured-sr-not-acknowledged-updates",
      domain.getAssuredSrNotAcknowledgedUpdates());

    addMonitorData(attributes, "assured-sr-timeout-updates",
      domain.getAssuredSrTimeoutUpdates());

    addMonitorData(attributes, "assured-sr-wrong-status-updates",
      domain.getAssuredSrWrongStatusUpdates());

    addMonitorData(attributes, "assured-sr-replay-error-updates",
      domain.getAssuredSrReplayErrorUpdates());

    final String ATTR_ASS_SR_SRV = "assured-sr-server-not-acknowledged-updates";
    type = DirectoryServer.getDefaultAttributeType(ATTR_ASS_SR_SRV);
    builder = new AttributeBuilder(type, ATTR_ASS_SR_SRV);
    Map<Integer, Integer> srSrvNotAckUps =
      domain.getAssuredSrServerNotAcknowledgedUpdates();
    if (srSrvNotAckUps.size() > 0)
    {
      for (Integer serverId : srSrvNotAckUps.keySet())
      {
        String str = serverId + ":" + srSrvNotAckUps.get(serverId);
        builder.add(AttributeValues.create(type, str));
      }
      attributes.add(builder.toAttribute());
    }

    addMonitorData(attributes, "assured-sr-received-updates",
      domain.getAssuredSrReceivedUpdates());

    addMonitorData(attributes, "assured-sr-received-updates-acked",
      domain.getAssuredSrReceivedUpdatesAcked());

    addMonitorData(attributes, "assured-sr-received-updates-not-acked",
      domain.getAssuredSrReceivedUpdatesNotAcked());

    addMonitorData(attributes, "assured-sd-sent-updates",
      domain.getAssuredSdSentUpdates());

    addMonitorData(attributes, "assured-sd-acknowledged-updates",
      domain.getAssuredSdAcknowledgedUpdates());

    addMonitorData(attributes, "assured-sd-timeout-updates",
      domain.getAssuredSdTimeoutUpdates());

    final String ATTR_ASS_SD_SRV = "assured-sd-server-timeout-updates";
    type = DirectoryServer.getDefaultAttributeType(ATTR_ASS_SD_SRV);
    builder = new AttributeBuilder(type, ATTR_ASS_SD_SRV);
    Map<Integer, Integer> sdSrvTimUps =
      domain.getAssuredSdServerTimeoutUpdates();
    if (sdSrvTimUps.size() > 0)
    {
      for (Integer serverId : sdSrvTimUps.keySet())
      {
        String str = serverId + ":" + sdSrvTimUps.get(serverId);
        builder.add(AttributeValues.create(type, str));
      }
      attributes.add(builder.toAttribute());
    }

    /*
     * Status related monitoring fields
     */
 
View Full Code Here

      {
        remoteState = new ServerState();
      }

      /* get the Server State */
      AttributeBuilder builder = new AttributeBuilder("server-state");
      for (String str : remoteState.toStringSet())
      {
        builder.add(str);
      }
      if (builder.size() == 0)
      {
        builder.add("unknown");
      }
      attributes.add(builder.toAttribute());

      // Oldest missing update
      Long approxFirstMissingDate=md.getApproxFirstMissingDate(serverId);
      if ((approxFirstMissingDate != null) && (approxFirstMissingDate>0))
      {
View Full Code Here

  {
    boolean ret;
    if (!(ret = skipAccessCheck(operation)))
    {
      Entry e = new Entry(dn, null, null, null);
      AttributeBuilder builder =
          new AttributeBuilder(refAttrType, ATTR_REFERRAL_URL);
      List<String> URLStrings = reference.getReferralURLs();

      // Load the values, a bind rule might want to evaluate them.
      for (String URLString : URLStrings)
      {
        builder.add(AttributeValues.create(refAttrType, URLString));
      }

      e.addAttribute(builder.toAttribute(), null);
      SearchResultEntry se = new SearchResultEntry(e);
      AciLDAPOperationContainer operationContainer =
          new AciLDAPOperationContainer(operation, (ACI_READ), se);
      operationContainer.setCurrentAttributeType(refAttrType);
      ret = accessAllowed(operationContainer);
View Full Code Here

      {
        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);
        }
        catch(Exception e)
        {
View Full Code Here

         "cn=Subject DN to User Attribute,cn=Certificate Mappers,cn=config";

    AttributeType attrType =
         DirectoryServer.getAttributeType("ds-cfg-user-base-dn");

    AttributeBuilder builder = new AttributeBuilder(attrType);
    if (baseDNs != null)
    {
      for (String baseDN : baseDNs)
      {
        builder.add(baseDN);
      }
    }

    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
                              builder.toAttribute()));

    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    ModifyOperation modifyOperation =
         conn.processModify(DN.decode(mapperDN), mods);
View Full Code Here

    String mapperDN = "cn=Fingerprint Mapper,cn=Certificate Mappers,cn=config";

    AttributeType attrType =
         DirectoryServer.getAttributeType("ds-cfg-user-base-dn");

    AttributeBuilder builder = new AttributeBuilder(attrType);
    if (baseDNs != null)
    {
      for (String baseDN : baseDNs)
      {
        builder.add(baseDN);
      }
    }

    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
                              builder.toAttribute()));

    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    ModifyOperation modifyOperation =
         conn.processModify(DN.decode(mapperDN), mods);
View Full Code Here

TOP

Related Classes of org.nasutekds.server.types.AttributeBuilder$RealAttribute

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.