| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && !respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, then |
| | | // continue. If it's an extended response, then it could be a notice of |
| | | // disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException( ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | |
| | | bindDN = ByteString.empty(); |
| | | } |
| | | |
| | | if ((mechanism == null) || (mechanism.length() == 0)) |
| | | if (mechanism == null || mechanism.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_SASL_MECHANISM.get(); |
| | | throw new ClientException( |
| | |
| | | |
| | | // Evaluate the properties provided. The only one we'll allow is the trace |
| | | // property, but it is not required. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | // This is fine because there are no required properties for this |
| | | // mechanism. |
| | | // This is fine because there are no required properties for this mechanism. |
| | | } |
| | | else |
| | | { |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | if (name.equalsIgnoreCase(SASL_PROPERTY_TRACE)) |
| | | { |
| | | // This is acceptable, and we'll take any single value. |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_TRACE_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, then |
| | | // continue. If it's an extended response, then it could be a notice of |
| | | // disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required, no other |
| | | // properties are allowed. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_CRAM_MD5); |
| | |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | authID = getAuthID(saslProperties, authID, name); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | if (authID == null || authID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_CRAM_MD5); |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage1.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage2.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage2.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | |
| | | |
| | | /** |
| | | * @param saslProperties |
| | | * @param authID |
| | | * @param name |
| | | * @return |
| | | * @throws ClientException |
| | | */ |
| | | private String getAuthID(Map<String, List<String>> saslProperties, String authID, String name) throws ClientException |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | return authID; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Generates the appropriate HMAC-MD5 digest for a CRAM-MD5 authentication |
| | | * with the given information. |
| | | * |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required. The realm, |
| | | // QoP, digest URI, and authzID are optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | authID = getAuthID(saslProperties, authID, name); |
| | | } |
| | | else if (lowerName.equals(SASL_PROPERTY_REALM)) |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | if (authID == null || authID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_DIGEST_MD5); |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage1.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | // Generate the response digest, and initialize the necessary remaining |
| | | // variables to use in the generation of that digest. |
| | | String nonceCount = "00000001"; |
| | | String charset = (useUTF8 ? "UTF-8" : "ISO-8859-1"); |
| | | String charset = useUTF8 ? "UTF-8" : "ISO-8859-1"; |
| | | String responseDigest; |
| | | try |
| | | { |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage2.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage2.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | // We found the closing quote before the end of the token. This |
| | | // is not fine. |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get((pos-2)); |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get(pos-2); |
| | | throw new LDAPException(ReturnCode.INVALID_CREDENTIALS.get(), |
| | | message); |
| | | } |
| | |
| | | throws ClientException, LDAPException |
| | | { |
| | | // Make sure that no SASL properties were provided. |
| | | if ((saslProperties != null) && (! saslProperties.isEmpty())) |
| | | if (saslProperties != null && ! saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_ALLOWED_SASL_PROPERTIES.get(SASL_MECHANISM_EXTERNAL); |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && ! respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | if (responseOID != null && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required. The authzID, |
| | | // KDC, QoP, and realm are optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_GSSAPI); |
| | |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Make sure that the authID was provided. |
| | | if ((gssapiAuthID == null) || (gssapiAuthID.length() == 0)) |
| | | if (gssapiAuthID == null || gssapiAuthID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_GSSAPI); |
| | |
| | | |
| | | // Evaluate the properties provided. The authID is required, and authzID is |
| | | // optional. |
| | | if ((saslProperties == null) || saslProperties.isEmpty()) |
| | | if (saslProperties == null || saslProperties.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_PLAIN); |
| | |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | | while (propertyNames.hasNext()) |
| | | for (String name : saslProperties.keySet()) |
| | | { |
| | | String name = propertyNames.next(); |
| | | String lowerName = toLowerCase(name); |
| | | |
| | | if (lowerName.equals(SASL_PROPERTY_AUTHID)) |
| | | { |
| | | List<String> values = saslProperties.get(name); |
| | | Iterator<String> iterator = values.iterator(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | authID = iterator.next(); |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | authID = getAuthID(saslProperties, authID, name); |
| | | } |
| | | else if (lowerName.equals(SASL_PROPERTY_AUTHZID)) |
| | | { |
| | |
| | | |
| | | |
| | | // Make sure that at least the authID was provided. |
| | | if ((authID == null) || (authID.length() == 0)) |
| | | if (authID == null || authID.length() == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_PLAIN); |
| | |
| | | // See if there are any controls in the response. If so, then add them to |
| | | // the response controls list. |
| | | List<Control> respControls = responseMessage.getControls(); |
| | | if ((respControls != null) && (! respControls.isEmpty())) |
| | | if (respControls != null && !respControls.isEmpty()) |
| | | { |
| | | responseControls.addAll(respControls); |
| | | } |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, then |
| | | // continue. If it's an extended response, then it could be a notice of |
| | | // disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | |
| | | // Look at the protocol op from the response. If it's a bind response, |
| | | // then continue. If it's an extended response, then it could be a notice |
| | | // of disconnection so check for that. Otherwise, generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | |
| | | |
| | | while (true) |
| | |
| | | // response, then continue. If it's an extended response, then it |
| | | // could be a notice of disconnection so check for that. Otherwise, |
| | | // generate an error. |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), |
| | | extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | generateError(responseMessage); |
| | | } |
| | | else |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private void generateError(LDAPMessage responseMessage) throws LDAPException, ClientException |
| | | { |
| | | switch (responseMessage.getProtocolOpType()) |
| | | { |
| | | case OP_TYPE_BIND_RESPONSE: |
| | | // We'll deal with this later. |
| | | break; |
| | | |
| | | case OP_TYPE_EXTENDED_RESPONSE: |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if (OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT. |
| | | get(extendedResponse.getResultCode(), extendedResponse.getErrorMessage()); |
| | | throw new LDAPException(extendedResponse.getResultCode(), message); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Handles the authentication callbacks to provide information needed by the |
| | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | | String responseOID = extendedResponse.getOID(); |
| | | if ((responseOID != null) && |
| | | responseOID.equals(OID_NOTICE_OF_DISCONNECTION)) |
| | | if (OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_SERVER_DISCONNECT.get( |
| | | extendedResponse.getResultCode(), extendedResponse.getErrorMessage()); |
| | |
| | | |
| | | // Get the authorization ID (if there is one) and return it to the caller. |
| | | ByteString authzID = extendedResponse.getValue(); |
| | | if ((authzID == null) || (authzID.length() == 0)) |
| | | if (authzID == null || authzID.length() == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | String valueString = authzID.toString(); |
| | | if ((valueString == null) || (valueString.length() == 0) || |
| | | if (valueString == null || valueString.length() == 0 || |
| | | valueString.equalsIgnoreCase("dn:")) |
| | | { |
| | | return null; |
| | |
| | | return authzID; |
| | | } |
| | | } |
| | | |