Search in sources :

Example 1 with CollectSupportDataSecurityLevel

use of com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel in project ldapsdk by pingidentity.

the class CollectSupportDataExtendedRequestTestCase method testSecurityLevels.

/**
 * Tests the behavior when using the various security levels.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSecurityLevels() throws Exception {
    final TestCollectSupportDataIntermediateResponseListener listener = new TestCollectSupportDataIntermediateResponseListener();
    final CollectSupportDataExtendedRequestProperties properties = new CollectSupportDataExtendedRequestProperties();
    for (final CollectSupportDataSecurityLevel securityLevel : CollectSupportDataSecurityLevel.values()) {
        properties.setSecurityLevel(securityLevel);
        CollectSupportDataExtendedRequest r = new CollectSupportDataExtendedRequest(properties, listener);
        r = new CollectSupportDataExtendedRequest(r, listener);
        r = r.duplicate();
        assertNotNull(r.getOID());
        assertEquals(r.getOID(), "1.3.6.1.4.1.30221.2.6.64");
        assertNotNull(r.getValue());
        assertNotNull(r.getCollectSupportDataIntermediateResponseListener());
        assertTrue(r.getCollectSupportDataIntermediateResponseListener() instanceof TestCollectSupportDataIntermediateResponseListener);
        assertNull(r.getArchiveFileName());
        assertNull(r.getEncryptionPassphrase());
        assertNull(r.getIncludeExpensiveData());
        assertNull(r.getIncludeReplicationStateDump());
        assertNull(r.getIncludeBinaryFiles());
        assertNull(r.getIncludeExpensiveData());
        assertNull(r.getUseSequentialMode());
        assertNotNull(r.getSecurityLevel());
        assertEquals(r.getSecurityLevel(), securityLevel);
        assertNull(r.getJStackCount());
        assertNull(r.getReportCount());
        assertNull(r.getReportIntervalSeconds());
        assertNull(r.getLogCaptureWindow());
        assertNull(r.getComment());
        assertNull(r.getProxyToServerAddress());
        assertNull(r.getProxyToServerPort());
        assertNull(r.getMaximumFragmentSizeBytes());
        assertNotNull(r.getControls());
        assertEquals(r.getControls().length, 0);
        assertNotNull(r.getExtendedRequestName());
        assertFalse(r.getExtendedRequestName().isEmpty());
        assertNotNull(r.toString());
    }
}
Also used : CollectSupportDataSecurityLevel(com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel) Test(org.testng.annotations.Test)

Example 2 with CollectSupportDataSecurityLevel

use of com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel in project ldapsdk by pingidentity.

the class CollectSupportDataExtendedRequestPropertiesTestCase method testSecurityLevel.

/**
 * Tests the behavior for the security level property.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSecurityLevel() throws Exception {
    CollectSupportDataExtendedRequestProperties p = new CollectSupportDataExtendedRequestProperties();
    p = new CollectSupportDataExtendedRequestProperties(p);
    assertNull(p.getArchiveFileName());
    assertNull(p.getEncryptionPassphrase());
    assertNull(p.getIncludeExpensiveData());
    assertNull(p.getIncludeReplicationStateDump());
    assertNull(p.getIncludeBinaryFiles());
    assertNull(p.getIncludeExtensionSource());
    assertNull(p.getUseSequentialMode());
    assertNull(p.getSecurityLevel());
    assertNull(p.getJStackCount());
    assertNull(p.getReportCount());
    assertNull(p.getReportIntervalSeconds());
    assertNull(p.getLogCaptureWindow());
    assertNull(p.getComment());
    assertNull(p.getProxyToServerAddress());
    assertNull(p.getProxyToServerPort());
    assertNull(p.getMaximumFragmentSizeBytes());
    assertNotNull(p.toString());
    for (final CollectSupportDataSecurityLevel level : CollectSupportDataSecurityLevel.values()) {
        p.setSecurityLevel(level);
        p = new CollectSupportDataExtendedRequestProperties(p);
        assertNull(p.getArchiveFileName());
        assertNull(p.getEncryptionPassphrase());
        assertNull(p.getIncludeExpensiveData());
        assertNull(p.getIncludeReplicationStateDump());
        assertNull(p.getIncludeBinaryFiles());
        assertNull(p.getIncludeExtensionSource());
        assertNull(p.getUseSequentialMode());
        assertNotNull(p.getSecurityLevel());
        assertEquals(p.getSecurityLevel(), level);
        assertNull(p.getJStackCount());
        assertNull(p.getReportCount());
        assertNull(p.getReportIntervalSeconds());
        assertNull(p.getLogCaptureWindow());
        assertNull(p.getComment());
        assertNull(p.getProxyToServerAddress());
        assertNull(p.getProxyToServerPort());
        assertNull(p.getMaximumFragmentSizeBytes());
        assertNotNull(p.toString());
    }
    p.setSecurityLevel(null);
    p = new CollectSupportDataExtendedRequestProperties(p);
    assertNull(p.getArchiveFileName());
    assertNull(p.getEncryptionPassphrase());
    assertNull(p.getIncludeExpensiveData());
    assertNull(p.getIncludeReplicationStateDump());
    assertNull(p.getIncludeBinaryFiles());
    assertNull(p.getIncludeExtensionSource());
    assertNull(p.getUseSequentialMode());
    assertNull(p.getSecurityLevel());
    assertNull(p.getJStackCount());
    assertNull(p.getReportCount());
    assertNull(p.getReportIntervalSeconds());
    assertNull(p.getLogCaptureWindow());
    assertNull(p.getComment());
    assertNull(p.getProxyToServerAddress());
    assertNull(p.getProxyToServerPort());
    assertNull(p.getMaximumFragmentSizeBytes());
    assertNotNull(p.toString());
}
Also used : CollectSupportDataSecurityLevel(com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel) Test(org.testng.annotations.Test)

Example 3 with CollectSupportDataSecurityLevel

use of com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel in project ldapsdk by pingidentity.

the class CollectSupportDataExtendedRequest method encodeValue.

/**
 * Constructs an ASN.1 octet string suitable for use as the value of this
 * collect support data extended request from the given set of properties.
 *
 * @param  properties  The properties that should be used to construct the
 *                     extended request value.  It must not be {@code null}.
 *
 * @return  the ASN.1 octet string that was created.
 */
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final CollectSupportDataExtendedRequestProperties properties) {
    final List<ASN1Element> elements = new ArrayList<>(20);
    final String archiveFileName = properties.getArchiveFileName();
    if (archiveFileName != null) {
        elements.add(new ASN1OctetString(TYPE_ARCHIVE_FILE_NAME, archiveFileName));
    }
    final ASN1OctetString encryptionPassphrase = properties.getEncryptionPassphrase();
    if (encryptionPassphrase != null) {
        elements.add(encryptionPassphrase);
    }
    final Boolean includeExpensiveData = properties.getIncludeExpensiveData();
    if (includeExpensiveData != null) {
        elements.add(new ASN1Boolean(TYPE_INCLUDE_EXPENSIVE_DATA, includeExpensiveData));
    }
    final Boolean includeReplicationStateDump = properties.getIncludeReplicationStateDump();
    if (includeReplicationStateDump != null) {
        elements.add(new ASN1Boolean(TYPE_INCLUDE_REPLICATION_STATE_DUMP, includeReplicationStateDump));
    }
    final Boolean includeBinaryFiles = properties.getIncludeBinaryFiles();
    if (includeBinaryFiles != null) {
        elements.add(new ASN1Boolean(TYPE_INCLUDE_BINARY_FILES, includeBinaryFiles));
    }
    final Boolean includeExtensionSource = properties.getIncludeExtensionSource();
    if (includeExtensionSource != null) {
        elements.add(new ASN1Boolean(TYPE_INCLUDE_EXTENSION_SOURCE, includeExtensionSource));
    }
    final Boolean useSequentialMode = properties.getUseSequentialMode();
    if (useSequentialMode != null) {
        elements.add(new ASN1Boolean(TYPE_USE_SEQUENTIAL_MODE, useSequentialMode));
    }
    final CollectSupportDataSecurityLevel securityLevel = properties.getSecurityLevel();
    if (securityLevel != null) {
        final int securityLevelIntValue;
        switch(securityLevel) {
            case NONE:
                securityLevelIntValue = SECURITY_LEVEL_VALUE_NONE;
                break;
            case OBSCURE_SECRETS:
                securityLevelIntValue = SECURITY_LEVEL_VALUE_OBSCURE_SECRETS;
                break;
            case MAXIMUM:
                securityLevelIntValue = SECURITY_LEVEL_VALUE_MAXIMUM;
                break;
            default:
                throw new LDAPRuntimeException(new LDAPException(ResultCode.LOCAL_ERROR, ERR_CSD_REQUEST_UNSUPPORTED_SECURITY_LEVEL.get(securityLevel.getName())));
        }
        elements.add(new ASN1Enumerated(TYPE_SECURITY_LEVEL, securityLevelIntValue));
    }
    final Integer jstackCount = properties.getJStackCount();
    if (jstackCount != null) {
        elements.add(new ASN1Integer(TYPE_JSTACK_COUNT, jstackCount));
    }
    final Integer reportCount = properties.getReportCount();
    if (reportCount != null) {
        elements.add(new ASN1Integer(TYPE_REPORT_COUNT, reportCount));
    }
    final Integer reportIntervalSeconds = properties.getReportIntervalSeconds();
    if (reportIntervalSeconds != null) {
        elements.add(new ASN1Integer(TYPE_REPORT_INTERVAL_SECONDS, reportIntervalSeconds));
    }
    final CollectSupportDataLogCaptureWindow logCaptureWindow = properties.getLogCaptureWindow();
    if (logCaptureWindow != null) {
        elements.add(new ASN1Element(TYPE_LOG_CAPTURE_WINDOW, logCaptureWindow.encode().encode()));
    }
    final String comment = properties.getComment();
    if (comment != null) {
        elements.add(new ASN1OctetString(TYPE_COMMENT, comment));
    }
    final String proxyToServerAddress = properties.getProxyToServerAddress();
    if (proxyToServerAddress != null) {
        elements.add(new ASN1Sequence(TYPE_PROXY_TO_SERVER, new ASN1OctetString(proxyToServerAddress), new ASN1Integer(properties.getProxyToServerPort())));
    }
    final Integer maximumFragmentSizeBytes = properties.getMaximumFragmentSizeBytes();
    if (maximumFragmentSizeBytes != null) {
        elements.add(new ASN1Integer(TYPE_MAXIMUM_FRAGMENT_SIZE_BYTES, maximumFragmentSizeBytes));
    }
    return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ArrayList(java.util.ArrayList) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Integer(com.unboundid.asn1.ASN1Integer) LDAPRuntimeException(com.unboundid.ldap.sdk.LDAPRuntimeException) ASN1Integer(com.unboundid.asn1.ASN1Integer) CollectSupportDataSecurityLevel(com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) LDAPException(com.unboundid.ldap.sdk.LDAPException) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) NotNull(com.unboundid.util.NotNull)

Aggregations

CollectSupportDataSecurityLevel (com.unboundid.ldap.sdk.unboundidds.tasks.CollectSupportDataSecurityLevel)3 Test (org.testng.annotations.Test)2 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)1 ASN1Element (com.unboundid.asn1.ASN1Element)1 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)1 ASN1Integer (com.unboundid.asn1.ASN1Integer)1 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 LDAPRuntimeException (com.unboundid.ldap.sdk.LDAPRuntimeException)1 NotNull (com.unboundid.util.NotNull)1 ArrayList (java.util.ArrayList)1