use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class PasswordPolicyStateJSON method getAvailableSASLMechanisms.
/**
* Retrieves a list of the names of the SASL mechanisms that the user can use
* to authenticate.
*
* @return A list of the names of the SASL mechanisms that the user can use
* to authenticate, or an empty list if no SASL mechanisms are
* available to the user or if this was not included in the password
* policy state JSON object.
*/
@NotNull()
public List<String> getAvailableSASLMechanisms() {
final List<String> saslMechanismNames = new ArrayList<>();
final List<JSONValue> values = passwordPolicyStateObject.getFieldAsArray(AVAILABLE_SASL_MECHANISMS.getFieldName());
if (values != null) {
for (final JSONValue v : values) {
try {
saslMechanismNames.add(((JSONString) v).stringValue());
} catch (final Exception e) {
Debug.debugException(e);
}
}
}
return Collections.unmodifiableList(saslMechanismNames);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class PasswordPolicyStateJSON method getAuthenticationFailureTimes.
/**
* Retrieves a list of the outstanding authentication failure times for the
* user account.
*
* @return A list of the outstanding authentication failure times for the
* user account, or an empty list if there are no outstanding
* authentication failures or if this was not included in the
* password policy state JSON object (e.g., because account lockout
* is not configured in the password policy that governs the user).
*/
@NotNull()
public List<Date> getAuthenticationFailureTimes() {
final List<Date> authFailureTimes = new ArrayList<>();
final List<JSONValue> values = passwordPolicyStateObject.getFieldAsArray(AUTHENTICATION_FAILURE_TIMES.getFieldName());
if (values != null) {
for (final JSONValue v : values) {
try {
final String valueString = ((JSONString) v).stringValue();
authFailureTimes.add(StaticUtils.decodeRFC3339Time(valueString));
} catch (final Exception e) {
Debug.debugException(e);
}
}
}
return Collections.unmodifiableList(authFailureTimes);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class PasswordPolicyStateJSON method getAccountUsabilityErrors.
/**
* Retrieves a list of information about any error conditions that may
* affect usability of the user's account.
*
* @return A list of information about any error conditions that may affect
* the usability of the user's account. The returned list may be
* empty if there are no account usability errors or if this was not
* included in the password policy state JSON object.
*/
@NotNull()
public List<PasswordPolicyStateAccountUsabilityError> getAccountUsabilityErrors() {
final List<PasswordPolicyStateAccountUsabilityError> errors = new ArrayList<>();
final List<JSONValue> values = passwordPolicyStateObject.getFieldAsArray(ACCOUNT_USABILITY_ERRORS.getFieldName());
if (values != null) {
for (final JSONValue v : values) {
if (v instanceof JSONObject) {
final JSONObject o = (JSONObject) v;
final String typeName = o.getFieldAsString(USABILITY_FIELD_TYPE_NAME);
final Integer typeID = o.getFieldAsInteger(USABILITY_FIELD_TYPE_ID);
final String message = o.getFieldAsString(USABILITY_FIELD_MESSAGE);
if ((typeName != null) && (typeID != null)) {
errors.add(new PasswordPolicyStateAccountUsabilityError(typeID, typeName, message));
}
}
}
}
return Collections.unmodifiableList(errors);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class PasswordPolicyStateJSON method getAccountUsabilityNotices.
/**
* Retrieves a list of information about any notices related to the usability
* of the user's account.
*
* @return A list of information about any notices related to the usability
* of the user's account. The returned list may be empty if there
* are no account usability notices or if this was not included in
* the password policy state JSON object.
*/
@NotNull()
public List<PasswordPolicyStateAccountUsabilityNotice> getAccountUsabilityNotices() {
final List<PasswordPolicyStateAccountUsabilityNotice> notices = new ArrayList<>();
final List<JSONValue> values = passwordPolicyStateObject.getFieldAsArray(ACCOUNT_USABILITY_NOTICES.getFieldName());
if (values != null) {
for (final JSONValue v : values) {
if (v instanceof JSONObject) {
final JSONObject o = (JSONObject) v;
final String typeName = o.getFieldAsString(USABILITY_FIELD_TYPE_NAME);
final Integer typeID = o.getFieldAsInteger(USABILITY_FIELD_TYPE_ID);
final String message = o.getFieldAsString(USABILITY_FIELD_MESSAGE);
if ((typeName != null) && (typeID != null)) {
notices.add(new PasswordPolicyStateAccountUsabilityNotice(typeID, typeName, message));
}
}
}
}
return Collections.unmodifiableList(notices);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class GreaterThanJSONObjectFilter method toJSONObject.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public JSONObject toJSONObject() {
final LinkedHashMap<String, JSONValue> fields = new LinkedHashMap<>(StaticUtils.computeMapCapacity(6));
fields.put(FIELD_FILTER_TYPE, new JSONString(FILTER_TYPE));
if (field.size() == 1) {
fields.put(FIELD_FIELD_PATH, new JSONString(field.get(0)));
} else {
final ArrayList<JSONValue> fieldNameValues = new ArrayList<>(field.size());
for (final String s : field) {
fieldNameValues.add(new JSONString(s));
}
fields.put(FIELD_FIELD_PATH, new JSONArray(fieldNameValues));
}
fields.put(FIELD_VALUE, value);
if (allowEquals) {
fields.put(FIELD_ALLOW_EQUALS, JSONBoolean.TRUE);
}
if (matchAllElements) {
fields.put(FIELD_MATCH_ALL_ELEMENTS, JSONBoolean.TRUE);
}
if (caseSensitive) {
fields.put(FIELD_CASE_SENSITIVE, JSONBoolean.TRUE);
}
return new JSONObject(fields);
}
Aggregations