示例#1
0
    def create_user_graph(self):
        """
        Create a subgraph for the user. All his data will be inserted in this subgraph
        """

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        ttl = '<' + self.settings['askomics.graph'] + ':' + self.username + \
            '> rdfg:subGraphOf <' + self.settings['askomics.graph'] + '>'

        header_ttl = sqa.header_sparql_config(ttl)
        query_laucher.insert_data(ttl, self.settings["askomics.graph"], header_ttl)
示例#2
0
    def create_user_graph(self):
        """
        Create a subgraph for the user. All his data will be inserted in this subgraph
        """

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        ttl = '<' + self.settings['askomics.graph'] + ':' + self.username + \
            '> rdfg:subGraphOf <' + self.settings['askomics.graph'] + '>'

        header_ttl = sqa.header_sparql_config(ttl)
        query_laucher.insert_data(ttl, self.settings["askomics.graph"], header_ttl)
示例#3
0
    def persist_user(self, host_url):
        """
        Persist all user infos in the TS
        """
        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        #check if user is the first. if yes, set him admin
        if self.get_number_of_users() == 0:
            admin = 'true'
            blocked = 'false'
            self.set_admin(True)
            self.set_blocked(False)
        else:
            admin = 'false'
            blocked = 'true'
            self.set_admin(False)
            self.set_blocked(True)

        chunk = ':' + self.username + ' rdf:type foaf:Person ;\n'
        indent = len(self.username) * ' ' + ' '
        chunk += indent + 'foaf:name \"' + self.username + '\" ;\n'
        chunk += indent + ':password \"' + self.sha256_pw + '\" ;\n'
        chunk += indent + 'foaf:mbox <mailto:' + self.email + '> ;\n'
        chunk += indent + ':isadmin \"' + admin + '\"^^xsd:boolean ;\n'
        chunk += indent + ':isblocked \"' + blocked + '\"^^xsd:boolean ;\n'
        chunk += indent + ':randomsalt \"' + self.randomsalt + '\" .\n'

        header_ttl = sqa.header_sparql_config(chunk)
        query_laucher.insert_data(chunk, self.settings["askomics.users_graph"],
                                  header_ttl)

        emails = self.get_admins_emails()

        # Send a mail to all admins
        body = 'Hello,\n'
        body += 'User \'' + self.username + '\' just created an account on Askomics.\n'
        body += 'Log into the admin interface in order to unblock this user, or contact him '
        body += 'at ' + self.email + '.\n\n\n'
        body += host_url + '\n\n'

        self.send_mails(host_url, emails,
                        '[AskOmics@' + host_url + '] New account created',
                        body)
示例#4
0
    def persist_user(self,host_url):
        """
        Persist all user infos in the TS
        """
        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        #check if user is the first. if yes, set him admin
        if self.get_number_of_users() == 0:
            admin = 'true'
            blocked = 'false'
            self.set_admin(True)
            self.set_blocked(False)
        else:
            admin = 'false'
            blocked = 'true'
            self.set_admin(False)
            self.set_blocked(True)

        chunk = ':' + self.username + ' rdf:type foaf:Person ;\n'
        indent = len(self.username) * ' ' + ' '
        chunk += indent + 'foaf:name \"' + self.username + '\" ;\n'
        chunk += indent + ':password \"' + self.sha256_pw + '\" ;\n'
        chunk += indent + 'foaf:mbox <mailto:' + self.email + '> ;\n'
        chunk += indent + ':isadmin \"' + admin + '\"^^xsd:boolean ;\n'
        chunk += indent + ':isblocked \"' + blocked + '\"^^xsd:boolean ;\n'
        chunk += indent + ':randomsalt \"' + self.randomsalt + '\" .\n'

        header_ttl = sqa.header_sparql_config(chunk)
        query_laucher.insert_data(chunk, self.settings["askomics.users_graph"], header_ttl)

        emails = self.get_admins_emails()

        # Send a mail to all admins
        body = 'Hello,\n'
        body += 'User \'' + self.username + '\' just created an account on Askomics.\n'
        body += 'Log into the admin interface in order to unblock this user, or contact him '
        body += 'at ' + self.email + '.\n\n\n'
        body += host_url + '\n\n'

        self.send_mails(host_url, emails, '[AskOmics@'+ host_url + '] New account created', body)
示例#5
0
    def add_another_admin_in_users(self):
        """Insert an admin User

        username is otheradmin
        mail is [email protected]
        password is iamadmin
        admin and not blocked
        """

        query_laucher = QueryLauncher(self.settings, self.request.session)
        sqa = SparqlQueryAuth(self.settings, self.request.session)
        chunk = ':otheradmin rdf:type foaf:Person ;\n'
        indent = len('otheradmin') * ' ' + ' '
        chunk += indent + 'foaf:name \"otheradmin\" ;\n'
        chunk += indent + ':password \"682cf6a90d94758bdedcf854e8d784e3d5d360a36cd65a2c49eaff214998c23a\" ;\n' #iamadmin
        chunk += indent + 'foaf:mbox <mailto:[email protected]> ;\n'
        chunk += indent + ':isadmin \"true\"^^xsd:boolean ;\n'
        chunk += indent + ':isblocked \"false\"^^xsd:boolean ;\n'
        chunk += indent + ':randomsalt \"00000000000000000000\" .\n'

        header_ttl = sqa.header_sparql_config(chunk)
        query_laucher.insert_data(chunk, 'urn:sparql:test_askomics:users', header_ttl)
示例#6
0
    def add_jsmith_in_users(self):
        """Insert a Jane Smith User

        username is jsmith
        mail is [email protected]
        password is iamjanesmith
        not admin and not blocked
        """

        query_laucher = QueryLauncher(self.settings, self.request.session)
        sqa = SparqlQueryAuth(self.settings, self.request.session)
        chunk = ':jsmith rdf:type foaf:Person ;\n'
        indent = len('jsmith') * ' ' + ' '
        chunk += indent + 'foaf:name \"jsmith\" ;\n'
        chunk += indent + ':password \"db64872417dcc1488a72b034cbe75268f52eb2486807af096dd2f4c620694efc\" ;\n' #iamjanesmith
        chunk += indent + 'foaf:mbox <mailto:[email protected]> ;\n'
        chunk += indent + ':isadmin \"false\"^^xsd:boolean ;\n'
        chunk += indent + ':isblocked \"false\"^^xsd:boolean ;\n'
        chunk += indent + ':randomsalt \"00000000000000000000\" .\n'

        header_ttl = sqa.header_sparql_config(chunk)
        query_laucher.insert_data(chunk, 'urn:sparql:test_askomics:users', header_ttl)
示例#7
0
    def add_jdoe_in_users(self):
        """Insert a John Doe User

        username is jdoe
        mail is [email protected]
        password is iamjohndoe
        not admin and not blocked
        """

        query_laucher = QueryLauncher(self.settings, self.request.session)
        sqa = SparqlQueryAuth(self.settings, self.request.session)
        chunk = ':jdoe rdf:type foaf:Person ;\n'
        indent = len('jdoe') * ' ' + ' '
        chunk += indent + 'foaf:name \"jdoe\" ;\n'
        chunk += indent + ':password \"23df582b51c3482b677c8eac54872b8bd0a49bfadc853628b8b8bd4806147b54\" ;\n' #iamjohndoe
        chunk += indent + 'foaf:mbox <mailto:[email protected]> ;\n'
        chunk += indent + ':isadmin \"false\"^^xsd:boolean ;\n'
        chunk += indent + ':isblocked \"false\"^^xsd:boolean ;\n'
        chunk += indent + ':randomsalt \"00000000000000000000\" .\n'

        header_ttl = sqa.header_sparql_config(chunk)
        query_laucher.insert_data(chunk, 'urn:sparql:test_askomics:users', header_ttl)