'Registers a data server in the master.'

def HandleRegister(self):

    if (not self.MASTER):
        self._EmptyResponse(constants.RESPONSE_NOT_MASTER_SERVER)
        return
    request = rdf_data_server.DataStoreRegistrationRequest.FromSerializedString(self.post_data)
    port = request.port
    addr = self.client_address[0]
    token = request.token
    if (not self.NONCE_STORE.ValidateAuthTokenServer(token)):
        self._EmptyResponse(constants.RESPONSE_SERVER_NOT_AUTHORIZED)
        return
    newserver = self.MASTER.RegisterServer(addr, port)
    if newserver:
        self.data_server = newserver
        index = newserver.Index()
        body = sutils.SIZE_PACKER.pack(index)
        body += self.NONCE_STORE.EncryptClientCredentials()
        self._Response(constants.RESPONSE_OK, body)
    else:
        logging.warning('Could    not    register    server    %s:%d.    Maybe    not    allowed?', addr, port)
        self._EmptyResponse(constants.RESPONSE_SERVER_NOT_ALLOWED)
