class Authenticator {

  public void close()
  {
    if (dnResolver instanceof ConnectionFactoryManager) {
      closeConnectionFactoryManagers((ConnectionFactoryManager) dnResolver);
    } else if (dnResolver instanceof AggregateDnResolver) {
      final Map<String, DnResolver> resolvers = ((AggregateDnResolver) dnResolver).getDnResolvers();
      if (resolvers != null) {
        closeConnectionFactoryManagers(resolvers.values().toArray(new ConnectionFactoryManager[0]));
      }
    }
    if (authenticationHandler instanceof ConnectionFactoryManager) {
      closeConnectionFactoryManagers((ConnectionFactoryManager) authenticationHandler);
    } else if (authenticationHandler instanceof AggregateAuthenticationHandler) {
      final Map<String, AuthenticationHandler> handlers =
        ((AggregateAuthenticationHandler) authenticationHandler).getAuthenticationHandlers();
      if (handlers != null) {
        closeConnectionFactoryManagers(handlers.values().toArray(new ConnectionFactoryManager[0]));
      }
    }
    if (entryResolver instanceof ConnectionFactoryManager) {
      closeConnectionFactoryManagers((ConnectionFactoryManager) entryResolver);
    } else if (entryResolver instanceof AggregateEntryResolver) {
      final Map<String, EntryResolver> resolvers = ((AggregateEntryResolver) entryResolver).getEntryResolvers();
      if (resolvers != null) {
        closeConnectionFactoryManagers(resolvers.values().toArray(new ConnectionFactoryManager[0]));
      }
    }
  }

  public  Authenticator();
  public  Authenticator(final DnResolver resolver, final AuthenticationHandler handler);

}