Search in sources :

Example 1 with StartTlsRequestImpl

use of org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl in project directory-ldap-api by apache.

the class ApiLdapExtrasCodecApiOsgiTest method useBundleClasses.

@Override
protected void useBundleClasses() throws Exception {
    SynchronizationModeEnum.REFRESH_AND_PERSIST.getValue();
    new AdDirSyncImpl().getOid();
    new AdShowDeletedImpl().getOid();
    new AdPolicyHintsImpl().getOid();
    new ChangeNotificationsImpl().getOid();
    new PermissiveModifyImpl().getOid();
    new PasswordPolicyImpl().getOid();
    new PasswordPolicyResponseImpl().getGraceAuthNRemaining();
    new SyncDoneValueImpl().getOid();
    new SyncRequestValueImpl().getOid();
    new SyncStateValueImpl(true).getCookie();
    new VirtualListViewRequestImpl().getOid();
    new VirtualListViewResponseImpl().getOid();
    new PasswordModifyRequestImpl().getUserIdentity();
    new PasswordModifyResponseImpl(5).setResponseName("foo");
    new WhoAmIRequestImpl();
    new WhoAmIResponseImpl().setDn(new Dn("uid=admin,ou=system"));
    new StartTlsRequestImpl();
    new StartTlsResponseImpl();
    new StartTransactionRequestImpl();
    new StartTransactionResponseImpl();
}
Also used : PasswordPolicyImpl(org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyImpl) AdPolicyHintsImpl(org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHintsImpl) SyncStateValueImpl(org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValueImpl) WhoAmIRequestImpl(org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIRequestImpl) AdDirSyncImpl(org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncImpl) AdShowDeletedImpl(org.apache.directory.api.ldap.extras.controls.ad.AdShowDeletedImpl) WhoAmIResponseImpl(org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIResponseImpl) SyncRequestValueImpl(org.apache.directory.api.ldap.extras.controls.syncrepl.syncRequest.SyncRequestValueImpl) Dn(org.apache.directory.api.ldap.model.name.Dn) VirtualListViewRequestImpl(org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewRequestImpl) PermissiveModifyImpl(org.apache.directory.api.ldap.extras.controls.permissiveModify.PermissiveModifyImpl) StartTlsResponseImpl(org.apache.directory.api.ldap.extras.extended.startTls.StartTlsResponseImpl) VirtualListViewResponseImpl(org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponseImpl) PasswordModifyRequestImpl(org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyRequestImpl) StartTlsRequestImpl(org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl) PasswordPolicyResponseImpl(org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponseImpl) SyncDoneValueImpl(org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValueImpl) ChangeNotificationsImpl(org.apache.directory.api.ldap.extras.controls.changeNotifications.ChangeNotificationsImpl) StartTransactionRequestImpl(org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionRequestImpl) PasswordModifyResponseImpl(org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyResponseImpl) StartTransactionResponseImpl(org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponseImpl)

Example 2 with StartTlsRequestImpl

use of org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl in project directory-ldap-api by apache.

the class LdapNetworkConnection method startTls.

/**
 * Sends the StartTLS extended request to server and adds a security layer
 * upon receiving a response with successful result. Note that we will use
 * the default LDAP connection.
 *
 * @throws LdapException If the StartTLS operation failed
 */
public void startTls() throws LdapException {
    try {
        if (config.isUseSsl()) {
            throw new LdapException("Cannot use TLS when the useSsl flag is set true in the configuration");
        }
        // try to connect, if we aren't already connected.
        connect();
        checkSession();
        IoFilter sslFilter = ldapSession.getFilterChain().get(SSL_FILTER_KEY);
        if (sslFilter != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(I18n.msg(I18n.MSG_03222_LDAP_ALREADY_USING_START_TLS));
            }
            return;
        }
        ExtendedResponse resp = extended(new StartTlsRequestImpl());
        LdapResult result = resp.getLdapResult();
        if (result.getResultCode() == ResultCodeEnum.SUCCESS) {
            addSslFilter();
        } else {
            throw new LdapOperationException(result.getResultCode(), result.getDiagnosticMessage());
        }
    } catch (LdapException e) {
        throw e;
    } catch (Exception e) {
        throw new LdapException(e);
    }
}
Also used : LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) ExtendedResponse(org.apache.directory.api.ldap.model.message.ExtendedResponse) StartTlsRequestImpl(org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl) LdapOperationException(org.apache.directory.api.ldap.model.exception.LdapOperationException) IoFilter(org.apache.mina.core.filterchain.IoFilter) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) UnresolvedAddressException(java.nio.channels.UnresolvedAddressException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) LdapInvalidDnException(org.apache.directory.api.ldap.model.exception.LdapInvalidDnException) InvalidConnectionException(org.apache.directory.ldap.client.api.exception.InvalidConnectionException) LdapOperationException(org.apache.directory.api.ldap.model.exception.LdapOperationException) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) MessageEncoderException(org.apache.directory.api.ldap.codec.api.MessageEncoderException) CursorException(org.apache.directory.api.ldap.model.cursor.CursorException) DecoderException(org.apache.directory.api.asn1.DecoderException) LdapNoPermissionException(org.apache.directory.api.ldap.model.exception.LdapNoPermissionException) LdapOtherException(org.apache.directory.api.ldap.model.exception.LdapOtherException) ProtocolEncoderException(org.apache.mina.filter.codec.ProtocolEncoderException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Aggregations

StartTlsRequestImpl (org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl)2 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 UnresolvedAddressException (java.nio.channels.UnresolvedAddressException)1 DecoderException (org.apache.directory.api.asn1.DecoderException)1 MessageEncoderException (org.apache.directory.api.ldap.codec.api.MessageEncoderException)1 AdDirSyncImpl (org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncImpl)1 AdPolicyHintsImpl (org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHintsImpl)1 AdShowDeletedImpl (org.apache.directory.api.ldap.extras.controls.ad.AdShowDeletedImpl)1 ChangeNotificationsImpl (org.apache.directory.api.ldap.extras.controls.changeNotifications.ChangeNotificationsImpl)1 PermissiveModifyImpl (org.apache.directory.api.ldap.extras.controls.permissiveModify.PermissiveModifyImpl)1 PasswordPolicyImpl (org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyImpl)1 PasswordPolicyResponseImpl (org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponseImpl)1 SyncDoneValueImpl (org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValueImpl)1 SyncRequestValueImpl (org.apache.directory.api.ldap.extras.controls.syncrepl.syncRequest.SyncRequestValueImpl)1 SyncStateValueImpl (org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValueImpl)1 VirtualListViewRequestImpl (org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewRequestImpl)1 VirtualListViewResponseImpl (org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponseImpl)1 PasswordModifyRequestImpl (org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyRequestImpl)1 PasswordModifyResponseImpl (org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyResponseImpl)1