| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.PasswordReader; |
| | | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | * specified SASL mechanism, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLProperties(String mechanism) |
| | | public static LinkedHashMap<String,Message> getSASLProperties( |
| | | String mechanism) |
| | | { |
| | | String upperName = toUpperCase(mechanism); |
| | | if (upperName.equals(SASL_MECHANISM_ANONYMOUS)) |
| | |
| | | } |
| | | else |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, |
| | | bindDN.stringValue())); |
| | | System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get( |
| | | bindDN.stringValue())); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | if (pwChars == null) |
| | | { |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND.get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // FIXME -- Add support for referrals. |
| | | |
| | | int msgID = MSGID_LDAPAUTH_SIMPLE_BIND_FAILED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_SIMPLE_BIND_FAILED.get(); |
| | | throw new LDAPException(resultCode, bindResponse.getErrorMessage(), |
| | | msgID, message, bindResponse.getMatchedDN(), null); |
| | | message, bindResponse.getMatchedDN(), null); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | if ((mechanism == null) || (mechanism.length() == 0)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_SASL_MECHANISM; |
| | | String message = getMessage(msgID); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_NO_SASL_MECHANISM.get(); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNSUPPORTED_SASL_MECHANISM; |
| | | String message = getMessage(msgID, mechanism); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_AUTH_UNKNOWN, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNSUPPORTED_SASL_MECHANISM.get(mechanism); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_AUTH_UNKNOWN, message); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_TRACE_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_TRACE_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_INVALID_SASL_PROPERTY; |
| | | String message = getMessage(msgID, name, SASL_MECHANISM_ANONYMOUS); |
| | | Message message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_ANONYMOUS); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_ANONYMOUS, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_ANONYMOUS, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_ANONYMOUS, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_ANONYMOUS, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, String.valueOf(responseMessage.getProtocolOp())); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // FIXME -- Add support for referrals. |
| | | |
| | | int msgID = MSGID_LDAPAUTH_SASL_BIND_FAILED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_ANONYMOUS); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_BIND_FAILED.get(SASL_MECHANISM_ANONYMOUS); |
| | | throw new LDAPException(resultCode, bindResponse.getErrorMessage(), |
| | | msgID, message, bindResponse.getMatchedDN(), null); |
| | | message, bindResponse.getMatchedDN(), null); |
| | | } |
| | | |
| | | |
| | |
| | | * SASL ANONYMOUS bind, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLAnonymousProperties() |
| | | public static LinkedHashMap<String, Message> getSASLAnonymousProperties() |
| | | { |
| | | LinkedHashMap<String,String> properties = |
| | | new LinkedHashMap<String,String>(1); |
| | | LinkedHashMap<String,Message> properties = |
| | | new LinkedHashMap<String,Message>(1); |
| | | |
| | | properties.put(SASL_PROPERTY_TRACE, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_TRACE)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_TRACE.get()); |
| | | |
| | | return properties; |
| | | } |
| | |
| | | // properties are allowed. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_SASL_PROPERTIES; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_INVALID_SASL_PROPERTY; |
| | | String message = getMessage(msgID, name, SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | // Make sure that the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SASL_AUTHID_REQUIRED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | // the user. |
| | | if (bindPassword == null) |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, authID)); |
| | | System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(authID)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | if (pwChars == null) |
| | | { |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage1 = reader.readMessage(); |
| | | if (responseMessage1 == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(ae)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(le)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message 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); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(responseMessage1.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage1.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | int resultCode1 = bindResponse1.getResultCode(); |
| | | if (resultCode1 != LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | { |
| | | String errorMessage = bindResponse1.getErrorMessage(); |
| | | Message errorMessage = bindResponse1.getErrorMessage(); |
| | | if (errorMessage == null) |
| | | { |
| | | errorMessage = ""; |
| | | errorMessage = Message.EMPTY; |
| | | } |
| | | |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), |
| | | errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, msgID, message, |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE. |
| | | get(SASL_MECHANISM_CRAM_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, message, |
| | | bindResponse1.getMatchedDN(), null); |
| | | } |
| | | |
| | |
| | | ASN1OctetString serverChallenge = bindResponse1.getServerSASLCredentials(); |
| | | if (serverChallenge == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_CRAMMD5_SERVER_CREDENTIALS; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_LDAPAUTH_NO_CRAMMD5_SERVER_CREDENTIALS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message 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); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage2 = reader.readMessage(); |
| | | if (responseMessage2 == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(ae)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(le)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5, |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message 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); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(responseMessage2.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage2.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // FIXME -- Add support for referrals. |
| | | |
| | | int msgID = MSGID_LDAPAUTH_SASL_BIND_FAILED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_CRAM_MD5); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_BIND_FAILED.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new LDAPException(resultCode2, bindResponse2.getErrorMessage(), |
| | | msgID, message, bindResponse2.getMatchedDN(), null); |
| | | message, bindResponse2.getMatchedDN(), null); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | | |
| | |
| | | * SASL CRAM-MD5 bind, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLCRAMMD5Properties() |
| | | public static LinkedHashMap<String,Message> getSASLCRAMMD5Properties() |
| | | { |
| | | LinkedHashMap<String,String> properties = |
| | | new LinkedHashMap<String,String>(1); |
| | | LinkedHashMap<String,Message> properties = |
| | | new LinkedHashMap<String,Message>(1); |
| | | |
| | | properties.put(SASL_PROPERTY_AUTHID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID.get()); |
| | | |
| | | return properties; |
| | | } |
| | |
| | | // QoP, digest URI, and authzID are optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_SASL_PROPERTIES; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_REALM_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_REALM_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_QOP_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_QOP_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | if (qop.equals("auth")) |
| | |
| | | else if (qop.equals("auth-int") || qop.equals("auth-conf")) |
| | | { |
| | | // FIXME -- Add support for integrity and confidentiality. |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED; |
| | | String message = getMessage(msgID, qop); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED.get(qop); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal value. |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_INVALID_QOP; |
| | | String message = getMessage(msgID, qop); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_INVALID_QOP.get(qop); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGEST_URI_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_DIGEST_URI_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHZID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_INVALID_SASL_PROPERTY; |
| | | String message = getMessage(msgID, name, SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | |
| | |
| | | // Make sure that the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SASL_AUTHID_REQUIRED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | | |
| | |
| | | // the user. |
| | | if (bindPassword == null) |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, authID)); |
| | | System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(authID)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | if (pwChars == null) |
| | | { |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage1 = reader.readMessage(); |
| | | if (responseMessage1 == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(ae)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(le)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message 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); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(responseMessage1.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage1.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | int resultCode1 = bindResponse1.getResultCode(); |
| | | if (resultCode1 != LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | { |
| | | String errorMessage = bindResponse1.getErrorMessage(); |
| | | Message errorMessage = bindResponse1.getErrorMessage(); |
| | | if (errorMessage == null) |
| | | { |
| | | errorMessage = ""; |
| | | errorMessage = Message.EMPTY; |
| | | } |
| | | |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), |
| | | errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, msgID, message, |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE. |
| | | get(SASL_MECHANISM_DIGEST_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, message, |
| | | bindResponse1.getMatchedDN(), null); |
| | | } |
| | | |
| | |
| | | bindResponse1.getServerSASLCredentials(); |
| | | if (serverCredentials == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_DIGESTMD5_SERVER_CREDENTIALS; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_LDAPAUTH_NO_DIGESTMD5_SERVER_CREDENTIALS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // This is bad because we're not at the end of the string but we don't |
| | | // have a name/value delimiter. |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_INVALID_TOKEN_IN_CREDENTIALS; |
| | | String message = getMessage(msgID, pos); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_TOKEN_IN_CREDENTIALS.get( |
| | | credString, pos); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | // The value must be the string "utf-8". If not, that's an error. |
| | | if (! tokenValue.equalsIgnoreCase("utf-8")) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_INVALID_CHARSET; |
| | | String message = getMessage(msgID, tokenValue); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CHARSET.get(tokenValue); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | useUTF8 = true; |
| | |
| | | |
| | | if (! qopModes.contains(qop)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_REQUESTED_QOP_NOT_SUPPORTED_BY_SERVER; |
| | | String message = getMessage(msgID, qop, tokenValue); |
| | | Message message = ERR_LDAPAUTH_REQUESTED_QOP_NOT_SUPPORTED_BY_SERVER. |
| | | get(qop, tokenValue); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | else |
| | |
| | | // Make sure that the nonce was included in the response from the server. |
| | | if (nonce == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_NO_NONCE; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_NO_NONCE.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_CANNOT_CREATE_RESPONSE_DIGEST; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_CANNOT_CREATE_RESPONSE_DIGEST. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage2 = reader.readMessage(); |
| | | if (responseMessage2 == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message 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); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(ae)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(le)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5, |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message 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); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(responseMessage2.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage2.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // FIXME -- Add support for referrals. |
| | | |
| | | int msgID = MSGID_LDAPAUTH_SASL_BIND_FAILED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_DIGEST_MD5); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_BIND_FAILED.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new LDAPException(resultCode2, bindResponse2.getErrorMessage(), |
| | | msgID, message, bindResponse2.getMatchedDN(), |
| | | message, bindResponse2.getMatchedDN(), |
| | | null); |
| | | } |
| | | |
| | |
| | | ASN1OctetString rspAuthCreds = bindResponse2.getServerSASLCredentials(); |
| | | if (rspAuthCreds == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | String credStr = toLowerCase(rspAuthCreds.stringValue()); |
| | | if (! credStr.startsWith("rspauth=")) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_COULD_NOT_DECODE_RSPAUTH; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_COULD_NOT_DECODE_RSPAUTH.get( |
| | | getExceptionMessage(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | byte[] clientRspAuth; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_COULD_NOT_CALCULATE_RSPAUTH; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_COULD_NOT_CALCULATE_RSPAUTH.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | if (! Arrays.equals(serverRspAuth, clientRspAuth)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_RSPAUTH_MISMATCH; |
| | | String message = getMessage(msgID); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_DIGESTMD5_RSPAUTH_MISMATCH.get(); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | |
| | | { |
| | | // We found the closing quote before the end of the token. This |
| | | // is not fine. |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS; |
| | | String message = getMessage(msgID, (pos-2)); |
| | | Message message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get((pos-2)); |
| | | throw new LDAPException(LDAPResultCode.INVALID_CREDENTIALS, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | | |
| | |
| | | * SASL DIGEST-MD5 bind, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLDigestMD5Properties() |
| | | public static LinkedHashMap<String,Message> getSASLDigestMD5Properties() |
| | | { |
| | | LinkedHashMap<String,String> properties = |
| | | new LinkedHashMap<String,String>(5); |
| | | LinkedHashMap<String,Message> properties = |
| | | new LinkedHashMap<String,Message>(5); |
| | | |
| | | properties.put(SASL_PROPERTY_AUTHID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID.get()); |
| | | properties.put(SASL_PROPERTY_REALM, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_REALM)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_REALM.get()); |
| | | properties.put(SASL_PROPERTY_QOP, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_QOP)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_QOP.get()); |
| | | properties.put(SASL_PROPERTY_DIGEST_URI, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_DIGEST_URI)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_DIGEST_URI.get()); |
| | | properties.put(SASL_PROPERTY_AUTHZID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHZID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHZID.get()); |
| | | |
| | | return properties; |
| | | } |
| | |
| | | // Make sure that no SASL properties were provided. |
| | | if ((saslProperties != null) && (! saslProperties.isEmpty())) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_ALLOWED_SASL_PROPERTIES; |
| | | String message = getMessage(msgID, SASL_MECHANISM_EXTERNAL); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_NO_ALLOWED_SASL_PROPERTIES.get(SASL_MECHANISM_EXTERNAL); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_EXTERNAL, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_EXTERNAL, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_EXTERNAL, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_EXTERNAL, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // FIXME -- Add support for referrals. |
| | | |
| | | int msgID = MSGID_LDAPAUTH_SASL_BIND_FAILED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_EXTERNAL); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_BIND_FAILED.get(SASL_MECHANISM_EXTERNAL); |
| | | throw new LDAPException(resultCode, bindResponse.getErrorMessage(), |
| | | msgID, message, bindResponse.getMatchedDN(), null); |
| | | message, bindResponse.getMatchedDN(), null); |
| | | } |
| | | |
| | | |
| | |
| | | * SASL EXTERNAL bind, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLExternalProperties() |
| | | public static LinkedHashMap<String,Message> getSASLExternalProperties() |
| | | { |
| | | // There are no properties for the SASL EXTERNAL mechanism. |
| | | return new LinkedHashMap<String,String>(0); |
| | | return new LinkedHashMap<String,Message>(0); |
| | | } |
| | | |
| | | |
| | |
| | | // KDC, QoP, and realm are optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_SASL_PROPERTIES; |
| | | String message = getMessage(msgID, SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHZID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_KDC_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_KDC_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_QOP_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_QOP_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | if (gssapiQoP.equals("auth")) |
| | |
| | | gssapiQoP.equals("auth-conf")) |
| | | { |
| | | // FIXME -- Add support for integrity and confidentiality. |
| | | int msgID = MSGID_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED; |
| | | String message = getMessage(msgID, gssapiQoP); |
| | | Message message = |
| | | ERR_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED.get(gssapiQoP); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal value. |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_INVALID_QOP; |
| | | String message = getMessage(msgID, gssapiQoP); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_INVALID_QOP.get(gssapiQoP); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_REALM_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_REALM_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_INVALID_SASL_PROPERTY; |
| | | String message = getMessage(msgID, name, SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get(name, SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | // Make sure that the authID was provided. |
| | | if ((gssapiAuthID == null) || (gssapiAuthID.length() == 0)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SASL_AUTHID_REQUIRED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_CANNOT_CREATE_JAAS_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_JAAS_CONFIG.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | System.setProperty(JAAS_PROPERTY_CONFIG_FILE, configFileName); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | try |
| | |
| | | throw (LDAPException) e; |
| | | } |
| | | |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_REMOTE_AUTHENTICATION_FAILED; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_REMOTE_AUTHENTICATION_FAILED.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | * SASL EXTERNAL bind, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLGSSAPIProperties() |
| | | public static LinkedHashMap<String,Message> getSASLGSSAPIProperties() |
| | | { |
| | | LinkedHashMap<String,String> properties = |
| | | new LinkedHashMap<String,String>(4); |
| | | LinkedHashMap<String,Message> properties = |
| | | new LinkedHashMap<String,Message>(4); |
| | | |
| | | properties.put(SASL_PROPERTY_AUTHID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID.get()); |
| | | properties.put(SASL_PROPERTY_AUTHZID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHZID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHZID.get()); |
| | | properties.put(SASL_PROPERTY_KDC, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_KDC)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_KDC.get()); |
| | | properties.put(SASL_PROPERTY_REALM, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_REALM)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_REALM.get()); |
| | | |
| | | return properties; |
| | | } |
| | |
| | | // optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NO_SASL_PROPERTIES; |
| | | String message = getMessage(msgID, SASL_MECHANISM_PLAIN); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_AUTHZID_SINGLE_VALUED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_INVALID_SASL_PROPERTY; |
| | | String message = getMessage(msgID, name, SASL_MECHANISM_PLAIN); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get(name, SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | // Make sure that at least the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SASL_AUTHID_REQUIRED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_PLAIN); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, msgID, |
| | | message); |
| | | Message message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | // the user. |
| | | if (bindPassword == null) |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, authID)); |
| | | System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(authID)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | if (pwChars == null) |
| | | { |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_PLAIN, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_PLAIN, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_PLAIN, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_PLAIN, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // FIXME -- Add support for referrals. |
| | | |
| | | int msgID = MSGID_LDAPAUTH_SASL_BIND_FAILED; |
| | | String message = getMessage(msgID, SASL_MECHANISM_PLAIN); |
| | | Message message = ERR_LDAPAUTH_SASL_BIND_FAILED.get(SASL_MECHANISM_PLAIN); |
| | | throw new LDAPException(resultCode, bindResponse.getErrorMessage(), |
| | | msgID, message, bindResponse.getMatchedDN(), null); |
| | | message, bindResponse.getMatchedDN(), null); |
| | | } |
| | | |
| | | |
| | |
| | | * SASL PLAIN bind, mapped from the property names to their |
| | | * corresponding descriptions. |
| | | */ |
| | | public static LinkedHashMap<String,String> getSASLPlainProperties() |
| | | public static LinkedHashMap<String,Message> getSASLPlainProperties() |
| | | { |
| | | LinkedHashMap<String,String> properties = |
| | | new LinkedHashMap<String,String>(2); |
| | | LinkedHashMap<String,Message> properties = |
| | | new LinkedHashMap<String,Message>(2); |
| | | |
| | | properties.put(SASL_PROPERTY_AUTHID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHID.get()); |
| | | properties.put(SASL_PROPERTY_AUTHZID, |
| | | getMessage(MSGID_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHZID)); |
| | | INFO_LDAPAUTH_PROPERTY_DESCRIPTION_AUTHZID.get()); |
| | | |
| | | return properties; |
| | | } |
| | |
| | | { |
| | | if (saslMechanism == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NONSASL_RUN_INVOCATION; |
| | | String message = getMessage(msgID, getBacktrace()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_NONSASL_RUN_INVOCATION.get(getBacktrace()); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | else if (saslMechanism.equals(SASL_MECHANISM_GSSAPI)) |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_CANNOT_CREATE_SASL_CLIENT; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_SASL_CLIENT.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_CANNOT_CREATE_INITIAL_CHALLENGE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message, e); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_INITIAL_CHALLENGE. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_GSSAPI, |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_GSSAPI, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | Message message = |
| | | ERR_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | } |
| | | |
| | |
| | | // Just to be sure, check that the login really is complete. |
| | | if (! saslClient.isComplete()) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_UNEXPECTED_SUCCESS_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_GSSAPI_UNEXPECTED_SUCCESS_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | |
| | | break; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_GSSAPI, |
| | | getExceptionMessage(ioe)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message, ioe); |
| | | message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_SASL_BIND; |
| | | String message = getMessage(msgID, SASL_MECHANISM_GSSAPI, |
| | | getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = |
| | | MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message, ioe); |
| | | message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_BIND_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, |
| | | extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE; |
| | | String message = getMessage(msgID, |
| | | String.valueOf(extendedResponse)); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get( |
| | | String.valueOf(extendedResponse)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This is an error. |
| | | int msgID = MSGID_LDAPAUTH_GSSAPI_BIND_FAILED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_GSSAPI_BIND_FAILED.get(); |
| | | throw new LDAPException(resultCode, bindResponse.getErrorMessage(), |
| | | msgID, message, bindResponse.getMatchedDN(), |
| | | message, bindResponse.getMatchedDN(), |
| | | null); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RUN_INVOCATION; |
| | | String message = getMessage(msgID, saslMechanism, getBacktrace()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RUN_INVOCATION.get( |
| | | saslMechanism, getBacktrace()); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (saslMechanism == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_NONSASL_CALLBACK_INVOCATION; |
| | | String message = getMessage(msgID, getBacktrace()); |
| | | throw new UnsupportedCallbackException(callbacks[0], message); |
| | | Message message = |
| | | ERR_LDAPAUTH_NONSASL_CALLBACK_INVOCATION.get(getBacktrace()); |
| | | throw new UnsupportedCallbackException(callbacks[0], message.toString()); |
| | | } |
| | | else if (saslMechanism.equals(SASL_MECHANISM_GSSAPI)) |
| | | { |
| | |
| | | { |
| | | if (gssapiAuthPW == null) |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, |
| | | gssapiAuthID)); |
| | | System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(gssapiAuthID)); |
| | | gssapiAuthPW = PasswordReader.readPassword(); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_GSSAPI_CALLBACK; |
| | | String message = getMessage(msgID, String.valueOf(cb)); |
| | | throw new UnsupportedCallbackException(cb, message); |
| | | Message message = |
| | | ERR_LDAPAUTH_UNEXPECTED_GSSAPI_CALLBACK.get(String.valueOf(cb)); |
| | | throw new UnsupportedCallbackException(cb, message.toString()); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_CALLBACK_INVOCATION; |
| | | String message = getMessage(msgID, saslMechanism, getBacktrace()); |
| | | throw new UnsupportedCallbackException(callbacks[0], message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_CALLBACK_INVOCATION.get( |
| | | saslMechanism, getBacktrace()); |
| | | throw new UnsupportedCallbackException(callbacks[0], message.toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST.get(getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST.get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | msgID, message, e); |
| | | message, e); |
| | | } |
| | | |
| | | |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE; |
| | | String message = getMessage(msgID); |
| | | Message message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msgID, message); |
| | | message); |
| | | } |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msgID, |
| | | message, ioe); |
| | | Message message = ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, ae); |
| | | message, ae); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(le)); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | msgID, message, le); |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message, e); |
| | | Message message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | | // If the protocol op isn't an extended response, then that's a problem. |
| | | if (responseMessage.getProtocolOpType() != OP_TYPE_EXTENDED_RESPONSE) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_UNEXPECTED_RESPONSE; |
| | | String message = |
| | | getMessage(msgID, String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get( |
| | | String.valueOf(responseMessage.getProtocolOp())); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_SERVER_DISCONNECT; |
| | | String message = getMessage(msgID, extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), msgID, message); |
| | | Message message = ERR_LDAPAUTH_SERVER_DISCONNECT.get( |
| | | extendedResponse.getResultCode(), extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | |
| | | |
| | |
| | | int resultCode = extendedResponse.getResultCode(); |
| | | if (resultCode != LDAPResultCode.SUCCESS) |
| | | { |
| | | int msgID = MSGID_LDAPAUTH_WHOAMI_FAILED; |
| | | String message = getMessage(msgID); |
| | | Message message = ERR_LDAPAUTH_WHOAMI_FAILED.get(); |
| | | throw new LDAPException(resultCode, extendedResponse.getErrorMessage(), |
| | | msgID, message, extendedResponse.getMatchedDN(), |
| | | message, extendedResponse.getMatchedDN(), |
| | | null); |
| | | } |
| | | |