def addEntitlementKey(self, authToken, entClass, entKey):
        cu = self.db.cursor()
        # validate the password

        roleIds = self.getAuthRoles(cu, authToken)
        self.log(2, "entClass=%s entKey=%s" % (entClass, entKey))

        if len(entKey) > MAX_ENTITLEMENT_LENGTH:
            raise errors.InvalidEntitlement

        entClassId = self.__checkEntitlementOwner(cu, roleIds, entClass)

        if entClassId == -1:
            raise errors.UnknownEntitlementClass

        # check for duplicates
        cu.execute("SELECT * FROM Entitlements WHERE entGroupId = ? AND entitlement = ?",
                   (entClassId, entKey))
        if len(cu.fetchall()):
            raise errors.EntitlementKeyAlreadyExists

        cu.execute("INSERT INTO Entitlements (entGroupId, entitlement) VALUES (?, ?)",
                   (entClassId, entKey))

        self.db.commit()
dataset/ETHPy150Open sassoftware/conary/conary/repository/netrepos/netauth.py/NetworkAuthorization.addEntitlementKey/original