faceless2 / c2pa Goto Github PK
View Code? Open in Web Editor NEWA Java C2PA implementation
License: Apache License 2.0
A Java C2PA implementation
License: Apache License 2.0
Example to reproduce:
C2PAStore c2pa = new C2PAStore();
C2PAManifest manifest = new C2PAManifest("urn:manifestid");
c2pa.getManifests().add(manifest);
C2PAClaim claim = manifest.getClaim();
claim.setFormat("image/jpeg");
claim.setInstanceID("urn:instanceid");
manifest.getAssertions().add(new C2PA_AssertionHashData());
manifest.getAssertions().add(new C2PA_AssertionThumbnail("image/png", null, new ByteArrayInputStream(new byte[0]), true));
KeyStore keystore = KeyStore.getInstance("PKCS12");
keystore.load(new FileInputStream(KEY_STORE), KEY_STORE_PASSWORD);
PrivateKey key = (PrivateKey) keystore.getKey(KEY_ALIAS, KEY_PASSWORD);
List<X509Certificate> certs = new ArrayList<>();
for (Certificate c : keystore.getCertificateChain(KEY_ALIAS)) {
certs.add((X509Certificate) c);
}
manifest.getSignature().setSigner(key, certs);
Json j = C2PAHelper.readJPEG(new FileInputStream("unsigned.jpg"));
C2PAHelper.writeJPEG(j, c2pa, new FileOutputStream("signed.jpg"));
// Read back the signed file
j = C2PAHelper.readJPEG(new FileInputStream("signed.jpg"));
c2pa = (C2PAStore)new BoxFactory().load(j.bufferValue("c2pa"));
manifest = c2pa.getActiveManifest();
for (C2PA_Assertion assertion : manifest.getAssertions()) {
System.out.println(assertion);
}
Expected output:
{"type":"jumb","class":"C2PA_AssertionHashData","size":193}
{"type":"jumb","class":"C2PA_AssertionThumbnail","size":100}
Actual output:
{"type":"jumb","class":"C2PA_AssertionHashData","size":193}
{"type":"jumb","class":"C2PA_AssertionUnknown"}
I think the issue comes from the label set in the constructor of C2PA_AssertionThumbnail:
SUBTYPE
with (claim ? "c2pa.thumbnail.claim." : "c2pa.thumbnail.ingredient.") + mediaSubtype(mediaType)
, the code seems to work as expected.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.