| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.PasswordPolicyState; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPClientConnection; |
| | | import org.opends.server.types.*; |
| | |
| | | public class SASLContext implements CallbackHandler, |
| | | PrivilegedExceptionAction<Boolean> |
| | | { |
| | | |
| | | // The tracer object for the debug logger. |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | catch (final SaslException ex) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ex); |
| | | } |
| | | logger.traceException(ex); |
| | | final GSSException gex = (GSSException) ex.getCause(); |
| | | |
| | | final LocalizableMessage msg; |
| | |
| | | } |
| | | catch (final SaslException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | |
| | | final LocalizableMessage msg = ERR_SASL_PROTOCOL_ERROR.get(mechanism, |
| | | getExceptionMessage(e)); |
| | |
| | | } |
| | | catch (final SaslException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final SaslException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | |
| | | final LocalizableMessage msg = ERR_SASL_PROTOCOL_ERROR.get(mechanism, |
| | | getExceptionMessage(e)); |
| | |
| | | } |
| | | catch (final SaslException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | final LocalizableMessage msg = ERR_SASL_PROTOCOL_ERROR.get(mechanism, |
| | | getExceptionMessage(e)); |
| | | handleError(msg); |
| | |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final PrivilegedActionException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | final LocalizableMessage msg = ERR_SASL_PROTOCOL_ERROR.get(mechanism, |
| | | getExceptionMessage(e)); |
| | | handleError(msg); |
| | |
| | | } |
| | | catch (final DirectoryException de) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, de); |
| | | } |
| | | logger.traceException(de); |
| | | setCallbackMsg(ERR_SASL_CANNOT_MAP_AUTHENTRY.get(authid, |
| | | de.getMessage())); |
| | | callback.setAuthorized(false); |
| | |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASL_AUTHZID_INVALID_DN.get(responseAuthzID, |
| | | e.getMessageObject())); |
| | | callback.setAuthorized(false); |
| | |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASL_AUTHZID_CANNOT_GET_ENTRY.get( |
| | | String.valueOf(authzDN), e.getMessageObject())); |
| | | callback.setAuthorized(false); |
| | |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASL_AUTHZID_NO_MAPPED_ENTRY.get(authzid)); |
| | | callback.setAuthorized(false); |
| | | return; |
| | |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASL_CANNOT_GET_ENTRY_BY_DN.get( |
| | | String.valueOf(userDN), SASL_MECHANISM_DIGEST_MD5, |
| | | e.getMessageObject())); |
| | |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASL_CANNOT_DECODE_USERNAME_AS_DN.get(mechanism, |
| | | userName, e.getMessageObject())); |
| | | return; |
| | |
| | | } |
| | | catch (final DirectoryException e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASLDIGESTMD5_CANNOT_MAP_USERNAME.get( |
| | | String.valueOf(userName), e.getMessageObject())); |
| | | } |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | setCallbackMsg(ERR_SASL_CANNOT_GET_REVERSIBLE_PASSWORDS.get( |
| | | String.valueOf(authEntry.getName()), mechanism, String.valueOf(e))); |
| | | return; |