Commit Graph

59 Commits

Author SHA1 Message Date
Jordan Rose
3f0d2b1384 Revert "java: Publish to GitHub Packages instead of Maven Central"
This reverts commit b2c5685080.
2025-11-07 11:37:25 -08:00
Jordan Rose
b2c5685080 java: Publish to GitHub Packages instead of Maven Central 2025-11-06 16:36:17 -08:00
moiseev-signal
177a495eba java: Use kotlin.Pair 2025-11-06 15:37:29 -08:00
Jordan Rose
ea343a89ab jni: Native.java -> Native.kt
Improvements included in this first iteration:
- Nullable/non-nullable!
- ObjectHandle typealias for Long
- Fixed handling for CompletableFuture<Void> (previously translated
  without generics at all in some cases)

Co-authored-by: Alex Bakon <akonradi@signal.org>
2025-08-08 14:41:22 -07:00
Jordan Rose
a881fcf0f3 java: Align CompletableFuture cancellation behavior with OpenJDK's 2025-07-25 13:24:29 -07:00
Jordan Rose
b2c2537277 java: Switch from javadoc to Dokka to include our Kotlin sources
The Maven publication will still contain a -javadoc jar for
consistency, but the -dokka jar is likely to have superior rendering
in practice, particularly for Kotlin-only APIs!
2025-06-18 10:57:50 -07:00
Alex Bakon
3c89a5fa07 Colocate Kotlin sources with Java 2025-06-12 16:00:05 -04:00
Alex Bakon
033abcf96f Support checking Java @CalledFromNative annotation 2025-06-02 13:02:41 -04:00
Alex Bakon
14adc1c74d Introduce Kotlin to the libsignal Java library 2025-05-23 09:57:41 -04:00
Jordan Rose
497d88b0b6 java: Add a shim to handle Base64 on both Android and Oracle Java 2024-10-24 16:59:42 -07:00
Jordan Rose
4e22da3293 Add BackupCredentialType to BackupAuthCredential
Rename BackupLevel::{Messages, Media} to {Free, Paid}, then add 
BackupCredentialType::{Messages, Media}.

This is a breaking change for apps and the server, both because of the
new names, and because the credential attributes have changed (both
what's in a serialized credential, and what's included in the
signature).
2024-10-23 13:03:53 -07:00
Jordan Rose
d9187a4db3 jni: Handle absurd numbers of recipients in multi-recipient messages
Previously we tried to be Fast by allocating a big local frame, enough
references for all the recipients we parsed. However, that backfired
if there were so many recipients that we couldn't allocate the local
frame. Switch to using AutoLocal references, so we have a fixed
overhead.

One interesting consequence of this is that we can't build the array
of excluded recipients in one go; instead, we now use a helper
java.util.ArrayList that we push into. Fortunately, we only exposed a
List in the public interface anyway.
2024-08-05 11:23:40 -07:00
Jordan Rose
11544c6718 java: Omit native libraries from the sources jars
...at least partly to cut down on the space used during a build that
includes all supported architectures.
2024-08-02 09:54:43 -07:00
Jonathan Klabunde Tomer
0453438d98 Prepare libsignal-server Java build for arm64 2024-07-30 13:37:55 -07:00
Chris Eager
4a3d4aecd5 Add SealedSenderMultiRecipientMessage#serializedRecipientView
This allows a server to parse and validate a multi-recipient message once,
and then efficiently store per-recipient views for future delivery.
2024-07-23 10:16:02 -07:00
Chris Eager
f26fd13631 Add SealedSenderMultiRecipientMessage#serialized 2024-06-26 17:01:01 -05:00
Jordan Rose
9f53f3d1e7 BackupAuthCredential: verify the redemption time on receive
This is passed both within the credential response and outside it, so
it's important to make sure the two times match.
2024-04-19 13:41:59 -07:00
ravi-signal
9204831745 Use an enum for BackupAuthCredential's level 2024-04-19 11:46:49 -07:00
Jordan Rose
4b87577969 java: Print all test outcomes as they run (not just passes)
Failures would still have been caught in the aggregate test results;
but if we're going to print successes we should print skips and
failures too. (This was just an oversight.)
2024-04-17 10:21:41 -07:00
Jordan Rose
f896129db9 Java: Update to Gradle 8.4, Android Gradle Plugin 8.3, SDK 34, Java 17
Each of these updates is required for the following update, and the
final one allows us to use 'record'.

The target SDK version is set to 33, matching the Android app.
2024-03-08 10:34:18 -08:00
Jordan Rose
4f4d21a8ca java: Mark all bridge_fns that return Result as throws Exception
Then, use FilterExceptions to filter out any exceptions that aren't
declared in the calling method's exception spec. Note that this isn't
perfect: Java's checks for typed exceptions prevents an *extra*
exception from being thrown this way, but it's still possible to
forget to *allow* an exception using FilterExceptions.

This is 99% a mechanical change; the interesting bit is in
gen_java_decl.py and one unusual pattern in NativeErrorsTest.java. No
exception specs were changed here.
2024-02-22 13:34:57 -08:00
Alex Konradi
8959e64ed1 Build TESTING_ functions for Android test
Run tests that call native TESTING_ functions on Android. This requires 
building a separate version of libsignal_jni.so with the testing functions 
included. The test code is still omitted from the published artifacts.
2024-02-15 16:53:05 -05:00
Alex Konradi
d08adf19bb Return username candidates as string array
Use the string bridging code introduced previously to provide string arrays to 
client directly instead of joining and splitting. This eliminates the use of a 
magic ',' character as a delimiter.
2024-02-06 09:46:06 -05:00
Alex Konradi
72ccec8cdd Fix java tests
- use int instead of promoting to long
- add missing return type to fix compilation
 - run auto-formatter

Also add the check that would have caught all of these to CI
2024-01-10 14:48:13 -05:00
Jonathan Klabunde Tomer
c3cb6ed0bf expose non-copying method on SealedSenderMultiRecipientMessage to get message size for a recipient 2024-01-09 11:28:12 -08:00
Alex Konradi
1c6e8e512d Fix CompletableFuture error handling
Fix the behavior of CompletableFuture.thenApply so that if the applied function
throws an exception, the pending future receives the exception (instead of never
completing). Add tests.
2023-11-30 15:38:22 -05:00
Jordan Rose
caf3dade92 Java: Add -Xcheck:jni to host testing
This can give better error messages for JNI mistakes that might
otherwise crash or go unnoticed. Tested by introducing such a mistake.
(Though it's hard to do with the jni crate's safe interfaces, which is
a good thing!)

The Android Emulator always has its equivalent checks on, so the Slow
Tests are also giving us some confidence about our JNI usage.
2023-11-15 10:17:26 -08:00
Alex Konradi
4c78373114 Expose libsignal-net function for CDSI via JNI
Expose the existing CDSI lookup async function to Java clients. Provide a small
library that can be easily integrated into the existing codebase.
2023-11-15 10:00:46 -05:00
akonradi-signal
3d8933ec96 Add CompletableFuture.thenApply method
Add the ability to chain futures by applying arbitrary functions. Mirrors
CompletableFuture.thenApply in the Java standard library.
2023-11-13 15:06:40 -05:00
Jordan Rose
9839a5be79 Always use the original SSv2 version byte, 0x22, for ReceivedMessages
The format hasn't changed, so we don't need to bump the version number
for the messages the server sends to recipients.

This is implemented in two places: the Rust side for round-trip
testing, and the Java side for what the server actually does. (Both
are implemented to avoid unnecessary copies and unfortunately the two
aren't conveniently compatible with one another, but it's a simple
implementation anyway.)
2023-11-10 09:30:39 -08:00
Jordan Rose
0c13580240 SSv2: Add receive support for excluded recipients
These are encoded as having a device ID of zero. Rust-level tests will
come with the send support, so we can do round-trip tests.
2023-11-07 16:25:22 -08:00
Jordan Rose
b618fd58e7 SSv2: Require known versions in SealedSenderV2SentMessage::parse
And if we're not trying to be open to future versions, we can validate
that there's enough bytes for the ephemeral public key as well.
2023-11-07 16:25:22 -08:00
Jordan Rose
418886c599 SSv2: Add server receive support for compact device lists
This takes advantage of the fact that multiple devices for the same
user will have the same identity key and therefore will use the same
per-recipient SSv2 data anyway.

This commit also enforces (on the server side) that device IDs are in
the range 1..=127 for destinations of a SSv2 message; previously they
were varint-encoded.

When send support is added, the round-trip Rust tests will
automatically start testing this as well.
2023-11-07 16:25:22 -08:00
Jordan Rose
64d5996825 Expose SSv2 message parsing in libsignal-server 2023-11-07 12:19:14 -08:00
ravi-signal
9c79bc97cb zkgroup: move java BackupAuthTest to server lib
This test does base64 decoding which differs between android 21 and
non-android platforms.
2023-10-26 13:15:25 -05:00
Jordan Rose
55a1958a15 Test various error and panic scenarios for bridge_fn and bridge_io 2023-10-12 12:23:22 -07:00
Jordan Rose
ae47f039fa bridge: Add a bridge_io macro that expects a runtime
For now, the "runtime" is spawning a thread that then uses
now_or_never, but eventually this will be a persistent tokio runtime
of some kind.

Also for now, this is only implemented for Java. Swift and Node
support coming soon.
2023-10-02 14:08:10 -07:00
Jordan Rose
5fde77a631 Don't include the Future testing APIs when building for Android 2023-09-27 06:48:21 -07:00
Jordan Rose
a563c9b93d Java: Add a bare-bones Future implementation for upcoming async APIs 2023-09-27 06:48:21 -07:00
Jordan Rose
3810154436 Automate the Android and Server publishing to Sonatype 2023-08-25 12:33:56 -07:00
Jordan Rose
e11a825fe3 Gradle: Adopt Nexus plugin to automatically close releases on Sonatype 2023-08-24 12:21:25 -07:00
Jordan Rose
b27f5c0f2e Gradle: Set version and group info in the root project
This will be necessary to adopt the Gradle Nexus publishing plugin,
but it's also just simpler.
2023-08-24 12:21:25 -07:00
moiseev-signal
f9471c9c68 Set up and apply code formatting for Java 2023-08-22 09:15:23 -07:00
Jordan Rose
761c8080ee java: Reorganize tests 2023-07-27 15:40:44 -07:00
Jordan Rose
6800244a53 protocol: Add the ServiceId, Aci, and Pni types
Co-authored-by: Max Moiseev <moiseev@signal.org>
2023-07-13 13:54:53 -07:00
Sergey Skrobotov
ca262db5ec bridge for username links 2023-07-06 15:51:52 -07:00
moiseev-signal
7d37b1c2f8 Better handle incremental mac edge case 2023-06-28 10:56:25 -07:00
moiseev-signal
2b46ae1e85 Implement incremental MAC 2023-05-09 12:29:25 -07:00
Ravi Khadiwala
1f8c279622 pin: Add pin hashing and an svr2 client
- Add a new SGX client that can be used for testing svr2
- Add pin hashing that can be used with svr1 and svr2
2023-03-29 13:59:28 -05:00
Max Moiseev
0bd497d5e8 Make tests more deterministic 2023-02-13 11:06:49 -08:00