| | |
| | | import java.util.Map; |
| | | import java.util.StringTokenizer; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import javax.security.auth.Subject; |
| | | import javax.security.auth.callback.Callback; |
| | | import javax.security.auth.callback.CallbackHandler; |
| | |
| | | import javax.security.sasl.Sasl; |
| | | import javax.security.sasl.SaslClient; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.util.Base64; |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND.get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException( LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException( ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_SASL_MECHANISM.get(); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNSUPPORTED_SASL_MECHANISM.get(mechanism); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_AUTH_UNKNOWN, message); |
| | | ReturnCode.CLIENT_SIDE_AUTH_UNKNOWN, message); |
| | | } |
| | | } |
| | | |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_TRACE_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_ANONYMOUS); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_ANONYMOUS, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_ANONYMOUS, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage1.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse1 = |
| | | responseMessage1.getBindResponseProtocolOp(); |
| | | int resultCode1 = bindResponse1.getResultCode(); |
| | | if (resultCode1 != LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | if (resultCode1 != ReturnCode.SASL_BIND_IN_PROGRESS.get()) |
| | | { |
| | | LocalizableMessage errorMessage = bindResponse1.getErrorMessage(); |
| | | if (errorMessage == null) |
| | |
| | | |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE. |
| | | get(SASL_MECHANISM_CRAM_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), errorMessage); |
| | | ReturnCode.get(resultCode1), errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, message, |
| | | bindResponse1.getMatchedDN(), null); |
| | | } |
| | |
| | | if (serverChallenge == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_CRAMMD5_SERVER_CREDENTIALS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage2.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse2 = |
| | | responseMessage2.getBindResponseProtocolOp(); |
| | | int resultCode2 = bindResponse2.getResultCode(); |
| | | if (resultCode2 == LDAPResultCode.SUCCESS) |
| | | if (resultCode2 == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_REALM_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_QOP_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | { |
| | | // FIXME -- Add support for integrity and confidentiality. |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED.get(qop); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal value. |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_INVALID_QOP.get(qop); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGEST_URI_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage1.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse1 = |
| | | responseMessage1.getBindResponseProtocolOp(); |
| | | int resultCode1 = bindResponse1.getResultCode(); |
| | | if (resultCode1 != LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | if (resultCode1 != ReturnCode.SASL_BIND_IN_PROGRESS.get()) |
| | | { |
| | | LocalizableMessage errorMessage = bindResponse1.getErrorMessage(); |
| | | if (errorMessage == null) |
| | |
| | | |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE. |
| | | get(SASL_MECHANISM_DIGEST_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), errorMessage); |
| | | ReturnCode.get(resultCode1), errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, message, |
| | | bindResponse1.getMatchedDN(), null); |
| | | } |
| | |
| | | if (serverCredentials == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_DIGESTMD5_SERVER_CREDENTIALS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_TOKEN_IN_CREDENTIALS.get( |
| | | credString, pos); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CHARSET.get(tokenValue); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | useUTF8 = true; |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_REQUESTED_QOP_NOT_SUPPORTED_BY_SERVER. |
| | | get(qop, tokenValue); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (nonce == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_NO_NONCE.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_CANNOT_CREATE_RESPONSE_DIGEST. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage2.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse2 = |
| | | responseMessage2.getBindResponseProtocolOp(); |
| | | int resultCode2 = bindResponse2.getResultCode(); |
| | | if (resultCode2 != LDAPResultCode.SUCCESS) |
| | | if (resultCode2 != ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Add support for referrals. |
| | | |
| | |
| | | if (rspAuthCreds == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | String credStr = toLowerCase(rspAuthCreds.toString()); |
| | | if (! credStr.startsWith("rspauth=")) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_COULD_NOT_DECODE_RSPAUTH.get( |
| | | getExceptionMessage(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | byte[] clientRspAuth; |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_COULD_NOT_CALCULATE_RSPAUTH.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | if (! Arrays.equals(serverRspAuth, clientRspAuth)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_RSPAUTH_MISMATCH.get(); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | |
| | | // is not fine. |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get((pos-2)); |
| | | throw new LDAPException(LDAPResultCode.INVALID_CREDENTIALS, |
| | | throw new LDAPException(ReturnCode.INVALID_CREDENTIALS.get(), |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_ALLOWED_SASL_PROPERTIES.get(SASL_MECHANISM_EXTERNAL); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_EXTERNAL, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_EXTERNAL, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_DECODING_ERROR, message, e); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_KDC_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_QOP_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | // FIXME -- Add support for integrity and confidentiality. |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED.get(gssapiQoP); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal value. |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_INVALID_QOP.get(gssapiQoP); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_REALM_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get(name, SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_JAAS_CONFIG.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | System.setProperty(JAAS_PROPERTY_CONFIG_FILE, configFileName); |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | try |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_REMOTE_AUTHENTICATION_FAILED.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get(name, SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_PLAIN, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_PLAIN, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NONSASL_RUN_INVOCATION.get(getBacktrace()); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | else if (saslMechanism.equals(SASL_MECHANISM_GSSAPI)) |
| | | { |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_SASL_CLIENT.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_INITIAL_CHALLENGE. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // We should be done after this, but we still need to look for and |
| | | // handle the server SASL credentials. |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_GSSAPI_UNEXPECTED_SUCCESS_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | else if (resultCode == LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | else if (resultCode == ReturnCode.SASL_BIND_IN_PROGRESS.get()) |
| | | { |
| | | // Read the response and process the server SASL credentials. |
| | | ByteString serverSASLCredentials = |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE |
| | | .get(getExceptionMessage(ae)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, message, ae); |
| | | ReturnCode.CLIENT_SIDE_DECODING_ERROR, message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | } |
| | | else |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RUN_INVOCATION.get( |
| | | saslMechanism, getBacktrace()); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST.get(getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST.get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if (responseMessage.getProtocolOpType() != OP_TYPE_EXTENDED_RESPONSE) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | // response and the value would be the authorization ID. However, first |
| | | // check that it was successful. If it was not, then fail. |
| | | int resultCode = extendedResponse.getResultCode(); |
| | | if (resultCode != LDAPResultCode.SUCCESS) |
| | | if (resultCode != ReturnCode.SUCCESS.get()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_WHOAMI_FAILED.get(); |
| | | throw new LDAPException(resultCode, extendedResponse.getErrorMessage(), |