Class ShieldEngineRegistry
Where the attestation engine registers itself.
Registration is by direct instance, not by class name. Codename One obfuscates and renames
classes -- ProGuard/R8 on Android, the bytecode-to-C translation on iOS -- so a
Class.forName lookup is unreliable by construction. The port or the build-server-generated
bootstrap instantiates the engine itself and passes the instance here, which survives renaming
because it is an ordinary symbol reference. The same convention is used elsewhere in the
framework for port-supplied implementations.
Registration happens in one of three places:
- Device builds: the build server splices a bootstrap into the generated application stub,
ahead of
Display.init, when the project is entitled to the enterprise engine. - Simulator: the desktop port's post-init bootstrap scan picks it up, which is the one place a name-based lookup is safe because the desktop port is not obfuscated.
- Tests: call
setEngine(ShieldEngine)directly.
The first registration wins and the registry then seals. Without that, any code running later in the process -- including code an attacker injected -- could swap in an engine that returns whatever it likes. Sealing does not make the app tamper-proof (an attacker who can patch the binary can patch this too); it removes the version of the attack that needs no patching at all.
-
Method Summary
Modifier and TypeMethodDescriptionstatic EngineContextThe framework-backedEngineContextan engine is initialized with.static ShieldEngineThe registered engine, or the inert default when none was registered.static booleanTrue when a real engine was registered, whatever it currently reports about its availability.static voidRegisters the engine.
-
Method Details
-
setEngine
Registers the engine. The first call wins.- Throws:
IllegalStateException- if an engine is already registered
-
getEngine
The registered engine, or the inert default when none was registered. Never null, so no caller needs a null check and no code path can silently skip a check that should have run. -
getDefaultContext
The framework-backedEngineContextan engine is initialized with. Exposed so a port or a test can construct an engine against the real services without reimplementing them. -
isEngineRegistered
public static boolean isEngineRegistered()True when a real engine was registered, whatever it currently reports about its availability.
Distinct from
AppShield.isProtected(), which asks whether attestation can run right now. A fail-closed host must refuse when a registered engine cannot attest -- that is the case it exists for -- and relax only for a build that has no engine at all.
-