Beispiel #1
0
def transportOwnLink(request: 'ExtendedHttpRequestWithUser', idService: str,
                     idTransport: str):
    response: typing.MutableMapping[str, typing.Any] = {}

    # For type checkers to "be happy"
    try:
        res = userServiceManager().getService(request.user, request.os,
                                              request.ip, idService,
                                              idTransport)
        ip, userService, iads, trans, itrans = res  # pylint: disable=unused-variable
        # This returns a response object in fact
        if itrans and ip:
            response = {
                'url':
                itrans.getLink(
                    userService,
                    trans,
                    ip,
                    request.os,
                    request.user,
                    webPassword(request),
                    request,
                )
            }
    except ServiceNotReadyError as e:
        response = {'running': e.code * 25}
    except Exception as e:
        logger.exception("Exception")
        response = {'error': str(e)}

    return HttpResponse(content=json.dumps(response),
                        content_type='application/json')

    # Will never reach this
    return errors.errorView(request, errors.UNKNOWN_ERROR)
Beispiel #2
0
def clientEnabler(request, idService, idTransport):

    # Maybe we could even protect this even more by limiting referer to own server /? (just a meditation..)

    url = ''
    error = _('Service not ready. Please, try again in a while.')
    try:
        res = getService(request, idService, idTransport, doTest=False)
        if res is not None:

            scrambler = cryptoManager().randomString(32)
            password = cryptoManager().xor(webPassword(request), scrambler)

            _x, ads, _x, trans, _x = res

            data = {
                'service': 'A' + ads.uuid,
                'transport': trans.uuid,
                'user': request.user.uuid,
                'password': password
            }

            ticket = TicketStore.create(data)
            error = ''
            url = html.udsLink(request, ticket, scrambler)
    except Exception as e:
        error = six.text_type(e)

    # Not ready, show message and return to this page in a while
    return HttpResponse('{{ "url": "{}", "error": "{}" }}'.format(url, error),
                        content_type='application/json')
Beispiel #3
0
def clientEnabler(request, idService, idTransport):

    # Maybe we could even protect this even more by limiting referer to own server /? (just a meditation..)

    url = ''
    error = _('Service not ready. Please, try again in a while.')
    try:
        res = getService(request, idService, idTransport, doTest=False)
        if res is not None:

            scrambler = cryptoManager().randomString(32)
            password = cryptoManager().xor(webPassword(request), scrambler)

            _x, ads, _x, trans, _x = res

            data = {
                'service': 'A' + ads.uuid,
                'transport': trans.uuid,
                'user': request.user.uuid,
                'password': password
            }

            ticket = TicketStore.create(data)
            error = ''
            url = html.udsLink(request, ticket, scrambler)
    except Exception as e:
        error = six.text_type(e)

    # Not ready, show message and return to this page in a while
    return HttpResponse('{{ "url": "{}", "error": "{}" }}'.format(url, error), content_type='application/json')
Beispiel #4
0
def enableService(request: 'ExtendedHttpRequestWithUser', idService: str,
                  idTransport: str) -> typing.Mapping[str, typing.Any]:
    # Maybe we could even protect this even more by limiting referer to own server /? (just a meditation..)
    logger.debug('idService: %s, idTransport: %s', idService, idTransport)
    url = ''
    error = ugettext('Service not ready. Please, try again in a while.')

    # If meta service, process and rebuild idService & idTransport

    try:
        res = userServiceManager().getService(request.user,
                                              request.os,
                                              request.ip,
                                              idService,
                                              idTransport,
                                              doTest=False)
        scrambler = cryptoManager().randomString(32)
        password = cryptoManager().symCrypt(webPassword(request), scrambler)

        userService, trans = res[1], res[3]

        typeTrans = trans.getType()

        error = ''  # No error

        if typeTrans.ownLink:
            url = reverse('TransportOwnLink',
                          args=('A' + userService.uuid, trans.uuid))
        else:
            data = {
                'service': 'A' + userService.uuid,
                'transport': trans.uuid,
                'user': request.user.uuid,
                'password': password
            }

            ticket = TicketStore.create(data)
            url = html.udsLink(request, ticket, scrambler)
    except ServiceNotReadyError as e:
        logger.debug('Service not ready')
        # Not ready, show message and return to this page in a while
        # error += ' (code {0:04X})'.format(e.code)
        error = ugettext(
            'Your service is being created, please, wait for a few seconds while we complete it.)'
        ) + '({}%)'.format(int(e.code * 25))
    except MaxServicesReachedError:
        logger.info('Number of service reached MAX for service pool "%s"',
                    idService)
        error = errors.errorString(errors.MAX_SERVICES_REACHED)
    except ServiceAccessDeniedByCalendar:
        logger.info('Access tried to a calendar limited access pool "%s"',
                    idService)
        error = errors.errorString(errors.SERVICE_CALENDAR_DENIED)
    except Exception as e:
        logger.exception('Error')
        error = str(e)

    return {'url': str(url), 'error': str(error)}
Beispiel #5
0
def trans(request, idService, idTransport):
    try:
        res = getService(request, idService, idTransport)
        if res is not None:
            ip, ads, iads, trans, itrans = res
            return itrans.getLink(ads, trans, ip, request.os, request.user, webPassword(request), request)
    except Exception, e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)
Beispiel #6
0
def trans(request, idService, idTransport):
    try:
        res = getService(request, idService, idTransport)
        if res is not None:
            ip, ads, iads, trans, itrans = res
            return itrans.getLink(ads, trans, ip, request.os, request.user,
                                  webPassword(request), request)
    except Exception, e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)
Beispiel #7
0
def userServiceEnabler(request, idService, idTransport):
    # Maybe we could even protect this even more by limiting referer to own server /? (just a meditation..)
    logger.debug('idService: {}, idTransport: {}'.format(
        idService, idTransport))
    url = ''
    error = _('Service not ready. Please, try again in a while.')

    # If meta service, process and rebuild idService & idTransport

    try:
        res = userServiceManager().getService(request.user,
                                              request.os,
                                              request.ip,
                                              idService,
                                              idTransport,
                                              doTest=False)
        scrambler = cryptoManager().randomString(32)
        password = cryptoManager().symCrypt(webPassword(request), scrambler)

        _x, userService, _x, trans, _x = res

        data = {
            'service': 'A' + userService.uuid,
            'transport': trans.uuid,
            'user': request.user.uuid,
            'password': password
        }

        ticket = TicketStore.create(data)
        error = ''
        url = html.udsLink(request, ticket, scrambler)
    except ServiceNotReadyError as e:
        logger.debug('Service not ready')
        # Not ready, show message and return to this page in a while
        error += ' (code {0:04X})'.format(e.code)
    except MaxServicesReachedError:
        logger.info(
            'Number of service reached MAX for service pool "{}"'.format(
                idService))
        error = errors.errorString(errors.MAX_SERVICES_REACHED)
    except ServiceAccessDeniedByCalendar:
        logger.info(
            'Access tried to a calendar limited access pool "{}"'.format(
                idService))
        error = errors.errorString(errors.SERVICE_CALENDAR_DENIED)
    except Exception as e:
        logger.exception('Error')
        error = str(e)

    return HttpResponse(json.dumps({
        'url': str(url),
        'error': str(error)
    }),
                        content_type='application/json')
Beispiel #8
0
def transportOwnLink(request, idService, idTransport):
    try:
        res = userServiceManager().getService(request.user, request.ip, idService, idTransport)
        ip, userService, iads, trans, itrans = res  # @UnusedVariable
        # This returns a response object in fact
        return itrans.getLink(userService, trans, ip, request.os, request.user, webPassword(request), request)
    except ServiceNotReadyError as e:
        return errors.exceptionView(request, e)
    except Exception as e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)

    # Will never reach this
    raise RuntimeError('Unreachable point reached!!!')
Beispiel #9
0
def transportOwnLink(request, idService, idTransport):
    try:
        res = userServiceManager().getService(request.user, request.os, request.ip, idService, idTransport)
        ip, userService, iads, trans, itrans = res  # @UnusedVariable
        # This returns a response object in fact
        return itrans.getLink(userService, trans, ip, request.os, request.user, webPassword(request), request)
    except ServiceNotReadyError as e:
        return errors.exceptionView(request, e)
    except Exception as e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)

    # Will never reach this
    raise RuntimeError('Unreachable point reached!!!')
Beispiel #10
0
def userServiceEnabler(request, idService, idTransport):
    # Maybe we could even protect this even more by limiting referer to own server /? (just a meditation..)
    logger.debug('idService: {}, idTransport: {}'.format(idService, idTransport))
    url = ''
    error = _('Service not ready. Please, try again in a while.')

    # If meta service, process and rebuild idService & idTransport

    try:
        res = userServiceManager().getService(request.user, request.os, request.ip, idService, idTransport, doTest=False)
        scrambler = cryptoManager().randomString(32)
        password = cryptoManager().symCrypt(webPassword(request), scrambler)

        _x, userService, _x, trans, _x = res

        data = {
            'service': 'A' + userService.uuid,
            'transport': trans.uuid,
            'user': request.user.uuid,
            'password': password
        }

        ticket = TicketStore.create(data)
        error = ''
        url = html.udsLink(request, ticket, scrambler)
    except ServiceNotReadyError as e:
        logger.debug('Service not ready')
        # Not ready, show message and return to this page in a while
        error += ' (code {0:04X})'.format(e.code)
    except MaxServicesReachedError:
        logger.info('Number of service reached MAX for service pool "{}"'.format(idService))
        error = errors.errorString(errors.MAX_SERVICES_REACHED)
    except ServiceAccessDeniedByCalendar:
        logger.info('Access tried to a calendar limited access pool "{}"'.format(idService))
        error = errors.errorString(errors.SERVICE_CALENDAR_DENIED)
    except Exception as e:
        logger.exception('Error')
        error = str(e)

    return HttpResponse(
        json.dumps({
            'url': str(url),
            'error': str(error)
        }),
        content_type='application/json'
    )
Beispiel #11
0
def transportOwnLink(request: 'HttpRequest', idService: str, idTransport: str):
    try:
        res = userServiceManager().getService(request.user, request.os,
                                              request.ip, idService,
                                              idTransport)
        ip, userService, iads, trans, itrans = res  # pylint: disable=unused-variable
        # This returns a response object in fact
        if itrans and ip:
            return itrans.getLink(userService, trans, ip, request.os,
                                  request.user, webPassword(request), request)
    except ServiceNotReadyError as e:
        return errors.exceptionView(request, e)
    except Exception as e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)

    # Will never reach this
    return errors.errorView(request, errors.UNKNOWN_ERROR)
Beispiel #12
0
def transportOwnLink(request, idService, idTransport):
    try:
        res = userServiceManager().getService(request.user, request.ip,
                                              idService, idTransport)
        ip, userService, iads, trans, itrans = res  # @UnusedVariable
        # This returns a response object in fact
        return itrans.getLink(userService, trans, ip, request.os, request.user,
                              webPassword(request), request)
    except ServiceNotReadyError as e:
        return render(request, theme.template('service_not_ready.html'), {
            'fromLauncher': False,
            'code': e.code
        })
    except Exception as e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)

    # Will never reach this
    raise RuntimeError('Unreachable point reached!!!')
Beispiel #13
0
def transportOwnLink(request, idService, idTransport):
    try:
        res = userServiceManager().getService(request.user, request.ip, idService, idTransport)
        ip, userService, iads, trans, itrans = res  # @UnusedVariable
        # This returns a response object in fact
        return itrans.getLink(userService, trans, ip, request.os, request.user, webPassword(request), request)
    except ServiceNotReadyError as e:
        return render(request,
            theme.template('service_not_ready.html'),
            {
                'fromLauncher': False,
                'code': e.code
            }
        )
    except Exception as e:
        logger.exception("Exception")
        return errors.exceptionView(request, e)

    # Will never reach this
    raise RuntimeError('Unreachable point reached!!!')
Beispiel #14
0
def clientEnabler(request, idService, idTransport):

    # Maybe we could even protect this even more by limiting referer to own server /? (just a meditation..)
    logger.debug('idService: {}, idTransport: {}'.format(idService, idTransport))
    url = ''
    error = _('Service not ready. Please, try again in a while.')
    try:
        res = userServiceManager().getService(request.user, request.ip, idService, idTransport, doTest=False)
        scrambler = cryptoManager().randomString(32)
        password = cryptoManager().xor(webPassword(request), scrambler)

        _x, userService, _x, trans, _x = res

        data = {
            'service': 'A' + userService.uuid,
            'transport': trans.uuid,
            'user': request.user.uuid,
            'password': password
        }

        ticket = TicketStore.create(data)
        error = ''
        url = html.udsLink(request, ticket, scrambler)
    except ServiceNotReadyError as e:
        logger.debug('Service not ready')
        # Not ready, show message and return to this page in a while
        error += ' (code {0:04X})'.format(e.code)
    except MaxServicesReachedError:
        logger.info('Number of service reached MAX for service pool "{}"'.format(idService))
        error = errors.errorString(errors.MAX_SERVICES_REACHED)
    except Exception as e:
        logger.exception('Error')
        error = six.text_type(e)

    return HttpResponse(
        '{{ "url": "{}", "error": "{}" }}'.format(url, error),
        content_type='application/json'
    )