aic-lib-javaEN
AIC SDK for Java
Maintainers wanted. This is an open, community-oriented SDK. We welcome active maintainers for review, porting, packaging, and platform testing. See CONTRIBUTING.md (org-wide) and the "Contributing" section below.
Java implementation of the AI Agent Identity Certificate (AIC) RFC drafts,
faithfully ported from the Go reference implementation
(varwof/types and varwof/types/aicjwt):
draft-wei-aic-identity-cert— X.509 certificate extension carrying the AIC agent identity & delegation authorization, encoded as ASN.1/DER.draft-wei-aic-jwt— AIC-JWT: the JSON Web Token profile for the same identity model.
The test suite verifies byte-exact DER output against Go-generated vectors and includes cross-language conformance tokens produced and signed by the Go implementation. Builds on Bouncy Castle.
Why AIC?
An ordinary X.509 certificate proves who an entity is; it says nothing about what it is allowed to do. AI agents act on behalf of humans, often across organizational boundaries, so a relying party needs to know not just the agent's identity but also: which human (principal) delegated to this agent, what capabilities were granted and under what constraints, and that the grant is fresh and cannot be replayed. AIC (Authorization in Certificates) encodes that evidence into the certificate itself (X.509v3 extension) or into a JWT profile, so a gateway can decide permission locally and offline.
Language matrix
AIC is implemented in five languages, all byte-compatible with the Go reference:
| Language | Repository | Status |
|---|---|---|
| Go (reference) | varwof/types | complete |
| TypeScript | varwof/aic-jwt | complete (18 tests) |
| C / OpenSSL | varwof/openaic | complete (13 tests) |
| Java | this repo (aic-lib-java) | complete (69 tests) |
| C# | varwof/aic-lib-dotnet | complete (69 tests) |
Status
- 69/69 tests green (DER vectors, JWS round-trips, JWT validator, capability matching, cert build/parse, Go conformance).
- Requires JDK 17+.
- See docs/ for protocol coverage and docs/conformance.md for cross-language guarantees.
Layout
src/main/java/com/varwof/aic/ core: ASN.1/DER models + validation
src/main/java/com/varwof/aic/cert/ X.509 certificate build/parse
src/main/java/com/varwof/aic/jwt/ JWT profile: JWS, claims, matcher, validator
src/test/java/com/varwof/aic/ DER vector + validator tests
src/test/java/com/varwof/aic/jwt/ JWS, matching, validation, Go conformance
Requirements
- JDK 17+
- Internet access on first build (dependencies are fetched into
lib/)
Build & test
scripts/fetch-deps.sh # one-time: download BouncyCastle/Jackson/JUnit into lib/
scripts/build.sh # compile main + test classes and run all JUnit tests
With Maven available the project also builds normally from pom.xml
(mvn test).
Quick usage
Core model & validation
import com.varwof.aic.*;
Aic aic = Aic.builder()
.agentId("agent-7")
.principalUid(new PrincipalUid("acme", "alice", keyHash, null))
.capability(new Capability("tt", "smart-device"))
.capability(new Capability("tt", "smart-device", "{\"level\":2}".getBytes()))
.constraint(new Capability("constraint", "max-concurrent",
"{\"max\":3}".getBytes()))
.delegationMode(DelegationMode.AUTHORIZED)
.build();
AicValidator.validate(aic); // spec validation (throws AicException)
byte[] der = aic.encode(); // DER bytes of the extension value
Aic parsed = Aic.parse(der); // round-trip
Sign / verify a DelegationAuthorization
DelegationAuthTbs tbs = new DelegationAuthTbs(
1, "agent-7", pu, reason, caps, mode, constraints,
3600, Instant.now(), nonce32);
DelegationAuthorization da =
DelegationAuthCrypto.sign(tbs, principalPrivateKey); // self-describing OID
boolean ok = DelegationAuthCrypto.verify(tbs, da, principalPublicKey);
X.509 certificates
import com.varwof.aic.cert.*;
X509CertificateHolder principalCert = AicCertificateBuilder.buildPrincipalCert(
issuerKey, subjectKey, principalAuth, ...);
X509CertificateHolder agentCert = AicCertificateBuilder.buildAgentCert(
issuerKey, subjectKey, aic, ...);
Aic parsed = AicCertificates.parseAndValidateAic(agentCert);
AIC-JWT validation
import com.varwof.aic.jwt.*;
Validator.Decision d = Validator.validate(token, new Validator.VerifyOptions()
.withIssuerKeys(kid -> key)
.withExpectedAudience("gateway"));
// d.permit(), d.actor(), d.principal(), d.permissions()
See docs/jwt-profile.md for the full 11-step pipeline.
Conformance notes
- DER byte output is compared against vectors generated by the Go
implementation (
DerVectorsTest). JwsTestround-trips every implemented algorithm (ES256, RS256, PS256, PS384, PS512, EdDSA).GoConformanceTestvalidates a token produced and signed by the Go implementation through the full 11-step pipeline, proving that signature encoding, SPKI key-binding hashes and RFC 7638 JWK thumbprints match.- RSA-PSS uses salt length equal to the digest (default for the profile). ES384/ES512 and RS384/RS512 are in the JOSE allowlist but intentionally not implemented (MAY-level algorithms).
Documentation
- docs/index.md — overview & protocol coverage
- docs/cert-profile.md — X.509/ASN.1 profile
- docs/jwt-profile.md — AIC-JWT profile
- docs/conformance.md — cross-language consistency
Contributing
This SDK is community-maintained. You do not need to be a core team member to contribute:
- Report bugs / request features — open an issue; bug reports do not require a contributor agreement.
- Send a patch — code contributions go through pull requests and require a
DCO sign-off (a
Signed-off-byline in the commit message). The org-wide process is in CONTRIBUTING.md. - Become a maintainer — after a few merged PRs, ask for collaborator access; regular reviewers are invited to take ownership of this SDK.
License
Apache-2.0. See LICENSE.