Skip to content

Commit ee5f08a

Browse files
committed
feat: v1.0.0-SNAPSHOT, support GnuPG
1 parent fe4f297 commit ee5f08a

File tree

12 files changed

+485
-179
lines changed

12 files changed

+485
-179
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
.DS_Store
12
*.class
23
*.jar
34

45
# Maven #
56
target/
67
pom.xml.versionsBackup
8+
dependency-reduced-pom.xml
79

810
# IntelliJ Settings Files (https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems) #
911
.idea/**/workspace.xml

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2021-2024 Ralph Plawetzki
4+
Copyright (c) 2024-2024 Hatter Jiang
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
1-
# keepassxc-cryptomator
2-
![keepassxc-cryptomator](keepassxc-cryptomator.svg)
1+
# gnupg-cryptomator
2+
3+
> This project is fork from https://github.com/purejava/keepassxc-cryptomator , add GnuPG support
34
4-
[![Java CI with Maven](https://github.com/purejava/keepassxc-cryptomator/workflows/Java%20CI%20with%20Maven/badge.svg)](https://github.com/purejava/keepassxc-cryptomator/actions?query=workflow%3A%22Java+CI+with+Maven%22)
5-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f092de6bfd99450f8a9a2766ed01c3c1)](https://app.codacy.com/gh/purejava/keepassxc-cryptomator?utm_source=github.com&utm_medium=referral&utm_content=purejava/keepassxc-cryptomator&utm_campaign=Badge_Grade_Settings)
65
[![GitHub Release](https://img.shields.io/github/v/release/purejava/keepassxc-cryptomator)](https://github.com/purejava/keepassxc-cryptomator/releases)
76
[![License](https://img.shields.io/github/license/purejava/keepassxc-cryptomator.svg)](https://github.com/purejava/keepassxc-cryptomator/blob/master/LICENSE)
8-
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate?hosted_button_id=XVX9ZM7WE4ANL)
97

10-
Plug-in for Cryptomator to store vault passwords in KeePassXC
8+
Plug-in for Cryptomator to store vault passwords with GnuPG encryption.
119

12-
# Documentation
13-
For documentation please take a look at the [Wiki](https://github.com/purejava/keepassxc-cryptomator/wiki).
10+
# Build Project
11+
12+
Requirement:
13+
14+
* JDK 17 or later
15+
* Maven 3.8.4 or later
16+
17+
```shell
18+
mvn package
19+
```
20+
21+
Copy plugin in `target/gnupg-cryptomator-1.0.0-SNAPSHOT.jar` to Cryptomator plugins dir.
22+
> Usage reference [Wiki](https://github.com/purejava/keepassxc-cryptomator/wiki)
1423
15-
# Donation
16-
If you like this project, you can give me a cup of coffee :)
24+
# Configuration
1725

18-
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate?hosted_button_id=XVX9ZM7WE4ANL)
26+
Config file location:
27+
28+
* `/etc/cryptomator/config.json`
29+
* `~/.config/cryptomator/config.json`
30+
31+
Keys will store in directory:
32+
`~/.config/cryptomator/keys/`
33+
34+
# Documentation
35+
36+
For documentation please take a look at the [Wiki](https://github.com/purejava/keepassxc-cryptomator/wiki).
1937

2038
# Copyright
39+
2140
Copyright (C) 2021-2024 Ralph Plawetzki
41+
Copyright (C) 2024-2024 Hatter Jiang
2242

2343
The Cryptomator logo is Copyright (C) of https://cryptomator.org/
2444

build.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"java": "17",
3+
"builder": {
4+
"name": "maven",
5+
"version": "3.8.4"
6+
}
7+
}

pom.xml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
<groupId>org.purejava</groupId>
7-
<artifactId>keepassxc-cryptomator</artifactId>
8-
<version>1.2.6-SNAPSHOT</version>
6+
<groupId>me.hatter</groupId>
7+
<artifactId>gnupg-cryptomator</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
99

10-
<name>keepassxc-cryptomator</name>
11-
<description>Plug-in for Cryptomator to store vault passwords in KeePassXC</description>
12-
<url>https://github.com/purejava/keepassxc-cryptomator/</url>
10+
<name>gnupg-cryptomator</name>
11+
<description>Plug-in for Cryptomator to store vault passwords with GnuPG encryption.</description>
12+
<url>https://github.com/jht5945/gnupg-cryptomator/</url>
1313

1414
<licenses>
1515
<license>
@@ -26,12 +26,19 @@
2626
<organization/>
2727
<organizationUrl>https://github.com/purejava</organizationUrl>
2828
</developer>
29+
<developer>
30+
<name>Hatter Jiang</name>
31+
<email>jht5945@gmail.com</email>
32+
<timezone>+8</timezone>
33+
<organization/>
34+
<organizationUrl>https://github.com/jht5945</organizationUrl>
35+
</developer>
2936
</developers>
3037

3138
<scm>
32-
<connection>scm:git:git@github.com:purejava/keepassxc-cryptomator.git</connection>
33-
<developerConnection>scm:git:git@github.com:purejava/keepassxc-cryptomator.git</developerConnection>
34-
<url>git@github.com:purejava/keepassxc-cryptomator.git</url>
39+
<connection>scm:git:git@github.com:jht5945/gnupg-cryptomator.git</connection>
40+
<developerConnection>scm:git:git@github.com:jht5945/gnupg-cryptomator.git</developerConnection>
41+
<url>git@github.com:jht5945/gnupg-cryptomator.git</url>
3542
</scm>
3643

3744
<distributionManagement>
@@ -52,6 +59,7 @@
5259
<api.version>1.3.1</api.version>
5360
<keepassxc-proxy.version>1.2.5</keepassxc-proxy.version>
5461
<guava.version>33.2.1-jre</guava.version>
62+
<gson.version>2.11.0</gson.version>
5563
<slf4j.version>2.0.13</slf4j.version>
5664
<junit.version>5.10.2</junit.version>
5765
</properties>
@@ -78,6 +86,11 @@
7886
<artifactId>guava</artifactId>
7987
<version>${guava.version}</version>
8088
</dependency>
89+
<dependency>
90+
<groupId>com.google.code.gson</groupId>
91+
<artifactId>gson</artifactId>
92+
<version>${gson.version}</version>
93+
</dependency>
8194
<dependency>
8295
<groupId>org.purejava</groupId>
8396
<artifactId>keepassxc-proxy-access</artifactId>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package me.hatter.integrations.keychain;
2+
3+
import org.cryptomator.integrations.keychain.KeychainAccessException;
4+
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* @author hatterjiang
10+
*/
11+
public class GnuPGAccessProvider implements KeychainAccessProvider {
12+
13+
private static final Logger LOG = LoggerFactory.getLogger(GnuPGAccessProvider.class);
14+
15+
private GnuPGConfig gnuPGConfig;
16+
17+
public GnuPGAccessProvider() {
18+
try {
19+
gnuPGConfig = Utils.loadGnuPGConfig();
20+
if (!Utils.checkGnuPGReady(gnuPGConfig)) {
21+
LOG.error("Check GnuPG command failed");
22+
gnuPGConfig = null;
23+
}
24+
} catch (KeychainAccessException e) {
25+
gnuPGConfig = null;
26+
LOG.error("Load GnuPG config failed", e);
27+
}
28+
}
29+
30+
@Override
31+
public String displayName() {
32+
return "GnuPG";
33+
}
34+
35+
@Override
36+
public boolean isSupported() {
37+
return gnuPGConfig != null;
38+
}
39+
40+
@Override
41+
public boolean isLocked() {
42+
// No lock status
43+
return false;
44+
}
45+
46+
@Override
47+
public void storePassphrase(String vault, CharSequence password) throws KeychainAccessException {
48+
storePassphrase(vault, "Vault", password);
49+
}
50+
51+
@Override
52+
public void storePassphrase(String vault, String name, CharSequence password) throws KeychainAccessException {
53+
Utils.storePassword(gnuPGConfig, vault, name, password);
54+
}
55+
56+
@Override
57+
public char[] loadPassphrase(String vault) throws KeychainAccessException {
58+
final String password = Utils.loadPassword(gnuPGConfig, vault);
59+
return password.toCharArray();
60+
}
61+
62+
@Override
63+
public void deletePassphrase(String vault) throws KeychainAccessException {
64+
if (isLocked()) {
65+
LOG.info("Failed to delete password. KeePassXC database is locked. Needs to be unlocked first.");
66+
return;
67+
}
68+
Utils.deletePassword(gnuPGConfig, vault);
69+
}
70+
71+
@Override
72+
public void changePassphrase(String vault, CharSequence password) throws KeychainAccessException {
73+
changePassphrase(vault, "Vault", password);
74+
}
75+
76+
@Override
77+
public void changePassphrase(String vault, String name, CharSequence password) throws KeychainAccessException {
78+
LOG.info("Change password for: " + vault);
79+
Utils.storePassword(gnuPGConfig, vault, name, password);
80+
}
81+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package me.hatter.integrations.keychain;
2+
3+
/**
4+
* GnuPG config
5+
*
6+
* @author hatterjiang
7+
*/
8+
public class GnuPGConfig {
9+
/**
10+
* REQUIRED, GnuPG key ID
11+
*/
12+
private String keyId;
13+
/**
14+
* OPTIONAL, GnuPG command path, default "gpg"
15+
*/
16+
private String gnuPgCommand;
17+
/**
18+
* OPTIONAL, Encrypt key base path, default "~/.config/cryptomator/keys/"
19+
*/
20+
private String encryptKeyBasePath;
21+
22+
public String getKeyId() {
23+
return keyId;
24+
}
25+
26+
public void setKeyId(String keyId) {
27+
this.keyId = keyId;
28+
}
29+
30+
public String getGnuPgCommand() {
31+
return gnuPgCommand;
32+
}
33+
34+
public void setGnuPgCommand(String gnuPgCommand) {
35+
this.gnuPgCommand = gnuPgCommand;
36+
}
37+
38+
public String getEncryptKeyBasePath() {
39+
return encryptKeyBasePath;
40+
}
41+
42+
public void setEncryptKeyBasePath(String encryptKeyBasePath) {
43+
this.encryptKeyBasePath = encryptKeyBasePath;
44+
}
45+
}

0 commit comments

Comments
 (0)