'Authenticate with the switch.
Returns authentication status with modified authentication
header (Base64(username:xxx:random no)).
:returns: Authentication status
:raises BrocadeZoningHttpException:'

def authenticate(self):

    headers = {zone_constant.AUTH_HEADER: self.auth_header}
    try:
        response = self.connect(zone_constant.GET_METHOD, zone_constant.AUTHEN_PAGE, header=headers)
        parsed_data = self.get_parsed_data(response, zone_constant.AUTHEN_BEGIN, zone_constant.AUTHEN_END)
        isauthenticated = self.get_nvp_value(parsed_data, zone_constant.AUTHENTICATED)
        if (isauthenticated == 'yes'):
            auth_string = ((((self.switch_user + ':') + 'xxx') + ':') + self.random_no)
            auth_token = base64.encode_as_text(auth_string).strip()
            auth_header = (zone_constant.AUTH_STRING + auth_token)
            return (True, auth_header)
        else:
            auth_error_code = self.get_nvp_value(parsed_data, 'errCode')
            msg = (_('Authentication    failed,    verify    the    switch    credentials,    error    code    %s.') % auth_error_code)
            LOG.error(msg)
            raise exception.BrocadeZoningHttpException(reason=msg)
    except Exception as e:
        msg = (_('Error    while    authenticating    with    switch:    %s.') % six.text_type(e))
        LOG.error(msg)
        raise exception.BrocadeZoningHttpException(reason=msg)
