| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.extensions.PasswordPolicyStateExtendedOperation.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_SEND_REQUEST_EXTOP.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_SEND_REQUEST_EXTOP.get(getExceptionMessage(e))); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | | |
| | |
| | | LDAPMessage responseMessage = ldapReader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWPSTATE_CONNECTION_CLOSED_READING_RESPONSE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_PWPSTATE_CONNECTION_CLOSED_READING_RESPONSE.get()); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | |
| | | int resultCode = extendedResponse.getResultCode(); |
| | | if (resultCode != LDAPResultCode.SUCCESS) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWPSTATE_REQUEST_FAILED.get(resultCode, |
| | | LDAPResultCode.toString(resultCode), |
| | | extendedResponse.getErrorMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_REQUEST_FAILED.get( |
| | | resultCode, LDAPResultCode.toString(resultCode), extendedResponse.getErrorMessage())); |
| | | return resultCode; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_OP.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_OP.get(getExceptionMessage(e))); |
| | | continue; |
| | | } |
| | | |
| | |
| | | |
| | | default: |
| | | message = ERR_PWPSTATE_INVALID_RESPONSE_OP_TYPE.get(opType); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, message); |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_MESSAGE.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_MESSAGE.get(getExceptionMessage(e))); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | | // If we've gotten here, then everything completed successfully. |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // return an error. |
| | | if (bindPW.isPresent() && bindPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | bindPW.getLongIdentifier(), |
| | | bindPWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, |
| | | ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | // If both a key store password and key store password file were provided, |
| | | // then return an error. |
| | | if (keyStorePW.isPresent() && keyStorePWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | keyStorePW.getLongIdentifier(), |
| | | keyStorePWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | keyStorePW.getLongIdentifier(), keyStorePWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // provided, then return an error. |
| | | if (trustStorePW.isPresent() && trustStorePWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | trustStorePW.getLongIdentifier(), |
| | | trustStorePWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | trustStorePW.getLongIdentifier(), trustStorePWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | connectionOptions.setSSLConnectionFactory(sslConnectionFactory); |
| | | } catch (SSLConnectionException sce) { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_INITIALIZE_SSL.get( |
| | | sce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_INITIALIZE_SSL.get(sce.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | int equalPos = s.indexOf('='); |
| | | if (equalPos <= 0) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_PARSE_SASL_OPTION.get(s); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_PARSE_SASL_OPTION.get(s)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (mechanism == null) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_SASL_MECHANISM.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_NO_SASL_MECHANISM.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | connectionOptions.setSASLMechanism(mechanism); |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DETERMINE_PORT.get( |
| | | port.getLongIdentifier(), |
| | | ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_DETERMINE_PORT.get(port.getLongIdentifier(), ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | |
| | | message = ERR_PWPSTATE_CANNOT_CONNECT.get(hostPort, |
| | | lce.getMessage()); |
| | | } |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR; |
| | | printWrappedText(err, message); |
| | | return CLIENT_SIDE_CONNECT_ERROR; |
| | | } |
| | | |
| | | ldapReader = connection.getLDAPReader(); |
| | | ldapWriter = connection.getLDAPWriter(); |
| | | |
| | | return LDAPResultCode.SUCCESS; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |
| | |
| | | SubCommand subCommand = argParser.getSubCommand(); |
| | | if (subCommand == null) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_SUBCOMMAND.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_NO_SUBCOMMAND.get()); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | String subCommandName = subCommand.getName(); |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_BOOLEAN_VALUE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_NO_BOOLEAN_VALUE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else if (subCommandName.equals(SC_CLEAR_ACCOUNT_DISABLED_STATE)) |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_BOOLEAN_VALUE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_NO_BOOLEAN_VALUE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else if(subCommandName.equals(SC_CLEAR_PASSWORD_RESET_STATE)) |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_INVALID_SUBCOMMAND.get(subCommandName); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_INVALID_SUBCOMMAND.get(subCommandName)); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | return LDAPResultCode.SUCCESS; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |