Search in sources :

Example 1 with JSONBoolean

use of com.unboundid.util.json.JSONBoolean in project ldapsdk by pingidentity.

the class JSONLogsTestCase method createPopulatedMessageObject.

/**
 * Creates a JSON object with an encoded representation of a log message that
 * has values populated for most of the optional common fields.
 *
 * @param  messageType    The message type for the log message.  This must not
 *                        be {@code null}.
 * @param  operationType  The operation type for the log message.  This may be
 *                        {@code null} if it is not an operation log message.
 * @param  fields         The set of additional fields to include in the log
 *                        message.  This must not be {@code null} but may be
 *                        empty.
 *
 * @return  The log message that was created.
 */
@NotNull()
protected static JSONObject createPopulatedMessageObject(@NotNull final AccessLogMessageType messageType, @Nullable final AccessLogOperationType operationType, @NotNull final JSONField... fields) {
    final Map<String, JSONValue> fieldMap = createMinimalFieldMap(messageType, operationType);
    fieldMap.put(PRODUCT_NAME.getFieldName(), new JSONString(DEFAULT_PRODUCT_NAME));
    fieldMap.put(INSTANCE_NAME.getFieldName(), new JSONString(DEFAULT_INSTANCE_NAME));
    fieldMap.put(STARTUP_ID.getFieldName(), new JSONString(DEFAULT_STARTUP_ID));
    fieldMap.put(THREAD_ID.getFieldName(), new JSONNumber(DEFAULT_THREAD_ID));
    fieldMap.put(CONNECTION_ID.getFieldName(), new JSONNumber(DEFAULT_CONNECTION_ID));
    if (operationType != null) {
        fieldMap.put(OPERATION_ID.getFieldName(), new JSONNumber(DEFAULT_OPERATION_ID));
        fieldMap.put(MESSAGE_ID.getFieldName(), new JSONNumber(DEFAULT_MESSAGE_ID));
        fieldMap.put(TRIGGERED_BY_CONNECTION_ID.getFieldName(), new JSONNumber(DEFAULT_TRIGGERED_BY_CONNECTION_ID));
        fieldMap.put(TRIGGERED_BY_OPERATION_ID.getFieldName(), new JSONNumber(DEFAULT_TRIGGERED_BY_OPERATION_ID));
        fieldMap.put(ORIGIN.getFieldName(), new JSONString(DEFAULT_ORIGIN));
        fieldMap.put(REQUESTER_IP_ADDRESS.getFieldName(), new JSONString(DEFAULT_REQUESTER_IP));
        fieldMap.put(REQUESTER_DN.getFieldName(), new JSONString(DEFAULT_REQUESTER_DN));
        fieldMap.put(REQUEST_CONTROL_OIDS.getFieldName(), createArray(DEFAULT_REQUEST_CONTROL_OIDS));
        fieldMap.put(USING_ADMIN_SESSION_WORKER_THREAD.getFieldName(), new JSONBoolean(DEFAULT_USING_ADMIN_SESSION_WORKER_THREAD));
        fieldMap.put(ADMINISTRATIVE_OPERATION.getFieldName(), new JSONString(DEFAULT_ADMIN_OP_MESSAGE));
        fieldMap.put(INTERMEDIATE_CLIENT_REQUEST_CONTROL.getFieldName(), DEFAULT_INTERMEDIATE_CLIENT_REQUEST.getControlObject());
        fieldMap.put(OPERATION_PURPOSE.getFieldName(), DEFAULT_OPERATION_PURPOSE_REQUEST.getControlObject());
        if ((messageType == AccessLogMessageType.FORWARD) || (messageType == AccessLogMessageType.FORWARD_FAILED) || (messageType == AccessLogMessageType.RESULT) || (messageType == AccessLogMessageType.ASSURANCE_COMPLETE)) {
            fieldMap.put(TARGET_HOST.getFieldName(), new JSONString(DEFAULT_FORWARD_TARGET_HOST));
            fieldMap.put(TARGET_PORT.getFieldName(), new JSONNumber(DEFAULT_FORWARD_TARGET_PORT));
            fieldMap.put(TARGET_PROTOCOL.getFieldName(), new JSONString(DEFAULT_FORWARD_TARGET_PROTOCOL));
        }
        if ((messageType == AccessLogMessageType.FORWARD_FAILED) || (messageType == AccessLogMessageType.RESULT) || (messageType == AccessLogMessageType.ASSURANCE_COMPLETE)) {
            fieldMap.put(RESULT_CODE_VALUE.getFieldName(), new JSONNumber(DEFAULT_RESULT_CODE.intValue()));
            fieldMap.put(RESULT_CODE_NAME.getFieldName(), new JSONString(DEFAULT_RESULT_CODE.getName()));
            fieldMap.put(DIAGNOSTIC_MESSAGE.getFieldName(), new JSONString(DEFAULT_DIAGNOSTIC_MESSAGE));
        }
        if ((messageType == AccessLogMessageType.RESULT) || (messageType == AccessLogMessageType.ASSURANCE_COMPLETE) || (messageType == AccessLogMessageType.ENTRY) || (messageType == AccessLogMessageType.REFERENCE) || (messageType == AccessLogMessageType.INTERMEDIATE_RESPONSE)) {
            fieldMap.put(RESPONSE_CONTROL_OIDS.getFieldName(), createArray(DEFAULT_RESPONSE_CONTROL_OIDS));
        }
        if ((messageType == AccessLogMessageType.RESULT) || (messageType == AccessLogMessageType.ASSURANCE_COMPLETE)) {
            fieldMap.put(ADDITIONAL_INFO.getFieldName(), new JSONString(DEFAULT_ADDITIONAL_INFO_MESSAGE));
            fieldMap.put(MATCHED_DN.getFieldName(), new JSONString(DEFAULT_MATCHED_DN));
            fieldMap.put(REFERRAL_URLS.getFieldName(), createArray(DEFAULT_REFERRAL_URLS));
            fieldMap.put(SERVERS_ACCESSED.getFieldName(), createArray(DEFAULT_SERVERS_ACCESSED));
            fieldMap.put(UNCACHED_DATA_ACCESSED.getFieldName(), new JSONBoolean(DEFAULT_UNCACHED_DATA_ACCESSED));
            fieldMap.put(WORK_QUEUE_WAIT_TIME_MILLIS.getFieldName(), new JSONNumber(DEFAULT_WORK_QUEUE_WAIT_TIME_MILLIS));
            fieldMap.put(PROCESSING_TIME_MILLIS.getFieldName(), new JSONNumber(DEFAULT_PROCESSING_TIME_MILLIS));
            fieldMap.put(INTERMEDIATE_RESPONSES_RETURNED.getFieldName(), new JSONNumber(DEFAULT_INTERMEDIATE_RESPONSES_RETURNED));
            fieldMap.put(USED_PRIVILEGES.getFieldName(), createArray(DEFAULT_USED_PRIVILEGES));
            fieldMap.put(PRE_AUTHORIZATION_USED_PRIVILEGES.getFieldName(), createArray(DEFAULT_PRE_AUTHZ_USED_PRIVILEGES));
            fieldMap.put(MISSING_PRIVILEGES.getFieldName(), createArray(DEFAULT_MISSING_PRIVILEGES));
            if (operationType != AccessLogOperationType.ABANDON) {
                fieldMap.put(INTERMEDIATE_CLIENT_RESPONSE_CONTROL.getFieldName(), DEFAULT_INTERMEDIATE_CLIENT_RESPONSE.getControlObject());
            }
            if ((operationType == AccessLogOperationType.ADD) || (operationType == AccessLogOperationType.COMPARE) || (operationType == AccessLogOperationType.DELETE) || (operationType == AccessLogOperationType.MODIFY) || (operationType == AccessLogOperationType.MODDN) || (operationType == AccessLogOperationType.SEARCH)) {
                fieldMap.put(AUTHORIZATION_DN.getFieldName(), new JSONString(DEFAULT_AUTHZ_DN));
            }
            if ((operationType == AccessLogOperationType.ADD) || (operationType == AccessLogOperationType.DELETE) || (operationType == AccessLogOperationType.MODIFY) || (operationType == AccessLogOperationType.MODDN)) {
                fieldMap.put(REPLICATION_CHANGE_ID.getFieldName(), new JSONString(DEFAULT_REPLICATION_CHANGE_ID));
                fieldMap.put(ASSURED_REPLICATION_REQUIREMENTS.getFieldName(), createAssuredReplicationRequirements());
            }
            if ((operationType == AccessLogOperationType.ADD) || (operationType == AccessLogOperationType.DELETE) || (operationType == AccessLogOperationType.MODIFY) || (operationType == AccessLogOperationType.MODDN) || (operationType == AccessLogOperationType.SEARCH)) {
                fieldMap.put(INDEXES_WITH_KEYS_ACCESSED_NEAR_ENTRY_LIMIT.getFieldName(), createArray(DEFAULT_INDEXES_NEAR_ENTRY_LIMIT));
                fieldMap.put(INDEXES_WITH_KEYS_ACCESSED_EXCEEDING_ENTRY_LIMIT.getFieldName(), createArray(DEFAULT_INDEXES_EXCEEDING_ENTRY_LIMIT));
            }
        }
        if (messageType == AccessLogMessageType.ASSURANCE_COMPLETE) {
            fieldMap.put(LOCAL_ASSURANCE_SATISFIED.getFieldName(), new JSONBoolean(DEFAULT_LOCAL_ASSURANCE_SATISFIED));
            fieldMap.put(REMOTE_ASSURANCE_SATISFIED.getFieldName(), new JSONBoolean(DEFAULT_REMOTE_ASSURANCE_SATISFIED));
            fieldMap.put(SERVER_ASSURANCE_RESULTS.getFieldName(), new JSONArray(DEFAULT_ASSURED_REPLICATION_SERVER_RESULTS.get(0).getServerResultObject(), DEFAULT_ASSURED_REPLICATION_SERVER_RESULTS.get(1).getServerResultObject()));
        }
    }
    for (final JSONField field : fields) {
        fieldMap.put(field.getName(), field.getValue());
    }
    return new JSONObject(fieldMap);
}
Also used : JSONValue(com.unboundid.util.json.JSONValue) JSONObject(com.unboundid.util.json.JSONObject) JSONArray(com.unboundid.util.json.JSONArray) JSONBoolean(com.unboundid.util.json.JSONBoolean) JSONField(com.unboundid.util.json.JSONField) JSONNumber(com.unboundid.util.json.JSONNumber) JSONString(com.unboundid.util.json.JSONString) JSONString(com.unboundid.util.json.JSONString) NotNull(com.unboundid.util.NotNull)

Example 2 with JSONBoolean

use of com.unboundid.util.json.JSONBoolean in project ldapsdk by pingidentity.

the class EqualsJSONObjectFilterTestCase method testTopLevelFieldBoolean.

/**
 * Provides test coverage for the case in which a filter references a
 * top-level field and a Boolean value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTopLevelFieldBoolean() throws Exception {
    EqualsJSONObjectFilter f = new EqualsJSONObjectFilter("top-level-field", JSONBoolean.TRUE);
    assertNotNull(f.toJSONObject());
    assertEquals(f.toJSONObject(), new JSONObject(new JSONField("filterType", "equals"), new JSONField("field", "top-level-field"), new JSONField("value", true)));
    f = (EqualsJSONObjectFilter) JSONObjectFilter.decode(f.toJSONObject());
    assertNotNull(f);
    assertNotNull(f.getField());
    assertEquals(f.getField(), Collections.singletonList("top-level-field"));
    assertNotNull(f.getValue());
    assertEquals(f.getValue(), new JSONBoolean(true));
    assertFalse(f.caseSensitive());
    assertNotNull(f.getFilterType());
    assertEquals(f.getFilterType(), "equals");
    assertNotNull(f.getRequiredFieldNames());
    assertEquals(f.getRequiredFieldNames(), new HashSet<String>(Arrays.asList("field", "value")));
    assertNotNull(f.getOptionalFieldNames());
    assertEquals(f.getOptionalFieldNames(), new HashSet<String>(Collections.singletonList("caseSensitive")));
    assertTrue(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", true))));
    assertFalse(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", false))));
    assertTrue(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", new JSONArray(JSONBoolean.TRUE, JSONBoolean.FALSE)))));
    assertTrue(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", new JSONArray(JSONBoolean.FALSE, JSONBoolean.TRUE)))));
    assertFalse(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", new JSONObject(new JSONField("top-level-field", true))))));
    f = new EqualsJSONObjectFilter("top-level-field", JSONBoolean.FALSE);
    assertNotNull(f.toJSONObject());
    assertEquals(f.toJSONObject(), new JSONObject(new JSONField("filterType", "equals"), new JSONField("field", "top-level-field"), new JSONField("value", false)));
    f = (EqualsJSONObjectFilter) JSONObjectFilter.decode(f.toJSONObject());
    assertNotNull(f);
    assertNotNull(f.getField());
    assertEquals(f.getField(), Collections.singletonList("top-level-field"));
    assertNotNull(f.getValue());
    assertEquals(f.getValue(), new JSONBoolean(false));
    assertFalse(f.caseSensitive());
    assertNotNull(f.getFilterType());
    assertEquals(f.getFilterType(), "equals");
    assertNotNull(f.getRequiredFieldNames());
    assertEquals(f.getRequiredFieldNames(), new HashSet<String>(Arrays.asList("field", "value")));
    assertNotNull(f.getOptionalFieldNames());
    assertEquals(f.getOptionalFieldNames(), new HashSet<String>(Collections.singletonList("caseSensitive")));
    assertFalse(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", true))));
    assertTrue(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", false))));
    assertTrue(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", new JSONArray(JSONBoolean.TRUE, JSONBoolean.FALSE)))));
    assertTrue(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", new JSONArray(JSONBoolean.FALSE, JSONBoolean.TRUE)))));
    assertFalse(f.matchesJSONObject(new JSONObject(new JSONField("top-level-field", new JSONObject(new JSONField("top-level-field", true))))));
}
Also used : JSONObject(com.unboundid.util.json.JSONObject) JSONArray(com.unboundid.util.json.JSONArray) JSONField(com.unboundid.util.json.JSONField) JSONBoolean(com.unboundid.util.json.JSONBoolean) JSONString(com.unboundid.util.json.JSONString) Test(org.testng.annotations.Test)

Example 3 with JSONBoolean

use of com.unboundid.util.json.JSONBoolean in project ldapsdk by pingidentity.

the class ModifiablePasswordPolicyStateJSONTestCase method createState.

/**
 * Creates a password policy state JSON object with the provided fields.
 *
 * @param  fields  The fields to include in the JSON object.
 *
 * @return  The password policy state JSON object that was created.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
private ModifiablePasswordPolicyStateJSON createState(final Map<ModifiablePasswordPolicyStateJSONField, ?> fields) throws Exception {
    final Map<String, JSONValue> jsonFields = new LinkedHashMap<>();
    for (final ModifiablePasswordPolicyStateJSONField field : fields.keySet()) {
        final String name = field.getFieldName();
        final Object value = fields.get(field);
        if (value instanceof Boolean) {
            final Boolean b = (Boolean) value;
            jsonFields.put(name, new JSONBoolean(b));
        } else if (value instanceof String) {
            final String s = (String) value;
            jsonFields.put(name, new JSONString(s));
        } else if (value instanceof Date) {
            final Date d = (Date) value;
            jsonFields.put(name, new JSONString(StaticUtils.encodeRFC3339Time(d)));
        } else if (value instanceof JSONValue) {
            jsonFields.put(name, (JSONValue) value);
        } else {
            fail("Unexpected field value " + value + " of type " + value.getClass().getName());
        }
    }
    final JSONObject o = new JSONObject(jsonFields);
    final Entry entry = new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: test.user", "givenName: Test", "sn: User", "cn: Test User");
    entry.addAttribute("ds-pwp-modifiable-state-json", o.toSingleLineString());
    final ModifiablePasswordPolicyStateJSON state = ModifiablePasswordPolicyStateJSON.get(entry);
    assertNotNull(state);
    assertNotNull(state.getModifiablePasswordPolicyStateJSONObject());
    assertFalse(state.getModifiablePasswordPolicyStateJSONObject().getFields().isEmpty());
    assertEquals(state.getModifiablePasswordPolicyStateJSONObject().getFields().size(), jsonFields.size());
    assertNotNull(state.toString());
    assertFalse(state.toString().isEmpty());
    return state;
}
Also used : ModifiablePasswordPolicyStateJSONField(com.unboundid.ldap.sdk.unboundidds.ModifiablePasswordPolicyStateJSONField) JSONString(com.unboundid.util.json.JSONString) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) JSONValue(com.unboundid.util.json.JSONValue) Entry(com.unboundid.ldap.sdk.Entry) JSONObject(com.unboundid.util.json.JSONObject) JSONBoolean(com.unboundid.util.json.JSONBoolean) JSONObject(com.unboundid.util.json.JSONObject) JSONBoolean(com.unboundid.util.json.JSONBoolean) JSONString(com.unboundid.util.json.JSONString)

Example 4 with JSONBoolean

use of com.unboundid.util.json.JSONBoolean in project ldapsdk by pingidentity.

the class RecentLoginHistoryAttempt method encodeToJSON.

/**
 * Encodes the provided information about a successful authentication attempt
 * to a JSON object.
 *
 * @param  successful              Indicates whether the attempt was
 *                                 successful.
 * @param  timestamp               The time of the authentication attempt.
 * @param  authenticationMethod    The name of the authentication method
 *                                 used for the attempt.  This must not be
 *                                 {@code null} or empty.
 * @param  clientIPAddress         The IP address of the client that made the
 *                                 authentication attempt.  This may be
 *                                 {@code null} if no client IP address is
 *                                 available.
 * @param  failureReason           A general reason that the authentication
 *                                 attempt failed.  It must be {@code null} if
 *                                 the attempt succeeded and must not be
 *                                 {@code null} if the attempt failed.  If
 *                                 provided, the value should be one of the
 *                                 {@code FAILURE_NAME_}* constants in the
 *                                 {@link AuthenticationFailureReason} class.
 * @param  additionalAttemptCount  The number of additional authentication
 *                                 attempts that occurred on the same date (in
 *                                 the UTC time zone) as the provided
 *                                 timestamp with the same values for the
 *                                 successful, authentication method, client
 *                                 IP address, and failure reason fields.  It
 *                                 may be {@code null} if this should not be
 *                                 included (e.g., if information about
 *                                 similar attempts should not be collapsed).
 *
 * @return  A JSON object containing the provided information.
 */
@NotNull()
private static JSONObject encodeToJSON(final boolean successful, final long timestamp, @NotNull final String authenticationMethod, @Nullable final String clientIPAddress, @Nullable final String failureReason, @Nullable final Long additionalAttemptCount) {
    final Map<String, JSONValue> fields = new LinkedHashMap<>(StaticUtils.computeMapCapacity(6));
    fields.put(JSON_FIELD_SUCCESSFUL, new JSONBoolean(successful));
    fields.put(JSON_FIELD_TIMESTAMP, new JSONString(StaticUtils.encodeRFC3339Time(timestamp)));
    fields.put(JSON_FIELD_AUTHENTICATION_METHOD, new JSONString(authenticationMethod));
    if (clientIPAddress != null) {
        fields.put(JSON_FIELD_CLIENT_IP_ADDRESS, new JSONString(clientIPAddress));
    }
    if (failureReason != null) {
        fields.put(JSON_FIELD_FAILURE_REASON, new JSONString(failureReason));
    }
    if (additionalAttemptCount != null) {
        fields.put(JSON_FIELD_ADDITIONAL_ATTEMPT_COUNT, new JSONNumber(additionalAttemptCount));
    }
    return new JSONObject(fields);
}
Also used : JSONValue(com.unboundid.util.json.JSONValue) JSONObject(com.unboundid.util.json.JSONObject) JSONBoolean(com.unboundid.util.json.JSONBoolean) JSONNumber(com.unboundid.util.json.JSONNumber) JSONString(com.unboundid.util.json.JSONString) JSONString(com.unboundid.util.json.JSONString) LinkedHashMap(java.util.LinkedHashMap) NotNull(com.unboundid.util.NotNull)

Example 5 with JSONBoolean

use of com.unboundid.util.json.JSONBoolean in project ldapsdk by pingidentity.

the class PasswordPolicyStateJSONTestCase method createState.

/**
 * Creates a password policy state JSON object with the provided fields.
 *
 * @param  fields  The fields to include in the JSON object.
 *
 * @return  The password policy state JSON object that was created.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
private PasswordPolicyStateJSON createState(final Map<PasswordPolicyStateJSONField, ?> fields) throws Exception {
    final Map<String, JSONValue> jsonFields = new LinkedHashMap<>();
    for (final PasswordPolicyStateJSONField field : fields.keySet()) {
        final String name = field.getFieldName();
        final Object value = fields.get(field);
        if (value instanceof Boolean) {
            final Boolean b = (Boolean) value;
            jsonFields.put(name, new JSONBoolean(b));
        } else if (value instanceof Integer) {
            final Integer i = (Integer) value;
            jsonFields.put(name, new JSONNumber(i));
        } else if (value instanceof String) {
            final String s = (String) value;
            jsonFields.put(name, new JSONString(s));
        } else if (value instanceof Date) {
            final Date d = (Date) value;
            jsonFields.put(name, new JSONString(StaticUtils.encodeRFC3339Time(d)));
        } else if (value instanceof List) {
            final List<?> l = (List<?>) value;
            final List<JSONValue> arrayValues = new ArrayList<>();
            for (final Object o : l) {
                if (o instanceof Date) {
                    final Date d = (Date) o;
                    arrayValues.add(new JSONString(StaticUtils.encodeRFC3339Time(d)));
                } else if (o instanceof String) {
                    final String s = (String) o;
                    arrayValues.add(new JSONString(s));
                } else if (o instanceof PasswordPolicyStateAccountUsabilityError) {
                    final PasswordPolicyStateAccountUsabilityError e = (PasswordPolicyStateAccountUsabilityError) o;
                    if (e.getMessage() == null) {
                        arrayValues.add(new JSONObject(new JSONField("type-name", e.getName()), new JSONField("type-id", e.getIntValue())));
                    } else {
                        arrayValues.add(new JSONObject(new JSONField("type-name", e.getName()), new JSONField("type-id", e.getIntValue()), new JSONField("message", e.getMessage())));
                    }
                } else if (o instanceof PasswordPolicyStateAccountUsabilityWarning) {
                    final PasswordPolicyStateAccountUsabilityWarning w = (PasswordPolicyStateAccountUsabilityWarning) o;
                    if (w.getMessage() == null) {
                        arrayValues.add(new JSONObject(new JSONField("type-name", w.getName()), new JSONField("type-id", w.getIntValue())));
                    } else {
                        arrayValues.add(new JSONObject(new JSONField("type-name", w.getName()), new JSONField("type-id", w.getIntValue()), new JSONField("message", w.getMessage())));
                    }
                } else if (o instanceof PasswordPolicyStateAccountUsabilityNotice) {
                    final PasswordPolicyStateAccountUsabilityNotice n = (PasswordPolicyStateAccountUsabilityNotice) o;
                    if (n.getMessage() == null) {
                        arrayValues.add(new JSONObject(new JSONField("type-name", n.getName()), new JSONField("type-id", n.getIntValue())));
                    } else {
                        arrayValues.add(new JSONObject(new JSONField("type-name", n.getName()), new JSONField("type-id", n.getIntValue()), new JSONField("message", n.getMessage())));
                    }
                } else {
                    fail("Unexpected list element " + o + " of type " + o.getClass().getName());
                }
            }
            jsonFields.put(name, new JSONArray(arrayValues));
        } else if (value instanceof JSONValue) {
            jsonFields.put(name, (JSONValue) value);
        } else {
            fail("Unexpected field value " + value + " of type " + value.getClass().getName());
        }
    }
    final JSONObject o = new JSONObject(jsonFields);
    final Entry entry = new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: test.user", "givenName: Test", "sn: User", "cn: Test User");
    entry.addAttribute("ds-pwp-state-json", o.toSingleLineString());
    final PasswordPolicyStateJSON state = PasswordPolicyStateJSON.get(entry);
    assertNotNull(state);
    assertNotNull(state.getPasswordPolicyStateJSONObject());
    assertFalse(state.getPasswordPolicyStateJSONObject().getFields().isEmpty());
    assertEquals(state.getPasswordPolicyStateJSONObject().getFields().size(), jsonFields.size());
    assertNotNull(state.toString());
    assertFalse(state.toString().isEmpty());
    return state;
}
Also used : PasswordPolicyStateAccountUsabilityError(com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityError) ArrayList(java.util.ArrayList) JSONArray(com.unboundid.util.json.JSONArray) PasswordPolicyStateJSONField(com.unboundid.ldap.sdk.unboundidds.PasswordPolicyStateJSONField) JSONField(com.unboundid.util.json.JSONField) JSONString(com.unboundid.util.json.JSONString) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) JSONValue(com.unboundid.util.json.JSONValue) Entry(com.unboundid.ldap.sdk.Entry) PasswordPolicyStateAccountUsabilityNotice(com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityNotice) PasswordPolicyStateJSONField(com.unboundid.ldap.sdk.unboundidds.PasswordPolicyStateJSONField) JSONObject(com.unboundid.util.json.JSONObject) JSONBoolean(com.unboundid.util.json.JSONBoolean) PasswordPolicyStateAccountUsabilityWarning(com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityWarning) JSONObject(com.unboundid.util.json.JSONObject) JSONNumber(com.unboundid.util.json.JSONNumber) ArrayList(java.util.ArrayList) List(java.util.List) JSONBoolean(com.unboundid.util.json.JSONBoolean) JSONString(com.unboundid.util.json.JSONString)

Aggregations

JSONBoolean (com.unboundid.util.json.JSONBoolean)7 JSONObject (com.unboundid.util.json.JSONObject)7 JSONString (com.unboundid.util.json.JSONString)7 JSONValue (com.unboundid.util.json.JSONValue)6 JSONArray (com.unboundid.util.json.JSONArray)5 LinkedHashMap (java.util.LinkedHashMap)5 JSONField (com.unboundid.util.json.JSONField)4 JSONNumber (com.unboundid.util.json.JSONNumber)4 Entry (com.unboundid.ldap.sdk.Entry)3 NotNull (com.unboundid.util.NotNull)3 ArrayList (java.util.ArrayList)3 PasswordPolicyStateJSONField (com.unboundid.ldap.sdk.unboundidds.PasswordPolicyStateJSONField)2 Date (java.util.Date)2 Map (java.util.Map)2 ModifiablePasswordPolicyStateJSONField (com.unboundid.ldap.sdk.unboundidds.ModifiablePasswordPolicyStateJSONField)1 PasswordPolicyStateAccountUsabilityError (com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityError)1 PasswordPolicyStateAccountUsabilityNotice (com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityNotice)1 PasswordPolicyStateAccountUsabilityWarning (com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityWarning)1 HashMap (java.util.HashMap)1 List (java.util.List)1