Пример #1
0
def validateUserRoomPwd(password, isRetype=False):
    if not password:
        if isRetype:
            errorID = CHANNEL_ERROR_ID.PASSWORD_EMPTY
        else:
            errorID = CHANNEL_ERROR_ID.RETYPE_EMPTY
        return ('', ClientChannelError(errorID))
    else:
        try:
            password = ResourcePrep.prepare(password)
        except XmppStringPrepError:
            if isRetype:
                errorID = CHANNEL_ERROR_ID.PASSWORD_INVALID
            else:
                errorID = CHANNEL_ERROR_ID.RETYPE_INVALID
            return ('', ClientChannelError(errorID))

        length = len(password)
        return ('',
                ClientIntLimitError(
                    LIMIT_ERROR_ID.PWD_INVALID_LENGTH,
                    CHANNEL_LIMIT.PWD_MIN_CHARS_COUNT,
                    CHANNEL_LIMIT.PWD_MAX_CHARS_COUNT)) if not isRetype and (
                        CHANNEL_LIMIT.PWD_MIN_CHARS_COUNT > length
                        or CHANNEL_LIMIT.PWD_MAX_CHARS_COUNT < length) else (
                            password.encode('utf-8'), None)
def validateRosterItemGroup(name):
    if not name:
        return ('', ClientContactError(CONTACT_ERROR_ID.GROUP_EMPTY))
    else:
        try:
            name = ResourcePrep.prepare(name)
        except XmppStringPrepError:
            return ('', ClientContactError(CONTACT_ERROR_ID.GROUP_INVALID_NAME, name))

        length = len(name)
        return (name.encode('utf-8'), ClientIntLimitError(LIMIT_ERROR_ID.GROUP_INVALID_LENGTH, CONTACT_LIMIT.GROUP_MAX_LENGTH, CONTACT_LIMIT.GROUP_MIN_LENGTH)) if CONTACT_LIMIT.GROUP_MIN_LENGTH > length or CONTACT_LIMIT.GROUP_MAX_LENGTH < length else (name.encode('utf-8'), None)
def validateUserRoomName(name):
    if not name:
        return ('', ClientChannelError(CHANNEL_ERROR_ID.NAME_EMPTY))
    else:
        try:
            name = ResourcePrep.prepare(name)
        except XmppStringPrepError:
            return ('', ClientChannelError(CHANNEL_ERROR_ID.NAME_INVALID, name))

        length = len(name)
        return (name.encode('utf-8'), ClientIntLimitError(LIMIT_ERROR_ID.CHANNEL_INVALID_LENGTH, CHANNEL_LIMIT.NAME_MAX_CHARS_COUNT, CHANNEL_LIMIT.NAME_MIN_CHARS_COUNT)) if CHANNEL_LIMIT.NAME_MIN_CHARS_COUNT > length or CHANNEL_LIMIT.NAME_MAX_CHARS_COUNT < length else (name.encode('utf-8'), None)
Пример #4
0
def validateRosterItemGroup(name):
    if not name:
        return ('', ClientContactError(CONTACT_ERROR_ID.GROUP_EMPTY))
    try:
        name = ResourcePrep.prepare(name)
    except XmppStringPrepError:
        return ('', ClientContactError(CONTACT_ERROR_ID.GROUP_INVALID_NAME, name))

    length = len(name)
    if CONTACT_LIMIT.GROUP_MIN_LENGTH > length or CONTACT_LIMIT.GROUP_MAX_LENGTH < length:
        return (name.encode('utf-8'), ClientIntLimitError(LIMIT_ERROR_ID.GROUP_INVALID_LENGTH, CONTACT_LIMIT.GROUP_MIN_LENGTH, CONTACT_LIMIT.GROUP_MAX_LENGTH))
    return (name.encode('utf-8'), None)
Пример #5
0
def validateUserRoomName(name):
    if not name:
        return ('', ClientChannelError(CHANNEL_ERROR_ID.NAME_EMPTY))
    try:
        name = ResourcePrep.prepare(name)
    except XmppStringPrepError:
        return ('', ClientChannelError(CHANNEL_ERROR_ID.NAME_INVALID, name))

    length = len(name)
    if CHANNEL_LIMIT.NAME_MIN_CHARS_COUNT > length or CHANNEL_LIMIT.NAME_MAX_CHARS_COUNT < length:
        return (name.encode('utf-8'), ClientIntLimitError(LIMIT_ERROR_ID.CHANNEL_INVALID_LENGTH, CHANNEL_LIMIT.NAME_MAX_CHARS_COUNT, CHANNEL_LIMIT.NAME_MIN_CHARS_COUNT))
    else:
        return (name.encode('utf-8'), None)
Пример #6
0
def validateUserRoomPwd(password, isRetype = False):
    if not password:
        if isRetype:
            errorID = CHANNEL_ERROR_ID.PASSWORD_EMPTY
        else:
            errorID = CHANNEL_ERROR_ID.RETYPE_EMPTY
        return ('', ClientChannelError(errorID))
    try:
        password = ResourcePrep.prepare(password)
    except XmppStringPrepError:
        if isRetype:
            errorID = CHANNEL_ERROR_ID.PASSWORD_INVALID
        else:
            errorID = CHANNEL_ERROR_ID.RETYPE_INVALID
        return ('', ClientChannelError(errorID))

    length = len(password)
    if CHANNEL_LIMIT.NAME_MIN_CHARS_COUNT > length or CHANNEL_LIMIT.NAME_MAX_CHARS_COUNT < length:
        return ('', ClientIntLimitError(LIMIT_ERROR_ID.CHANNEL_INVALID_LENGTH, CHANNEL_LIMIT.NAME_MAX_CHARS_COUNT, CHANNEL_LIMIT.NAME_MIN_CHARS_COUNT))
    else:
        return (password.encode('utf-8'), None)