Package org.nasutekds.server.types

Examples of org.nasutekds.server.types.AttributeValue


      modTypeLine.append("\n");

      Iterator<AttributeValue> iteratorValues = a.iterator();
      while (iteratorValues.hasNext())
      {
        AttributeValue av = iteratorValues.next();

        String stringValue = av.toString();

        modTypeLine.append(attrName);
        if (needsBase64Encoding(stringValue))
        {
          modTypeLine.append(":: ");
          modTypeLine.append(Base64.encode(av.getValue()));
        }
        else
        {
          modTypeLine.append(": ");
          modTypeLine.append(stringValue);
View Full Code Here


          Iterator<AttributeValue> iav = attrs.get(0).iterator();
          try
          {
            while (true)
            {
              AttributeValue attrVal = iav.next();
              HistoricalAttributeValue histVal =
                new HistoricalAttributeValue(attrVal.toString());
              ChangeNumber cn = histVal.getCn();

              if ((cn != null) && (cn.getServerId() == serverId))
              {
                // compare the csn regarding the maxCn we know and
View Full Code Here

          List<Attribute> attrs =
            ldapSubEntry.getAttribute(ENTRY_UUID.toLowerCase());
          if (attrs != null)
          {
            Iterator<AttributeValue> iav = attrs.get(0).iterator();
            AttributeValue attrVal = iav.next();
            if (attrVal.toString().
                equalsIgnoreCase("ffffffff-ffff-ffff-ffff-ffffffffffff"))
            {
              ruvEntry = ldapSubEntry;
              break;
            }
View Full Code Here

    AttributeType attributeType;
    if ((attributeType = DirectoryServer.getAttributeType(baseName)) == null)
    {
      attributeType = DirectoryServer.getDefaultAttributeType(baseName);
    }
    AttributeValue attributeValue =
        AttributeValues.create(attributeType, operation
            .getAssertionValue());
    operationContainer.setCurrentAttributeType(attributeType);
    operationContainer.setCurrentAttributeValue(attributeValue);
    return isAllowed(operationContainer, operation);
View Full Code Here

    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)))
      {
        break;
View Full Code Here

    Attribute attr = attrs.get(0);
    assertNotNull(attr);
    Iterator<AttributeValue> attrValues = attr.iterator();
    assertNotNull(attrValues);
    assertTrue(attrValues.hasNext());
    AttributeValue attrValue = attrValues.next();
    assertNotNull(attrValue);
    assertFalse(attrValues.hasNext());
    assertEquals(attrValue.toString(), attributeValue, "Was expecting attribute " +
      attributeName + "=" + attributeValue + " but got value: " + attrValue.toString());

  }
View Full Code Here

          }
          else
          {
            bs = ByteString.valueOf(value.toString());
          }
          AttributeValue attributeValue =
            AttributeValues.create(attrType, bs);
          builder.add(attributeValue);
        }
        List<org.nasutekds.server.types.Attribute> attrList =
          new ArrayList<org.nasutekds.server.types.Attribute>(1);
View Full Code Here

    this.passwordPolicySubentryDN = subentry.getDN();

    // Get known Password Policy draft attributes from the entry.
    // If any given attribute is missing or empty set its value
    // from default Password Policy configuration.
    AttributeValue value = getAttrValue(entry, PWD_ATTR_ATTRIBUTE);
    if ((value != null) && (value.toString().length() > 0)) {
      this.pPasswordAttribute = DirectoryServer.getAttributeType(
              value.toString().toLowerCase(), false);
      if (this.pPasswordAttribute == null) {
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                ERR_PWPOLICY_UNDEFINED_PASSWORD_ATTRIBUTE.get(
                this.passwordPolicySubentryDN.toNormalizedString(),
                value.toString()));
      }
    } else {
      // This should not normally happen since pwdAttribute
      // declared as MUST but handle this anyway in case
      // the schema is not enforced for some reason.
      this.pPasswordAttribute =
              defaultPasswordPolicy.getPasswordAttribute();
    }

    value = getAttrValue(entry, PWD_ATTR_MINAGE);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pMinPasswordAge = Long.parseLong(value.toString());
        checkIntegerAttr(PWD_ATTR_MINAGE, this.pMinPasswordAge,
                0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pMinPasswordAge =
              defaultPasswordPolicy.getMinimumPasswordAge();
    }

    value = getAttrValue(entry, PWD_ATTR_MAXAGE);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pMaxPasswordAge = Long.parseLong(value.toString());
        checkIntegerAttr(PWD_ATTR_MAXAGE, this.pMaxPasswordAge,
                0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pMaxPasswordAge =
              defaultPasswordPolicy.getMaximumPasswordAge();
    }

    value = getAttrValue(entry, PWD_ATTR_INHISTORY);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pPasswordHistoryCount = Integer.parseInt(value.toString());
        checkIntegerAttr(PWD_ATTR_INHISTORY,
                this.pPasswordHistoryCount, 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pPasswordHistoryCount =
              defaultPasswordPolicy.getPasswordHistoryCount();
    }

    // This one is managed via the password validator
    // so only check if its value is acceptable.
    value = getAttrValue(entry, PWD_ATTR_CHECKQUALITY);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        int pwdCheckQuality = Integer.parseInt(value.toString());
        checkIntegerAttr(PWD_ATTR_CHECKQUALITY, pwdCheckQuality,
                 0, 2);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    }

    // This one is managed via the password validator
    // so only check if its value is acceptable.
    value = getAttrValue(entry, PWD_ATTR_MINLENGTH);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        int pwdMinLength = Integer.parseInt(value.toString());
        checkIntegerAttr(PWD_ATTR_MINLENGTH, pwdMinLength,
                 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    }

    // This one depends on lockout failure count value
    // so only check if its value is acceptable.
    value = getAttrValue(entry, PWD_ATTR_LOCKOUT);
    if ((value != null) && (value.toString().length() > 0)) {
      if (value.toString().equalsIgnoreCase(Boolean.TRUE.toString()) ||
          value.toString().equalsIgnoreCase(Boolean.FALSE.toString())) {
        Boolean.parseBoolean(value.toString());
      } else {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_BOOLEAN_VALUE.get(
                PWD_ATTR_MUSTCHANGE, value.toString()));
      }
    }

    value = getAttrValue(entry, PWD_ATTR_EXPIREWARNING);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pPasswordExpirationWarningInterval =
              Long.parseLong(value.toString());
        checkIntegerAttr(PWD_ATTR_EXPIREWARNING,
                this.pPasswordExpirationWarningInterval,
                 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pPasswordExpirationWarningInterval =
              defaultPasswordPolicy.getWarningInterval();
    }

    value = getAttrValue(entry, PWD_ATTR_GRACEAUTHNLIMIT);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pGraceLoginCount = Integer.parseInt(value.toString());
        checkIntegerAttr(PWD_ATTR_GRACEAUTHNLIMIT,
                this.pGraceLoginCount, 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pGraceLoginCount =
              defaultPasswordPolicy.getGraceLoginCount();
    }

    value = getAttrValue(entry, PWD_ATTR_LOCKOUTDURATION);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pLockoutDuration = Long.parseLong(value.toString());
        checkIntegerAttr(PWD_ATTR_LOCKOUTDURATION,
                this.pLockoutDuration, 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pLockoutDuration =
              defaultPasswordPolicy.getLockoutDuration();
    }

    value = getAttrValue(entry, PWD_ATTR_MAXFAILURE);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pLockoutFailureCount = Integer.parseInt(value.toString());
        checkIntegerAttr(PWD_ATTR_MAXFAILURE,
                this.pLockoutFailureCount, 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_MINAGE, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pLockoutFailureCount =
              defaultPasswordPolicy.getLockoutFailureCount();
    }

    value = getAttrValue(entry, PWD_ATTR_MUSTCHANGE);
    if ((value != null) && (value.toString().length() > 0)) {
      if (value.toString().equalsIgnoreCase(Boolean.TRUE.toString()) ||
          value.toString().equalsIgnoreCase(Boolean.FALSE.toString())) {
        this.pForceChangeOnReset =
                Boolean.parseBoolean(value.toString());
      } else {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_BOOLEAN_VALUE.get(
                PWD_ATTR_MUSTCHANGE, value.toString()));
      }
    } else {
      this.pForceChangeOnReset =
              defaultPasswordPolicy.forceChangeOnReset();
    }

    value = getAttrValue(entry, PWD_ATTR_ALLOWUSERCHANGE);
    if ((value != null) && (value.toString().length() > 0)) {
      if (value.toString().equalsIgnoreCase(Boolean.TRUE.toString()) ||
          value.toString().equalsIgnoreCase(Boolean.FALSE.toString())) {
        this.pAllowUserPasswordChanges =
                Boolean.parseBoolean(value.toString());
      } else {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_BOOLEAN_VALUE.get(
                PWD_ATTR_ALLOWUSERCHANGE, value.toString()));
      }
    } else {
      this.pAllowUserPasswordChanges =
              defaultPasswordPolicy.allowUserPasswordChanges();
    }

    value = getAttrValue(entry, PWD_ATTR_SAFEMODIFY);
    if ((value != null) && (value.toString().length() > 0)) {
      if (value.toString().equalsIgnoreCase(Boolean.TRUE.toString()) ||
          value.toString().equalsIgnoreCase(Boolean.FALSE.toString())) {
        this.pPasswordChangeRequiresCurrentPassword =
                Boolean.parseBoolean(value.toString());
      } else {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_BOOLEAN_VALUE.get(
                PWD_ATTR_SAFEMODIFY, value.toString()));
      }
    } else {
      this.pPasswordChangeRequiresCurrentPassword =
              defaultPasswordPolicy.requireCurrentPassword();
    }

    value = getAttrValue(entry, PWD_ATTR_FAILURECOUNTINTERVAL);
    if ((value != null) && (value.toString().length() > 0)) {
      try {
        this.pLockoutFailureExpirationInterval =
                Long.parseLong(value.toString());
        checkIntegerAttr(PWD_ATTR_FAILURECOUNTINTERVAL,
                this.pLockoutFailureExpirationInterval,
                 0, Integer.MAX_VALUE);
      } catch (NumberFormatException ne) {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_CONFIG_ATTR_INVALID_INT_VALUE.get(
                PWD_ATTR_FAILURECOUNTINTERVAL, value.toString(),
                ne.getLocalizedMessage()));
      }
    } else {
      this.pLockoutFailureExpirationInterval =
              defaultPasswordPolicy.getLockoutFailureExpirationInterval();
View Full Code Here

    assertTrue(schemaEntry.hasAttribute(cnType));
    assertTrue(schemaEntry.hasAttribute(ctType));
    assertTrue(schemaEntry.hasAttribute(mnType));
    assertTrue(schemaEntry.hasAttribute(mtType));

    AttributeValue oldMTValue =
         schemaEntry.getAttribute(mtType).get(0).iterator().next();

    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
         "add: attributeTypes",
         "attributeTypes: ( testlastmodattributes-oid " +
              "NAME 'testLastModAttributes' " +
              "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
              "X-ORGIN 'SchemaBackendTestCase' )");

    String[] args =
    {
      "-h", "127.0.0.1",
      "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
      "-D", "cn=Directory Manager",
      "-w", "password",
      "-f", path
    };

    // Sleep longer than the TimeThread delay to ensure the modifytimestamp
    // will be different.
    Thread.sleep(6000);
    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);

    schemaEntry = DirectoryServer.getEntry(DN.decode("cn=schema"));
    assertNotNull(schemaEntry);
    assertTrue(schemaEntry.hasAttribute(cnType));
    assertTrue(schemaEntry.hasAttribute(ctType));
    assertTrue(schemaEntry.hasAttribute(mnType));
    assertTrue(schemaEntry.hasAttribute(mtType));

    AttributeValue newMTValue =
         schemaEntry.getAttribute(mtType).get(0).iterator().next();
    assertFalse(oldMTValue.equals(newMTValue));
  }
View Full Code Here

      //from the attribute values and then check to see if our
      //OID is found in the result set or not.
      List<String> syntaxList = new ArrayList<String>();
      while(iter.hasNext())
      {
        AttributeValue val = iter.next();
        //parse the OIDs.
        syntaxList.add(getOIDFromLdapSyntax(val.toString()));
      }

      assertTrue(syntaxList.size() ==
              DirectoryServer.getAttributeSyntaxSet().size() ) ;
      //Check if we find our OID.
View Full Code Here

TOP

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

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.