| | |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | 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. |
| | | CharacterSetPasswordValidatorCfg config = currentConfig; |
| | |
| | | |
| | | if ((! found) && (! config.isAllowUnclassifiedCharacters())) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_ILLEGAL_CHARACTER; |
| | | invalidReason.append(getMessage(msgID, String.valueOf(c))); |
| | | invalidReason.append(ERR_CHARSET_VALIDATOR_ILLEGAL_CHARACTER.get( |
| | | String.valueOf(c))); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | Integer passwordCount = counts.get(characterSet); |
| | | if ((passwordCount == null) || (passwordCount < minimumCount)) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_TOO_FEW_CHARS_FROM_SET; |
| | | invalidReason.append(getMessage(msgID, characterSet, minimumCount)); |
| | | invalidReason.append(ERR_CHARSET_VALIDATOR_TOO_FEW_CHARS_FROM_SET.get( |
| | | characterSet, minimumCount)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | int colonPos = definition.indexOf(':'); |
| | | if (colonPos <= 0) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_NO_COLON; |
| | | String message = getMessage(msgID, definition); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CHARSET_VALIDATOR_NO_COLON.get(definition); |
| | | throw new ConfigException(message); |
| | | } |
| | | else if (colonPos == (definition.length() - 1)) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_NO_CHARS; |
| | | String message = getMessage(msgID, definition); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CHARSET_VALIDATOR_NO_CHARS.get(definition); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | int minCount; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_INVALID_COUNT; |
| | | String message = getMessage(msgID, definition); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CHARSET_VALIDATOR_INVALID_COUNT.get(definition); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | if (minCount <= 0) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_INVALID_COUNT; |
| | | String message = getMessage(msgID, definition); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CHARSET_VALIDATOR_INVALID_COUNT.get(definition); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | String characterSet = definition.substring(colonPos+1); |
| | |
| | | char c = characterSet.charAt(i); |
| | | if (usedCharacters.contains(c)) |
| | | { |
| | | int msgID = MSGID_CHARSET_VALIDATOR_DUPLICATE_CHAR; |
| | | String message = getMessage(msgID, definition, String.valueOf(c)); |
| | | throw new ConfigException(msgID, message); |
| | | Message message = ERR_CHARSET_VALIDATOR_DUPLICATE_CHAR.get( |
| | | definition, String.valueOf(c)); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | usedCharacters.add(c); |
| | |
| | | */ |
| | | @Override() |
| | | public boolean isConfigurationAcceptable(PasswordValidatorCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | CharacterSetPasswordValidatorCfg config = |
| | | (CharacterSetPasswordValidatorCfg) configuration; |
| | |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | CharacterSetPasswordValidatorCfg configuration, |
| | | List<String> unacceptableReasons) |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | // Make sure that we can process the defined character sets. If so, then |
| | | // we'll accept the new configuration. |
| | |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | unacceptableReasons.add(ce.getMessage()); |
| | | unacceptableReasons.add(ce.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | CharacterSetPasswordValidatorCfg configuration) |
| | | { |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<String> messages = new ArrayList<String>(); |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | ArrayList<Message> messages = new ArrayList<Message>(); |
| | | |
| | | |
| | | // Make sure that we can process the defined character sets. If so, then |