| | |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The identity mapper that will be used to map ID strings to user entries.*/ |
| | | /** The identity mapper that will be used to map ID strings to user entries. */ |
| | | private IdentityMapper<?> identityMapper; |
| | | |
| | | /** The current configuration for this SASL mechanism handler. */ |
| | | private PlainSASLMechanismHandlerCfg currentConfig; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this SASL mechanism handler. No initialization |
| | | * should be done in this method, as it should all be performed in the |
| | |
| | | super(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSASLMechanismHandler( |
| | | PlainSASLMechanismHandlerCfg configuration) |
| | |
| | | configuration.addPlainChangeListener(this); |
| | | currentConfig = configuration; |
| | | |
| | | |
| | | // Get the identity mapper that should be used to find users. |
| | | DN identityMapperDN = configuration.getIdentityMapperDN(); |
| | | identityMapper = DirectoryServer.getIdentityMapper(identityMapperDN); |
| | | |
| | | |
| | | DirectoryServer.registerSASLMechanismHandler(SASL_MECHANISM_PLAIN, this); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeSASLMechanismHandler() |
| | | { |
| | |
| | | DirectoryServer.deregisterSASLMechanismHandler(SASL_MECHANISM_PLAIN); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void processSASLBind(BindOperation bindOperation) |
| | | { |
| | |
| | | authzID = credString.substring(0, nullPos1); |
| | | } |
| | | |
| | | |
| | | int nullPos2 = credString.indexOf('\u0000', nullPos1+1); |
| | | if (nullPos2 < 0) |
| | | { |
| | |
| | | authcID = credString.substring(nullPos1+1, nullPos2); |
| | | password = credString.substring(nullPos2+1); |
| | | |
| | | |
| | | // Get the user entry for the authentication ID. Allow for an |
| | | // authentication ID that is just a username (as per the SASL PLAIN spec), |
| | | // but also allow a value in the authzid form specified in RFC 2829. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // At this point, we should have a user entry. If we don't then fail. |
| | | if (userEntry == null) |
| | | { |
| | |
| | | bindOperation.setSASLAuthUserEntry(userEntry); |
| | | } |
| | | |
| | | |
| | | // If an authorization ID was provided, then make sure that it is |
| | | // acceptable. |
| | | Entry authZEntry = userEntry; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Get the password policy for the user and use it to determine if the |
| | | // provided password was correct. |
| | | try |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the authentication was successful. |
| | | bindOperation.setResultCode(ResultCode.SUCCESS); |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isPasswordBased(String mechanism) |
| | | { |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isSecure(String mechanism) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable( |
| | | SASLMechanismHandlerCfg configuration, |
| | |
| | | return isConfigurationChangeAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | PlainSASLMechanismHandlerCfg configuration, |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | PlainSASLMechanismHandlerCfg configuration) |