| | |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import org.opends.messages.MessageBuilder; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | |
| | | public boolean passwordIsAcceptable(ByteString newPassword, |
| | | Set<ByteString> currentPasswords, |
| | | Operation operation, Entry userEntry, |
| | | StringBuilder invalidReason) |
| | | MessageBuilder invalidReason) |
| | | { |
| | | // Get a handle to the current configuration. |
| | | DictionaryPasswordValidatorCfg config = currentConfig; |
| | |
| | | |
| | | if (dictionary.contains(password)) |
| | | { |
| | | int msgID = MSGID_DICTIONARY_VALIDATOR_PASSWORD_IN_DICTIONARY; |
| | | invalidReason.append(getMessage(msgID)); |
| | | invalidReason.append( |
| | | ERR_DICTIONARY_VALIDATOR_PASSWORD_IN_DICTIONARY.get()); |
| | | return false; |
| | | } |
| | | |
| | |
| | | { |
| | | if (dictionary.contains(new StringBuilder(password).reverse().toString())) |
| | | { |
| | | int msgID = MSGID_DICTIONARY_VALIDATOR_PASSWORD_IN_DICTIONARY; |
| | | invalidReason.append(getMessage(msgID)); |
| | | invalidReason.append( |
| | | ERR_DICTIONARY_VALIDATOR_PASSWORD_IN_DICTIONARY.get()); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | File dictionaryFile = getFileForPath(configuration.getDictionaryFile()); |
| | | if (! dictionaryFile.exists()) |
| | | { |
| | | int msgID = MSGID_DICTIONARY_VALIDATOR_NO_SUCH_FILE; |
| | | String message = getMessage(msgID, configuration.getDictionaryFile()); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_DICTIONARY_VALIDATOR_NO_SUCH_FILE.get( |
| | | configuration.getDictionaryFile()); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_DICTIONARY_VALIDATOR_CANNOT_READ_FILE; |
| | | String message = getMessage(msgID, configuration.getDictionaryFile(), |
| | | String.valueOf(e)); |
| | | throw new InitializationException(msgID, message); |
| | | Message message = ERR_DICTIONARY_VALIDATOR_CANNOT_READ_FILE.get( |
| | | configuration.getDictionaryFile(), String.valueOf(e)); |
| | | throw new InitializationException(message); |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | @Override() |
| | | public boolean isConfigurationAcceptable(PasswordValidatorCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | DictionaryPasswordValidatorCfg config = |
| | | (DictionaryPasswordValidatorCfg) configuration; |
| | |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | DictionaryPasswordValidatorCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | // Make sure that we can load the dictionary. If so, then we'll accept the |
| | | // new configuration. |
| | |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | unacceptableReasons.add(ce.getMessage()); |
| | | unacceptableReasons.add(ce.getMessageObject()); |
| | | return false; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | unacceptableReasons.add(ie.getMessage()); |
| | | unacceptableReasons.add(ie.getMessageObject()); |
| | | return false; |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | ArrayList<Message> messages = new ArrayList<Message>(); |
| | | |
| | | |
| | | // Make sure we can load the dictionary. If we can, then activate the new |