| | |
| | | import javax.net.ssl.X509TrustManager; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import org.forgerock.opendj.ldap.ConnectionFactory; |
| | | import org.forgerock.opendj.ldap.KeyManagers; |
| | | import org.forgerock.opendj.ldap.LDAPConnectionFactory; |
| | |
| | | /** |
| | | * A connection factory designed for use with command line tools. |
| | | */ |
| | | public class ConnectionFactoryProvider extends AbstractAuthenticatedConnectionFactory { |
| | | public class ConnectionFactoryProvider { |
| | | /** |
| | | * The Logger. |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the connection factory. |
| | | * Returns the host name. |
| | | * |
| | | * @return The host name value. |
| | | */ |
| | | public String getHostname() { |
| | | if (hostNameArg.isPresent()) { |
| | | return hostNameArg.getValue(); |
| | | } |
| | | return hostNameArg.getDefaultValue(); |
| | | } |
| | | |
| | | /** |
| | | * Get the port which has to be used for the command. |
| | | * |
| | | * @return The port specified by the command line argument, or the default value, if not specified. |
| | | */ |
| | | public int getPort() { |
| | | if (portArg.isPresent()) { |
| | | try { |
| | | return portArg.getIntValue(); |
| | | } catch (ArgumentException e) { |
| | | return Integer.valueOf(portArg.getDefaultValue()); |
| | | } |
| | | } |
| | | return Integer.valueOf(portArg.getDefaultValue()); |
| | | } |
| | | |
| | | /** |
| | | * Checks if any conflicting arguments are present, build the connection with |
| | | * selected arguments and returns the connection factory. |
| | | * |
| | | * @return The connection factory. |
| | | * @throws ArgumentException |
| | | * If an error occurs during the parsing of the arguments. |
| | | * If an error occurs during the parsing of the arguments. (conflicting |
| | | * arguments or if an error occurs during building SSL context). |
| | | */ |
| | | public ConnectionFactory getConnectionFactory() throws ArgumentException { |
| | | if (connFactory == null) { |
| | |
| | | authenticatedConnFactory = getConnectionFactory(); |
| | | final BindRequest bindRequest = getBindRequest(); |
| | | if (bindRequest != null) { |
| | | authenticatedConnFactory = newAuthenticatedConnectionFactory(authenticatedConnFactory, bindRequest); |
| | | authenticatedConnFactory = new AuthenticatedConnectionFactory(authenticatedConnFactory, bindRequest); |
| | | } |
| | | } |
| | | return authenticatedConnFactory; |
| | |
| | | |
| | | return option.substring(equalPos + 1, option.length()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, |
| | | final BindRequest request) throws ArgumentException { |
| | | return null; |
| | | } |
| | | } |