| | |
| | | /** Suffix for log files. */ |
| | | static public final String LOG_FILE_SUFFIX = ".log"; |
| | | |
| | | /** Maximum number of connection attempts. */ |
| | | private final int MAX_CONNECTION_RETRY =3; |
| | | |
| | | /** |
| | | * The enumeration containing the different return codes that the command-line |
| | | * can have. |
| | |
| | | /** |
| | | * User cancelled (for instance not accepting the certificate proposed). |
| | | */ |
| | | USER_CANCELLED(3); |
| | | USER_CANCELLED(3), |
| | | /** |
| | | * Too many connection failure. |
| | | */ |
| | | ERROR_TOO_MANY_CONNECTION_FAILURE(4); |
| | | |
| | | private int returnCode; |
| | | private ErrorReturnCode(int returnCode) |
| | |
| | | } |
| | | |
| | | InitialLdapContext ctx = null; |
| | | while (!connected && !cancelled) |
| | | int remainingRetry = MAX_CONNECTION_RETRY; |
| | | while (!connected && !cancelled && (remainingRetry > 0)) |
| | | { |
| | | remainingRetry--; |
| | | if (prompted) |
| | | { |
| | | printLineBreak(); |
| | |
| | | { |
| | | return ErrorReturnCode.USER_CANCELLED.getReturnCode(); |
| | | } |
| | | else |
| | | if (remainingRetry <= 0) |
| | | { |
| | | printErrorMessage( |
| | | ERR_STATUS_CLI_TOO_MANY_CONNECTION_ATTEMPT.get()); |
| | | return ErrorReturnCode.ERROR_TOO_MANY_CONNECTION_FAILURE |
| | | .getReturnCode(); |
| | | } |
| | | } |
| | | else |
| | | { |