Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a8d1796
PDF: PAdES signatures (PdfSignature, PdfSignatureInfo, PdfSigner)
shai-almog Nov 30, 2026
1f00ceb
PDF signing: gate fixes, backend-friendly provider docs, developer gu…
shai-almog Nov 30, 2026
48c6074
Lingo: scaffold from Fieldline (accounts, push, live, settings), fiel…
shai-almog Nov 30, 2026
d491391
Lingo: learning, certificates, community, studio, live signaling and …
shai-almog Nov 30, 2026
04de8f9
Lingo: backend tests for the learning loop, certificates, community, …
shai-almog Nov 30, 2026
7f6c20c
Lingo: shared tutor prompt, client tutor engines, voice, theme tokens
shai-almog Nov 30, 2026
e2887c5
Lingo: learner and studio screens
shai-almog Nov 30, 2026
eb1dd76
Lingo: Lingo copy throughout, l10n, telemetry and client tests
shai-almog Nov 30, 2026
6d6bbf1
Lingo: CI registration, layout and dark-mode polish, passing e2e
shai-almog Nov 30, 2026
a989e92
Lingo: web e2e for learner and creator, config docs, MIT-0 header exc…
shai-almog Nov 30, 2026
38391a1
Lingo: admin accounts console, Initializr template, README, polish
shai-almog Nov 30, 2026
432095d
Lingo: user's and implementor's guides, README row, real Initializr p…
shai-almog Nov 30, 2026
142e528
Lingo: resync Initializr template
shai-almog Nov 30, 2026
4b99d71
Lingo: iOS privacy strings for speech, microphone and camera; templat…
shai-almog Nov 30, 2026
19221e3
Lingo: fix the level progress, split the certificate chain without St…
shai-almog Nov 30, 2026
5bf12cb
Lingo: its own icon; tutor, video, certificate, live and desktop capt…
shai-almog Nov 30, 2026
0999613
Lingo docs: self-contained PDF signing snippets; guide wording that p…
shai-almog Nov 30, 2026
43575a6
Merge remote-tracking branch 'origin/master' into lingo-learning-sample
shai-almog Nov 30, 2026
b486a7b
Lingo: the cloud tutor is off until the learner opts in; ActivityTime…
shai-almog Nov 30, 2026
62687b5
Merge remote-tracking branch 'origin/master' into lingo-learning-sample
shai-almog Nov 30, 2026
584c753
Lingo: resync the Initializr template; guide prose LanguageTool accepts
shai-almog Nov 30, 2026
62e12fe
Merge remote-tracking branch 'origin/master' into lingo-learning-sample
shai-almog Dec 1, 2026
135f320
Backend tests: ask once per run whether a source backs each class
shai-almog Dec 1, 2026
4eece83
Merge master into lingo-learning-sample
shai-almog Dec 1, 2026
9273aac
Merge master into lingo-learning-sample
shai-almog Dec 1, 2026
b36fb42
Website build: expand the optional workspace args safely on bash 3.2
shai-almog Dec 1, 2026
8c45c4b
pre-push-gates: run the site build on JDK 25 and refresh stale snapshots
shai-almog Dec 1, 2026
3b625e4
pre-push-gates: build the site's apps against this tree's snapshots, …
shai-almog Dec 1, 2026
f9bde7e
Mermaid gate: retry a page that timed out loading Mermaid once
shai-almog Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ci/ci-members.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@
"scripts/pulse/**",
"scripts/slate/**",
"scripts/fieldline/**",
"scripts/lingo/**",
"scripts/splat/**",
"scripts/skirmish/**",
"scripts/papercut/**",
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/samples-ios-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
# Watch-app samples (dash, pulse, splat, slate) are the slow ones;
# they are split across the shards.
- shard: a
samples: ' parley savor dash pulse bastion fieldline papercut '
samples: ' parley savor dash pulse bastion fieldline lingo papercut '
- shard: b
samples: ' wayline reel splat slate skirmish bazaar '
steps:
Expand Down Expand Up @@ -188,6 +188,10 @@ jobs:
if: ${{ !cancelled() && contains(matrix.samples, ' fieldline ') }}
run: scripts/ci/build-sample-ios-simulator.sh scripts/fieldline
timeout-minutes: 45
- name: 'iOS: lingo'
if: ${{ !cancelled() && contains(matrix.samples, ' lingo ') }}
run: scripts/ci/build-sample-ios-simulator.sh scripts/lingo
timeout-minutes: 45
- name: 'iOS: skirmish'
if: ${{ !cancelled() && contains(matrix.samples, ' skirmish ') }}
run: scripts/ci/build-sample-ios-simulator.sh scripts/skirmish
Expand Down
150 changes: 147 additions & 3 deletions .github/workflows/samples.yml

Large diffs are not rendered by default.

510 changes: 510 additions & 0 deletions CodenameOne/src/com/codename1/impl/pdf/PdfCms.java

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions CodenameOne/src/com/codename1/pdf/PdfDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public final class PdfDocument {
private String creator;
private long creationDate = System.currentTimeMillis();
private boolean compress = true;
private PdfSignature signature;

/// Adds a page of `size` at the end of the document.
public PdfPage addPage(PdfPageSize size) {
Expand Down Expand Up @@ -142,6 +143,21 @@ public PdfDocument setCreationDate(long millis) {
return this;
}

/// Signs the document with `signature` when it is saved. Pass null to
/// save unsigned again. Every save signs afresh, so the bytes differ
/// between saves.
///
/// @throws IllegalArgumentException if a visible signature is placed on
/// a page of another document
public PdfDocument sign(PdfSignature signature) {
if (signature != null && signature.getPage() != null
&& signature.getPage().document() != this) { // NOPMD CompareObjectsWithEquals - the same document object is required
throw new IllegalArgumentException("The signature's page belongs to another document");
}
this.signature = signature;
return this;
}

/// Turns stream compression off, for a file that can be read in a text
/// editor while debugging. On by default.
public PdfDocument setCompress(boolean compress) {
Expand Down Expand Up @@ -205,6 +221,20 @@ public void save(OutputStream out) throws IOException {
if (pages.isEmpty()) {
addPage(PdfPageSize.A4);
}
if (signature == null) {
write(out, null);
return;
}
ByteArrayOutputStream bo = new ByteArrayOutputStream();
PdfPage target = signature.getPage() != null ? signature.getPage() : pages.get(0);
write(bo, target);
byte[] file = bo.toByteArray();
PdfSignatures.complete(file, signature);
out.write(file);
out.flush();
}

private void write(OutputStream out, PdfPage signedPage) throws IOException {
PdfWriter w = new PdfWriter(out);
int catalog = w.reserve();
int tree = w.reserve();
Expand All @@ -217,6 +247,11 @@ public void save(OutputStream out) throws IOException {
for (int i = 0; i < imageOrder.size(); i++) { // NOPMD ForLoopCanBeForeach - indexed like the surrounding decoder loops
imageObjects.put(imageOrder.get(i), Integer.valueOf(w.reserve()));
}
int sigField = 0;
if (signedPage != null) {
sigField = w.reserve();
signedPage.signatureWidget = sigField;
}
extGStateObjects = new int[extGStateOrder.size()];
for (int i = 0; i < extGStateObjects.length; i++) {
extGStateObjects[i] = w.reserve();
Expand Down Expand Up @@ -244,8 +279,15 @@ public void save(OutputStream out) throws IOException {
PdfImage img = imageOrder.get(i);
img.write(w, imageObject(img));
}
if (signedPage != null) {
signedPage.signatureWidget = 0;
PdfSignatures.writeField(w, signature, signedPage, sigField);
}
int outlines = bookmarks.isEmpty() ? 0 : writeOutlines(w);
StringBuilder cat = new StringBuilder("<</Type /Catalog /Pages ").append(tree).append(" 0 R");
if (signedPage != null) {
cat.append(" /AcroForm <</Fields [").append(sigField).append(" 0 R] /SigFlags 3>>");
}
if (outlines > 0) {
cat.append(" /Outlines ").append(outlines).append(" 0 R /PageMode /UseOutlines");
}
Expand Down
8 changes: 7 additions & 1 deletion CodenameOne/src/com/codename1/pdf/PdfPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public final class PdfPage {
private final List<PdfImage> images = new ArrayList<PdfImage>();
private final List<Object[]> links = new ArrayList<Object[]>();
int objectNumber;
/// The object number of the signature field's widget on this page while
/// a signed document is being saved, otherwise 0.
int signatureWidget;

PdfPage(PdfDocument document, float width, float height) {
this.document = document;
Expand Down Expand Up @@ -137,10 +140,13 @@ String resources() {
}

String annotations() {
if (links.isEmpty()) {
if (links.isEmpty() && signatureWidget == 0) {
return "";
}
StringBuilder sb = new StringBuilder(" /Annots [");
if (signatureWidget > 0) {
sb.append(signatureWidget).append(" 0 R ");
}
for (int i = 0; i < links.size(); i++) { // NOPMD ForLoopCanBeForeach - indexed like the surrounding decoder loops
Object[] link = links.get(i);
float[] r = (float[]) link[0];
Expand Down
174 changes: 174 additions & 0 deletions CodenameOne/src/com/codename1/pdf/PdfSignature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* Copyright (c) 2026, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/
package com.codename1.pdf;

/// Describes the digital signature [PdfDocument#sign(PdfSignature)] embeds
/// when the document is saved.
///
/// The result is a PAdES baseline (B-B) signature: a detached CMS
/// `SignedData` over the whole file, SHA-256, with the signer's
/// certificate. Acrobat, Preview and `pdfsig` report it as signed; whether
/// they call it *trusted* depends on the certificate, which is the
/// application's choice, not this class's.
///
/// ```java
/// PrivateKey key = PrivateKey.fromPem(new String(Util.readInputStream(
/// CN.getResourceAsStream("/signer-key.pem")), "UTF-8"));
/// byte[] certificateDer = Util.readInputStream(CN.getResourceAsStream("/signer.der"));
/// PdfDocument doc = new PdfDocument();
/// doc.addPage(PdfPageSize.A4);
/// // ... draw the certificate of completion ...
/// doc.sign(new PdfSignature(PdfSigner.provider(key, certificateDer))
/// .setReason("Certificate of completion")
/// .setLocation("Lingo Academy")
/// .setVisible(doc.getPage(0), 380, 40, 180, 50));
/// byte[] signed = doc.toByteArray();
/// ```
@com.codename1.impl.SharedWithBackend
public final class PdfSignature {
private final PdfSignatureProvider provider;
private String name;
private String reason;
private String location;
private String contactInfo;
private long signingTime = System.currentTimeMillis();
private PdfPage page;
private float x;
private float y;
private float width;
private float height;
private int reservedBytes = 12288;

/// A signature whose key material comes from `provider`.
public PdfSignature(PdfSignatureProvider provider) {
if (provider == null) {
throw new IllegalArgumentException("A signature needs a provider");
}
this.provider = provider;
}

/// The provider given to the constructor.
public PdfSignatureProvider getProvider() {
return provider;
}

/// The signer's name as shown by viewers; defaults to the certificate's
/// common name.
public PdfSignature setName(String name) {
this.name = name;
return this;
}

/// The signer's name, or null for the certificate's common name.
public String getName() {
return name;
}

/// Why the document was signed.
public PdfSignature setReason(String reason) {
this.reason = reason;
return this;
}

/// Why the document was signed, or null.
public String getReason() {
return reason;
}

/// Where the document was signed.
public PdfSignature setLocation(String location) {
this.location = location;
return this;
}

/// Where the document was signed, or null.
public String getLocation() {
return location;
}

/// How to reach the signer.
public PdfSignature setContactInfo(String contactInfo) {
this.contactInfo = contactInfo;
return this;
}

/// How to reach the signer, or null.
public String getContactInfo() {
return contactInfo;
}

/// The claimed signing time, in milliseconds since the epoch; the
/// current time by default. It is the signer's claim, not a timestamp
/// authority's.
public PdfSignature setSigningTime(long millis) {
this.signingTime = millis;
return this;
}

/// The claimed signing time.
public long getSigningTime() {
return signingTime;
}

/// Shows the signature as a box at `(x, y, width, height)` on `page`,
/// in the page's top-left based coordinates, with the signer's name,
/// the date and the reason. Without this the signature is invisible
/// and attached to the first page.
public PdfSignature setVisible(PdfPage page, float x, float y, float width, float height) {
this.page = page;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
return this;
}

/// True when [#setVisible] placed the signature on a page.
public boolean isVisible() {
return page != null && width > 0 && height > 0;
}

PdfPage getPage() {
return page;
}

float[] getRect() {
return new float[] {x, y, width, height};
}

/// The space reserved in the file for the CMS signature, in bytes;
/// 12 KB by default, enough for a signer certificate and two
/// intermediates. Saving fails if the signature does not fit.
public PdfSignature setReservedBytes(int bytes) {
if (bytes < 1024) {
throw new IllegalArgumentException("At least 1024 bytes must be reserved");
}
this.reservedBytes = bytes;
return this;
}

/// The space reserved for the CMS signature, in bytes.
public int getReservedBytes() {
return reservedBytes;
}
}
Loading
Loading