commit | ad6ff4b64ec9536fcf8b69624986f7c312c80742 | [log] [tgz] |
---|---|---|
author | Philippe Larose <philippe.larose@savoirfairelinux.com> | Tue Apr 02 11:03:41 2024 -0400 |
committer | Philippe Larose <philippe.larose@savoirfairelinux.com> | Tue Apr 02 11:03:41 2024 -0400 |
tree | b9673ef6e2375265000a375efadc952e3f750c57 | |
parent | 8988640b6750612995463a80e39c6c13280b7a9a [diff] |
jams-react-client: Handle revoked contact Fixes holes in the contact list where contact that are revoked user where still attempted to be displayed Ticket: https://redmine.savoirfairelinux.com/issues/7449 Change-Id: Ib3fddf6c4b24bbd90e30d15b00c45cb306443bec
Clone the contents of this repository and run
mvn clean package
This will create a distribution folder called jams
in the root folder. You can then launch the server by running
cd jams java -jar jams-launcher.jar
If you want to start the server with an SSL certificate and on a port different from 8080, then run:
java -jar jams-launcher.jar 8443 server.pem server.key
Where the pem
and key
files are a pem encoded certificate and key.
In order to generate a pair of pem and key use the following command using openssl.
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout server.key -out server.pem
Note that a self signed certificate will be rejected from opendht, QNetworkAccessManager and other curl-like program by default. The following changes should disable those checks.
src/http.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 6b7d4aad..f10a4138 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -111,7 +111,7 @@ std::shared_ptr<asio::ssl::context> newTlsClientContext(const std::shared_ptr<dht::Logger>& logger) { auto ctx = std::make_shared<asio::ssl::context>(asio::ssl::context::tls_client); - ctx->set_verify_mode(asio::ssl::verify_peer | asio::ssl::verify_fail_if_no_peer_cert); + ctx->set_verify_mode(asio::ssl::verify_peer); if (char* path = getenv("CA_ROOT_FILE")) { if (logger) @@ -160,7 +160,7 @@ Connection::Connection(asio::io_context& ctx, std::shared_ptr<dht::crypto::Certi asio::error_code ec; if (server_ca) { ssl_ctx_ = std::make_shared<asio::ssl::context>(asio::ssl::context::tls_client); - ssl_ctx_->set_verify_mode(asio::ssl::verify_peer | asio::ssl::verify_fail_if_no_peer_cert); + ssl_ctx_->set_verify_mode(asio::ssl::verify_peer); auto ca = server_ca->toString(false/*chain*/); ssl_ctx_->add_certificate_authority(asio::const_buffer{ca.data(), ca.size()}, ec); if (ec) @@ -488,6 +488,7 @@ Connection::set_ssl_verification(const std::string& hostname, const asio::ssl::v ssl_socket_->asio_ssl_stream().set_verify_callback([ id = id_, logger = logger_, hostname, checkOcsp = checkOcsp_ ] (bool preverified, asio::ssl::verify_context& ctx) -> bool { + return true; X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); if (logger) { char subject_name[1024]; @@ -1218,7 +1219,7 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb) conn_ = std::make_shared<Connection>(ctx_, server_ca_, client_identity_, logger_); else conn_ = std::make_shared<Connection>(ctx_, true/*ssl*/, logger_); - conn_->set_ssl_verification(get_url().host, asio::ssl::verify_peer | asio::ssl::verify_fail_if_no_peer_cert); + conn_->set_ssl_verification(get_url().host, asio::ssl::verify_peer); } else conn_ = std::make_shared<Connection>(ctx_, false/*ssl*/, logger_);
// jami-client-qt/src/app/networkmanager.cpp NetworkManager::NetworkManager QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration(); sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone); QSslConfiguration::setDefaultConfiguration(sslConfig);
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:35000 -jar jams-server.jar 8080
The code was formatted using google-java-format
that can be installed with npm:
npm install --global google-java-format
And is used with the following command:
google-java-format -i -a --skip-reflowing-long-strings **/*.java
To generate the documentation you will need apidoc
installed on your system. This can be completed by running npm install -g apidoc
, if for some reason that does not work, you can clone their project from : https://github.com/apidoc/apidoc and install it from source.
To build the documentation, enter the jams-server
directory and simply run:
apidoc -i src/ -o doc/
You can then open doc/index.html
. Click on 1.0.0 in the top right corner if the doc doesn't appear.
The extras
folder contains a pre-commit hook that formats every js and java file. To enable it, run:
cp extras/scripts/pre-commit .git/hooks chmod +x .git/hooks/pre-commit
A development environment with react hot reloading can be created using:
docker build -f Dockerfile -t jams:dev --target dev . docker run -it -p 3000:3000 -p 8080:8080 -p 35000:35000 \ -v $(pwd)/jams-react-client/src:/app/jams-react-client/src \ -v $(pwd)/jams-react-client/public:/app/jams-react-client/public \ --rm jams:dev
setup_jams.sh
can be used to quickly do the initial setup. The script creates user alice, bob, charlie and danny, all with the password "a", and they all belong to the group "defaultGroup".
./extras/scripts/setup_jams.sh
Note: It is possible that after 15 minutes, the user's token expires, the server will answer with a "You are not authentified" and forget to put the CORS headers, thus the browser will refuse to read the response. In this case, you will need to restart the server.
The following commands will generate the userguide and the jars needed:
docker build -f Dockerfile -t jams:latest --target prod . \ && CONTAINER=$(docker create jams:latest) \ && docker cp $CONTAINER:/app/jams/. jams \ && docker cp $CONTAINER:/app/versions.json . \ && docker rm -v $CONTAINER \ && cd jams \ && java -jar jams-launcher.jar
mvn clean test # to open the report files in the browser for f in */target/site/jacoco/index.html ; do xdg-open $f ; done # (optional) if the file doesn't open in your browser TYPE=$(xdg-mime query filetype datastore/target/site/jacoco/index.html) xdg-mime default firefox.desktop "$TYPE"
The DBeaver Community software can help visualize the database schema. You can install it from its official website. Once installed, here are the steps to access the database:
You can also use Apache Derby's official ij cli tool to access the database.
The files in the filters
folder are prefixed "A", "B", "C" and "D" so that the order of execution of the filters are right (jakarta registers filters in alphabetical order).