Exemplo n.º 1
0
    def listChannels(self, system_id):
        """ Clients v2+ """
        log_debug(5, system_id)
        # Authenticate the system certificate
        self.auth_system('listChannels', system_id)
        # log the entry
        log_debug(1, self.server_id)
        channelList = rhnChannel.channels_for_server(self.server_id)

        loginDict = {
            'X-RHN-Server-Id':
            self.server_id,
            'X-RHN-Auth-Channels':
            rhnChannel.getSubscribedChannels(self.server_id),
        }

        # Duplicate these values in the headers so that the proxy can
        # intercept and cache them without parseing the xmlrpc.
        transport = rhnFlags.get('outputTransportOptions')
        for k, v in list(loginDict.items()):
            # Special case for channels
            if k.lower() == 'x-rhn-auth-channels'.lower():
                # Concatenate the channel information column-separated
                transport[k] = [':'.join(x) for x in v]
            else:
                transport[k] = v
        return channelList
Exemplo n.º 2
0
    def login(self, system_id, extra_data={}):
        """ Clients v2+
            Log in routine.
            Return a dictionary of session token/channel information.
            Also sets this information in the headers.
        """
        log_debug(5, system_id)
        # Authenticate the system certificate. We need the user record
        # to generate the tokens
        self.load_user = 1
        server = self.auth_system('login', system_id)
        # log the entry
        log_debug(1, self.server_id)
        # Update the capabilities list
        rhnCapability.update_client_capabilities(self.server_id)
        # Fetch the channels this client is subscribed to
        channels = rhnChannel.getSubscribedChannels(self.server_id)

        rhnServerTime = str(time.time())
        expireOffset = str(CFG.CLIENT_AUTH_TIMEOUT)
        signature = computeSignature(CFG.SECRET_KEY,
                                     self.server_id,
                                     self.user,
                                     rhnServerTime,
                                     expireOffset)

        loginDict = {
            'X-RHN-Server-Id': self.server_id,
            'X-RHN-Auth-User-Id': self.user,
            'X-RHN-Auth': signature,
            'X-RHN-Auth-Server-Time': rhnServerTime,
            'X-RHN-Auth-Expire-Offset': expireOffset,
            # List of lists [[label,last_mod],...]:
            'X-RHN-Auth-Channels': channels
        }

        # Duplicate these values in the headers so that the proxy can
        # intercept and cache them without parseing the xmlrpc.
        transport = rhnFlags.get('outputTransportOptions')
        for k, v in loginDict.items():
            # Special case for channels
            if string.lower(k) == string.lower('X-RHN-Auth-Channels'):
                # Concatenate the channel information column-separated
                transport[k] = [string.join(x, ':') for x in v]
            else:
                transport[k] = v
        log_debug(5, "loginDict", loginDict, transport)

        # store route in DB (schema for RHN 3.1+ only!)
        server_route.store_client_route(self.server_id)

        return loginDict
Exemplo n.º 3
0
 def checkTokenValidity(self, token, systemid):
     log_debug(5, token, systemid)
     # authenticate that this request is initiated from a proxy
     try:
         self.auth_system(systemid)
         server = self.auth_client(token)  # sets self.server_id
     except rhnFault:
         # A Fault means that something did not auth. Either the caller
         # is not a proxy or the token is not valid, return false.
         return False
     # Proxy has to calculate new proxy-clock-skew, and needs channel info
     ret = {}
     ret['X-RHN-Auth-Server-Time'] = str(time.time())
     channels = rhnChannel.getSubscribedChannels(self.server_id)
     ret['X-RHN-Auth-Channels'] = channels
     return ret
Exemplo n.º 4
0
 def checkTokenValidity(self, token, systemid):
     log_debug(5, token, systemid)
     # authenticate that this request is initiated from a proxy
     try:
         self.auth_system(systemid)
         server = self.auth_client(token) # sets self.server_id
     except rhnFault:
         # A Fault means that something did not auth. Either the caller
         # is not a proxy or the token is not valid, return false.
         return False
     # Proxy has to calculate new proxy-clock-skew, and needs channel info
     ret = {}
     ret['X-RHN-Auth-Server-Time'] = str(time.time())
     channels = rhnChannel.getSubscribedChannels(self.server_id)
     ret['X-RHN-Auth-Channels'] = channels
     return ret