LDAPClientFilter.java revision 16bdb19cdda5201d272cd6ca5bf876c88493327c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2010 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS.
*/
/**
* Grizzly filter implementation for decoding LDAP responses and handling client
* side logic for SSL and SASL operations over LDAP.
*/
final class LDAPClientFilter extends LDAPBaseFilter {
static final class ClientResponseHandler extends AbstractLDAPMessageHandler implements
private FilterChainContext context;
/**
* Creates a handler with the provided reader.
*
* @param reader
* LDAP reader to use for reading incoming messages
*/
}
}
/**
* Returns the LDAP reader.
*
* @return the reader to read incoming LDAP messages
*/
return this.reader;
}
if (ldapConnection != null) {
if (pendingRequest != null) {
return;
}
}
}
}
throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
if (pendingRequest instanceof BindResultLdapPromiseImpl) {
try {
// The server is expecting a multi stage
// bind response.
try {
final GenericBindRequest nextRequest =
} finally {
}
return;
}
} catch (final LdapException e) {
return;
} catch (final IOException e) {
// FIXME: I18N need to have a better error message.
// FIXME: Is this the best result code?
final Result errorResult =
"An error occurred during multi-stage authentication")
.setCause(e);
return;
}
final ConnectionSecurityLayer l =
if (l != null) {
// The connection needs to be secured by
// the SASL mechanism.
}
}
return;
}
}
}
}
@SuppressWarnings("unchecked")
throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
return;
}
}
}
}
@SuppressWarnings("unchecked")
if (ldapConnection != null) {
if (pendingRequest != null) {
return;
}
}
}
}
throws DecodeException, IOException {
if (ldapConnection != null) {
if (messageID == 0) {
// Unsolicited notification received.
// Treat this as a connection error.
} else {
}
} else {
if (pendingRequest != null) {
final ExtendedResultLdapPromiseImpl<?> extendedPromise =
try {
} catch (final DecodeException de) {
// FIXME: should the connection be closed as well?
}
} else {
}
}
}
}
}
throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
}
}
}
@SuppressWarnings("unchecked")
throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
return;
}
}
}
}
@SuppressWarnings("unchecked")
public void modifyResult(final int messageID, final Result result) throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
return;
}
}
}
}
@SuppressWarnings("unchecked")
if (ldapConnection != null) {
if (pendingRequest != null) {
} else {
}
}
}
}
throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
if (pendingRequest instanceof SearchResultLdapPromiseImpl) {
} else {
}
}
}
}
throws DecodeException, IOException {
if (ldapConnection != null) {
if (pendingRequest != null) {
if (pendingRequest instanceof SearchResultLdapPromiseImpl) {
} else {
}
}
}
}
/** Needed in order to expose type information. */
private <R extends ExtendedResult> void handleExtendedResult0(
try {
new EmptyCompletionHandler<SSLEngine>() {
conn.setBindOrStartTLSInProgress(false);
}
conn.setBindOrStartTLSInProgress(false);
}
});
return;
} catch (final IOException e) {
.setDiagnosticMessage(e.getMessage());
return;
}
}
}
}
/**
* Creates a client filter with provided options and max size of ASN1
* elements.
*
* @param options
* allow to control how request and responses are decoded
* @param maxASN1ElementSize
* The maximum BER element size, or <code>0</code> to indicate
* that there is no limit.
*/
super(options, maxASN1ElementSize);
}
if (!connection.isOpen()) {
// Grizzly doesn't not deregister the read interest from the
// selector so closing the connection results in an EOFException.
// Just ignore errors on closed connections.
return;
}
if (error instanceof EOFException) {
// FIXME: Is this the best result code?
} else {
// FIXME: what other sort of IOExceptions can be thrown?
// FIXME: Is this the best result code?
}
}
if (ldapConnection != null) {
}
return ctx.getInvokeAction();
}
final Result errorResult =
.setDiagnosticMessage(e.getMessage());
}
/**
* Returns the response handler associated to the provided connection and
* context.
* <p>
* If no handler exists yet for this context, a new one is created and
* recorded for the connection.
*
* @param ctx
* current filter chain context
* @return the response handler associated to the context, which can be a
* new one if no handler have been created yet
*/
.getTransport().getMemoryManager());
}
return handler;
}
/**
* Associate a LDAP connection to the provided Grizzly connection.
*
* @param connection
* Grizzly connection
* @param ldapConnection
* LDAP connection
*/
final GrizzlyLDAPConnection ldapConnection) {
}
}