Search in sources :

Example 11 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class PasswordPolicyStateExtendedResult method encodeValue.

/**
 * Encodes the provided information into a suitable value for this control.
 *
 * @param  userDN             The user DN from the response.
 * @param  operations         The set of operations from the response, mapped
 *                            from operation type to the corresponding
 *                            operation data.
 *
 * @return  An ASN.1 octet string containing the appropriately-encoded value
 *          for this control, or {@code null} if there should not be a value.
 */
@Nullable()
private static ASN1OctetString encodeValue(@Nullable final String userDN, @Nullable final PasswordPolicyStateOperation[] operations) {
    if ((userDN == null) && ((operations == null) || (operations.length == 0))) {
        return null;
    }
    final ArrayList<ASN1Element> elements = new ArrayList<>(2);
    elements.add(new ASN1OctetString(userDN));
    if ((operations != null) && (operations.length > 0)) {
        final ASN1Element[] opElements = new ASN1Element[operations.length];
        for (int i = 0; i < operations.length; i++) {
            opElements[i] = operations[i].encode();
        }
        elements.add(new ASN1Sequence(opElements));
    }
    return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) Nullable(com.unboundid.util.Nullable)

Example 12 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getStackTraceMonitorEntry.

/**
 * Retrieves the stack trace monitor entry from the Directory Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The stack trace monitor entry from the Directory Server, or
 *          {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static StackTraceMonitorEntry getStackTraceMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", StackTraceMonitorEntry.STACK_TRACE_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getStackTraceMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in getStackTraceMonitorEntry");
    }
    return new StackTraceMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Example 13 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getResultCodeMonitorEntry.

/**
 * Retrieves the result code monitor entry from the Directory Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The result code monitor entry from the Directory Server, or
 *          {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static ResultCodeMonitorEntry getResultCodeMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", ResultCodeMonitorEntry.RESULT_CODE_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getResultCodeMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in getResultCodeMonitorEntry");
    }
    return new ResultCodeMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Example 14 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getVersionMonitorEntry.

/**
 * Retrieves the version monitor entry from the Directory Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The version monitor entry from the Directory Server, or
 *          {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static VersionMonitorEntry getVersionMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", VersionMonitorEntry.VERSION_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getVersionMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in getVersionMonitorEntry");
    }
    return new VersionMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Example 15 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getTraditionalWorkQueueMonitorEntry.

/**
 * Retrieves the traditional work queue monitor entry from the Directory
 * Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The traditional work queue monitor entry from the Directory
 *          Server, or {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static TraditionalWorkQueueMonitorEntry getTraditionalWorkQueueMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", TraditionalWorkQueueMonitorEntry.TRADITIONAL_WORK_QUEUE_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getTraditionalWorkQueueMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in getTraditionalWorkQueueMonitorEntry");
    }
    return new TraditionalWorkQueueMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Aggregations

Nullable (com.unboundid.util.Nullable)149 ArrayList (java.util.ArrayList)47 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)42 Entry (com.unboundid.ldap.sdk.Entry)30 LDAPException (com.unboundid.ldap.sdk.LDAPException)30 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)21 Attribute (com.unboundid.ldap.sdk.Attribute)21 ASN1Element (com.unboundid.asn1.ASN1Element)20 Filter (com.unboundid.ldap.sdk.Filter)20 SearchResult (com.unboundid.ldap.sdk.SearchResult)18 IOException (java.io.IOException)16 ReadOnlyEntry (com.unboundid.ldap.sdk.ReadOnlyEntry)14 File (java.io.File)14 DN (com.unboundid.ldap.sdk.DN)12 ArgumentException (com.unboundid.util.args.ArgumentException)10 RDN (com.unboundid.ldap.sdk.RDN)9 LDIFException (com.unboundid.ldif.LDIFException)8 ChangeLogEntry (com.unboundid.ldap.sdk.ChangeLogEntry)7 Modification (com.unboundid.ldap.sdk.Modification)7 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)7