Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of the structure-based integrity proof method #778

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*.class
target/

# IDE files
.idea/
*.iml
.classpath
.project
.settings/
out/

logs/

velocity.log.*
*.log

dependency-reduced-pom.xml

.protegedata/
.devdata/

.vscode/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ velocity.log.*

dependency-reduced-pom.xml

.protegedata/
.protegedata/
.devdata/

.vscode/
18 changes: 14 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@ version: "3"

services:

ganache:
image: trufflesuite/ganache-cli:latest
ports:
- '8545:8545'
command: ganache-cli -s attestation -l 100000000000
# mnemonic: endorse soccer immense wonder cheap crew hundred protect bunker lemon burden wash

wpmongo:
container_name: webprotege-mongodb
image: mongo:4.1-bionic
restart: unless-stopped
volumes:
- ./.protegedata/mongodb:/data/db
ports:
- '27017:27017'

webprotege:
container_name: webprotege
image: protegeproject/webprotege
webprotege-attestation:
container_name: webprotege-attestation
image: curtys/webprotege-attestation:latest
depends_on:
- wpmongo
- ganache
restart: unless-stopped
environment:
- webprotege.mongodb.host=wpmongo
volumes:
- ./.protegedata/protege:/srv/webprotege
ports:
- 5000:8080
- '5000:8080'

31 changes: 31 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# How to use the attestation extension

Requirements (see the installation instructions):
- Running WebProtégé instance (either as Docker container or using Maven).
- Deployed contracts (either in a local test blockchain, e.g., in Ganache or on a public network).
- [Metamask](https://metamask.io/) plugin for your browser.

## Setting up Metamask
1) Install the Metamask plugin for your browser. You may follow the [Metamask installation guide](https://metamask.zendesk.com/hc/en-us/articles/360015489531-Getting-started-with-MetaMask).
2) Open the extension and login to your account (if you have one) or create/import a new one by entering a Mnemonic (Secret Recovery Phrase). If you use the Ganache instance chose "Import wallet" and enter the Mnemonic phrase found in the `docker-compose.yml` file. The Mnemonic is a phrase of 12+ lower-case words.
3) If using a local blockchain, e.g., the Ganache instance configured in the `docker-compose.yml` file, you need to add a custom network as explained here: https://metamask.zendesk.com/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC. For the Ganache instance, enter following values:
```
RPC Url: localhost:
Chain ID: 1
```
4) Switch to the network where the contracts are deployed (e.g., localhost for Ganache)

## Attesting to the provenance of an ontology in WebProtégé

1. Log into WebProtégé (by default https://localhost:5000 when using docker or https://localhost:8080 in DevMode) and import an Ontology, e.g., download one from [BioPortal](https://bioportal.bioontology.org), by pressing "Create new project".
![webprotege1.png](webprotege1.png)
1. Open the project and add a new view by clicking the menu icon of a tab and selecting "Add new view".
![webprotege2.png](webprotege2.png)
A popup appears. Select the portlet named "Ontology Attestation". Then place the view on the screen.
![webprotege3.png](webprotege3.png)
1. In the attestation panel (here on the right) select the IRI of the ontology to attest (the IRIs of imported ontologies are shown as well) with the dropdown menu.
![webprotege4.png](webprotege4.png)
1. Once an IRI is selected an attestation may be started by clicking "Sign". Metamask will then prompt to log in. If the popup does not appear, click the Metamask icon on the Plugin bar of your browser.
![webprotege5.png](webprotege5.png)
1. After unlocking Metamask a transaction request is shown. Make sure you have selected the correct network (see previouse section). Authorizing the transaction closes the popup and the result is displayed in the attestation panel.
![webprotege5.png](webprotege6.png)
Binary file added docs/package_protege.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/webprotege1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/webprotege2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/webprotege3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/webprotege4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/webprotege5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/webprotege6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
</properties>

<scm>
<connection>scm:git:https://github.com/protegeproject/webprotege.git</connection>
<url>https://github.com/webprotege/webprotege.git</url>
<connection>scm:git:git://github.com:curtys/webprotege-attestation.git</connection>
<url>https://github.com/curtys/webprotege-attestation.git</url>
</scm>

<prerequisites>
Expand Down Expand Up @@ -444,6 +444,16 @@
</application.analytics>
</properties>
</profile>
<profile>
<id>dev</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<data.directory>${project.basedir}/../.devdata</data.directory>
</properties>

</profile>
</profiles>

<modules>
Expand All @@ -454,5 +464,6 @@
<module>webprotege-client</module>
<module>webprotege-shared-core</module>
<module>webprotege-cli</module>
<module>webprotege-attestation-lib</module>
</modules>
</project>
114 changes: 62 additions & 52 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,101 @@
WebProtégé
Fork of WebProtégé implementing ontology attestation and verification
==========

What is WebProtégé?
-------------------
Modification of the [WebProtégé ontology editor](https://github.com/protegeproject/webprotege) to support ontology attestation by implementing a custom portlet. See the original readme below for
instructions for WebProtégé in general. To run a pre-built docker image see the section ["Running from docker"](#running-from-docker).

WebProtégé is a free, open source collaborative ontology development environment.
## Relevant links
- For further documentation see the [Attestation library module](webprotege-attestation-lib) and its [readme](webprotege-attestation-lib/README.md)
- Attestation portlet [usage guide](docs/guide.md)
- [Dataset](webprotege-attestation-lib/dataset) and results used for publication

It provides the following features:
- Support for editing OWL 2 ontologies
- A default simple editing interface, which provides access to commonly used OWL constructs
- Full change tracking and revision history
- Collaboration tools such as, sharing and permissions, threaded notes and discussions, watches and email notifications
- Customizable user interface
- Support for editing OBO ontologies
- Multiple file formats for upload and download of ontologies (supported formats: RDF/XML, Turtle, OWL/XML, OBO, and others)
## Requirements

WebProtégé runs as a Web application. End users access it through their Web browsers.
They do not need to download or install any software. We encourage end-users to use
- Development requirements of the attestation module for compiling and deploying smart contracts:
- [solc 7.1.0+](https://docs.soliditylang.org/en/v0.8.10/installing-solidity.html#linux-packages)
- [web3j-cli](http://docs.web3j.io/4.8.7/command_line_tools/)
- [Node and NPM](https://nodejs.org/en/)
- [Metamask](metamask.io) (or other wallet plugin) for client blockchain interaction
- [Docker Compose](https://docs.docker.com/compose/install/)
- Java 8 and Maven

https://webprotege.stanford.edu

If you have downloaded the webprotege war file from GitHub, and would like to deploy it on your own server,
please follow the instructions at:

https://github.com/protegeproject/webprotege/wiki/WebProtégé-4.0.0-beta-x-Installation

Building
--------
## Building for development

To build WebProtégé from source

1) Clone the github repository
```
git clone https://github.com/protegeproject/webprotege.git
```
2) Open a terminal in the directory where you clone the repository to
3) Use maven to package WebProtégé
1. Clone the github repository
2. Open a terminal in the directory where you clone the repository
3. Use maven to package WebProtégé
```
mvn clean package
```
5) The WebProtege .war file will be built into the webprotege-server directory
To ignore tests use
```
mvn clean package -DskipTests=True
```
5. The WebProtege .war file will be built into the webprotege-server directory

Running from Maven
------------------
## Starting in DevMode

To run WebProtégé in SuperDev Mode using maven
- first, consider following the instructions of the **attestation module** to set up an Ethereum test network
- start the database with `docker-compose up -d wpmongo`
- start the GWT code server with `mvn gwt:codeserver`
- in a different terminal start a tomcat server instance with `mvn -P dev -Denv=dev tomcat7:run`. The maven profile `-P dev` will result in WebProtégé storing its data in `.devdata` instead of the default directory (`/srv/webprotege`).
- first time starting up (or after resetting the database) an admin user has to be created.
Executed the **webprotege-cli** JAR (compile it, if not already done). E.g.,
`java -jar webprotege-cli/target/webprotege-cli-{version}.jar create-admin-account`
- by default, WebProtégé is available on [http://localhost:8080](http://localhost:8080).
- After the first start, some application settings need to be configured. Login to [localhost:8080/#application/settings](the settings page) with the previously created admin account.

1) Start the GWT code server in one terminal window
```
mvn gwt:codeserver
```
2) In a different terminal window start the tomcat server
```
mvn -Denv=dev tomcat7:run
```
3) Browse to WebProtégé in a Web browser by navigating to [http://localhost:8080](http://localhost:8080)
Detailed installation instructions can be found in the [official wiki](https://github.com/protegeproject/webprotege/wiki/WebProt%C3%A9g%C3%A9-4.0.0-Installation).

Running from Docker
-------------------
## Running from Docker

To run WebProtégé using Docker containers:
A pre-built docker image is available. To run the project stack from docker:

1. Enter this following command in the Terminal to start the docker container in the background
1. Enter this following command in the Terminal to start the docker container in the background. This will start containers for all dependand services as well, i.e., MongoDB and Ganache.

```bash
docker-compose up -d
```
1. Deploy the smart contracts (e.g., to Ganache). Follow the instructions [here](webprotege-attestation-lib/README.md).

2. Create the admin user (follow the questions prompted to provider username, email and password)
1. Create the admin user (follow the questions prompted to provider username, email and password)

```bash
docker exec -it webprotege java -jar /webprotege-cli.jar create-admin-account
```

3. Browse to WebProtégé Settings page in a Web browser by navigating to [http://localhost:5000/#application/settings](http://localhost:5000/#application/settings)
1. Define the `System notification email address` and `application host URL`
2. Enable `User creation`, `Project creation` and `Project import`
1. Browse to WebProtégé Settings page in a Web browser by navigating to [http://localhost:5000/#application/settings](http://localhost:5000/#application/settings)
1. Define the `System notification email address` and `application host URL`
2. Enable `User creation`, `Project creation` and `Project import`

To stop WebProtégé and MongoDB:
To stop WebProtégé, MongoDB and the Ganache test instance:

```bash
docker-compose down
```

Sharing the volumes used by the WebProtégé app and MongoDB allow to keep persistent data, even when the containers stop. Default shared data storage:
Sharing the volumes used by the WebProtégé app and MongoDB allows for keeping persistent data, even when the containers stop. Default shared data storage:

* WebProtégé will store its data in the source code folder at `./.protegedata/protege` where you run `docker-compose`
* MongoDB will store its data in the source code folder at `./.protegedata/mongodb` where you run `docker-compose`

> Path to the shared volumes can be changed in the `docker-compose.yml` file.

By default, a Ganache test blockchain will be started. WebProtégé is pre-configured to use this chain. It is possible to change the chain by setting environment variables in `docker-compose.yml` (of the servcie `webprotege-attestation`):
```yaml
environment:
- webprotege.mongodb.host=wpmongo
- ADDRESS_ATTESTATION=<the smart contract address>
- PROVIDER_HOST=<host name of the RPC endpoint provider>
- PROVIDER_PORT=<port of the RPC endpoint provider>
```

## Changes made in this fork
Some key classes were altered to integrate an attestation
portlet in the editor. The portlet can be added by choosing 'Attestation' from the list of available portlets,
e.g. when adding a new tab.
In the graphic below the altered classes are marked in red and the added packages in green.

![docs/package_protege.png](docs/package_protege.png)
42 changes: 42 additions & 0 deletions webprotege-attestation-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Java (general)
*.class
bin/

# Maven
target/
*.releaseBackup

# Eclipse
.project
.classpath
.settings/
/build

# IntelliJ
.idea/
*.iml
*.iws

# VisualCode
**/.vscode/

# Netbeans
build.xml
manifest.mf
nbproject/
/data

# Subversion
.svn

# Mac
.DS_Store

# npm
**/node_modules/

/bin
/results
*.owl
*.rdf
*.ttl
56 changes: 56 additions & 0 deletions webprotege-attestation-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## Ontology attestation and verification module for WebProtégé

A module for WebProtégé, implementing an approach for ontology attestation. See also the [usage guide](../docs/guide.md).

## Development requirements
* [solc 7.1.0+](https://docs.soliditylang.org/en/v0.8.10/installing-solidity.html#linux-packages)
* [web3j-cli](http://docs.web3j.io/4.8.7/command_line_tools/)
* [Node and NPM](https://nodejs.org/en/)
* [Ganache / Ganache CLI](https://trufflesuite.com/ganache/)
* [Metamask](metamask.io) (or other wallet plugin) for client blockchain interaction
* Java 8 + Maven

## Building the module
The module can be compiled and installed locally with `mvn clean install`. The smart contracts need to be compiled and deployed separately.

## Compiling and deploying the smart contracts
The `scripts` folder contains utilities for compiling and deploying the contracts.
1. Compile solidity contracts (requires `solc`):
```
sh ./compile-contracts.sh
```
2. Generate Java contract interfaces and wrappers (only needed for development purposes, requires `web3j-cli` and `solc`):
```
sh ./generate-contract-wrappers.sh
```
3. Start a local Ganache test blockchain with the docker-compose file in the [parent directory](../readme.md) (execute from the project root).
```
docker-compose up -d ganache
```
4. The seed is fixed, use the mnemonic indicated in the docker-compose file to access the test accounts (in Metamask this is the "Secret Recovery Phrase").

5. Deploy contracts (execute from the `scripts` folder, requires `node` and `npm`):
The connection to the chain is confiigured in the `.env` file in the same folder and is pre-configured for Ganache as started by `docker-compose.yml`.
```
npm install
npm run deploy
```

## Configuration
The contract address must be made available to the application server. To do this, configure the address in `src/main/java/resources/configuration/config.properties`.
Alternatively, the address may be set n the environment with the key `ADDRESS_ATTESTATION`, the RPC provider host and port by `PROVIDER_HOST` and `PROVIDER_PORT` respectively. These can also be set inside the `docker-compose.yml` file as follows in the service definition of `webprotege-attestation`.

```yaml
environment:
- webprotege.mongodb.host=wpmongo
- ADDRESS_ATTESTATION=<the smart contract address>
- PROVIDER_HOST=<host name of the RPC endpoint provider>
- PROVIDER_PORT=<port of the RPC endpoint provider>
```

## Dataset & Running the tests
The evaluation dataset and test results can be found in the folder `dataset/`.
The tests require the ontologies to be placed in `src/test/resources/ontologies`.

Configuration of the test blockchain provider are located in `src/test/resources/configuration`. The tests use the JUnit
framework and can thus be run manually by an appropriate runner, e.g., through Intellij.
Binary file not shown.
Binary file not shown.