|
YAACC - UPNP Client and Server
|
Single-use tokens that prove an intent for the browser came from LauncherActivity after its checks.
More...

Public Member Functions | |
| LaunchNonces (LongSupplier nowMillis, Consumer< byte[]> randomBytes, long ttlMillis, int maxOutstanding) | |
| synchronized String | mint () |
| Makes a new token. | |
| synchronized boolean | consume (String presented) |
| Spends a token. | |
Static Public Member Functions | |
| static LaunchNonces | createDefault () |
The production store: monotonic clock, SecureRandom, the limits of ShareLimits. | |
Static Public Attributes | |
| static final String | EXTRA_NAME = "de.yaacc.extra.LAUNCH_NONCE" |
| The intent extra that carries the token from the launcher to the browser. | |
Single-use tokens that prove an intent for the browser came from LauncherActivity after its checks.
Plain Java, memory only.
The browser activities are exported, so any app can start them with a file share and skip the launcher (and with it the checks of the incoming file share). The launcher therefore mint()s a token when its checks have passed and puts it into the fresh intent it forwards; the browser accepts a shared file only if the intent presents a token that consume(String) accepts. The store lives in this process only (another app can neither read nor guess it: 128 bits from a SecureRandom), a token is valid for a short time and once, the store is bounded, and the comparison is constant-time. A token that is replayed (a recents re-delivery, a process restart) is simply not found.
| de.yaacc.share.LaunchNonces.LaunchNonces | ( | LongSupplier | nowMillis, |
| Consumer< byte[]> | randomBytes, | ||
| long | ttlMillis, | ||
| int | maxOutstanding ) |
| nowMillis | a monotonic clock |
| randomBytes | fills the array with unpredictable bytes |
| ttlMillis | how long a token is valid, positive |
| maxOutstanding | how many unused tokens are kept, at least 1 |
Referenced by de.yaacc.share.LaunchNonces.createDefault().

| synchronized boolean de.yaacc.share.LaunchNonces.consume | ( | String | presented | ) |
Spends a token.
| presented | what the intent carried, may be null |
| synchronized String de.yaacc.share.LaunchNonces.mint | ( | ) |
Makes a new token.
Expired tokens go first; if the store is still full, the oldest live one is dropped.