Skip to content

Commit 31bc983

Browse files
authored
Merge pull request #27 from SendSafely/3.1.12
v3.1.12
2 parents f93bb55 + d140ed7 commit 31bc983

File tree

10 files changed

+21
-22
lines changed

10 files changed

+21
-22
lines changed

SampleApplication/README.MD

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
SampleApplication is intended to provide a starting point for building custom Java application integrations using the SendSafely Java Client API.
22

33
# Instructions
4-
Download the most recent release of the SendSafely Client API from [GitHub](https://github.com/SendSafely/Java-Client-API/releases) or a [public maven repository](https://mvnrepository.com/artifact/com.sendsafely/sendsafely-java-api) and copy the jar files into the SampleApplication/lib folder. Alternatively, build and run SampleApplication using the Maven instructions below.
4+
Build and run SampleApplication using the Maven instructions below.
55

6-
## Manual
7-
### Build
8-
9-
`mkdir bin`
10-
11-
`javac -cp "lib/*" -d bin src/*.java`
12-
13-
### Run (macOS/Linux)
14-
15-
```
16-
java -cp "lib/*:bin" SendSafelyRefApp
17-
```
18-
19-
### Run (Windows)
206

21-
```
22-
java -cp "lib/*;bin/" SendSafelyRefApp
23-
```
247
## Maven
258
### Build
269
```mvn clean compile package```

SampleApplication/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<dependency>
1717
<groupId>com.sendsafely</groupId>
1818
<artifactId>sendsafely-java-api</artifactId>
19-
<version>3.1.11</version>
19+
<version>3.1.12</version>
2020
</dependency>
2121
</dependencies>
2222

SendSafelyAPI/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Use the following dependency in your project to grab via Maven:
66
<dependency>
77
<groupId>com.sendsafely</groupId>
88
<artifactId>sendsafely-java-api</artifactId>
9-
<version>3.1.11</version>
9+
<version>3.1.12</version>
1010
</dependency>
1111
```
1212

SendSafelyAPI/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.sendsafely</groupId>
66
<artifactId>sendsafely-java-api</artifactId>
7-
<version>3.1.11</version>
7+
<version>3.1.12</version>
88
<name>SendSafely Java Client API</name>
99
<description>The SendSafely Client API allows programmatic access to SendSafely and provides a layer of abstraction from our REST API, which requires developers to perform several complex tasks in a correct manner.</description>
1010
<url>https://developer.sendsafely.com</url>

SendSafelyAPI/src/com/sendsafely/utils/CryptoUtil.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,27 @@ public static String encryptKeycode(String publicKeyStr, String keycode) throws
369369
Iterator kIt = kRing.getPublicKeys();
370370
while (key == null && kIt.hasNext()) {
371371
PGPPublicKey k = (PGPPublicKey) kIt.next();
372-
if (k.isEncryptionKey() /*&& CanEncrypt(k.getSignatures()*/) { //Enable CanEncrypt check in future version of SDK
372+
if (k.isEncryptionKey() && CanEncrypt(k.getSignatures())) {
373373
key = k;
374374
}
375375
}
376376
}
377+
// if no encrypt key was found then see if we can use the signing key.
378+
// this is only to provide legacy support for incorrectly formatted keys that don't have an encryption key.
379+
if (key == null) {
380+
rIt = pgpPub.getKeyRings();
381+
while (key == null && rIt.hasNext()) {
382+
PGPPublicKeyRing kRing = (PGPPublicKeyRing) rIt.next();
383+
Iterator kIt = kRing.getPublicKeys();
384+
while (key == null && kIt.hasNext()) {
385+
PGPPublicKey k = (PGPPublicKey) kIt.next();
386+
if (k.isEncryptionKey()) {
387+
key = k;
388+
}
389+
}
390+
}
391+
}
392+
// if the key is still null then throw an exception
377393
if (key == null) {
378394
throw new IllegalArgumentException("Can't find encryption key in key ring.");
379395
}

0 commit comments

Comments
 (0)