|
YAACC - UPNP Client and Server
|
Decides which shared local content may be registered for serving. More...

Static Public Member Functions | |
| static boolean | isAcceptableUri (String uriString, String ownAuthority) |
Accepts a URI only if all of these hold: not null, at most MAX_URI_LENGTH chars, only printable ASCII (no whitespace, no control characters, no non-ASCII), scheme content (ASCII case-insensitive) followed by //, a non-empty authority (up to the next /, ? or #) without @ (Android user id prefix) and without % (Android decodes authorities), and an authority that is not ownAuthority (ASCII case-insensitive). | |
| static String | authorityOf (String uriString) |
The authority of a URI text that is well-formed in the sense of isAcceptableUri (the own-authority rule aside), for the checks that need the Android package manager (does a provider of this app own it?). | |
| static boolean | isAcceptableMimeType (String mime) |
Accepts only concrete audio, video and image types: audio/<subtype>, video/<subtype>, image/<subtype> (type ASCII case-insensitive), the subtype a non-empty token of letters, digits and . + - _ ! # $ & ^ that starts with a letter or digit. | |
| static long | maxCopyBytes () |
The cap for the copy fallback in bytes, see MAX_COPY_BYTES. | |
| static boolean | isWithinCopyLimit (long sizeBytes) |
| static String | chooseMimeType (String providerType, String intentType) |
| Picks the MIME type of a shared file. | |
Decides which shared local content may be registered for serving.
Plain Java so it can be unit tested on the JVM; http/https text links stay with de.yaacc.browser.ShareUriPolicy.
The input comes from another app and is untrusted. Only content:// URIs of OTHER apps are accepted: a file: URI or a URI of yaacc's own file provider would let any app make yaacc read and serve its private data. Checks are on the text, ASCII only, nothing is trimmed or decoded, so what is checked is what Android would use.
|
static |
The authority of a URI text that is well-formed in the sense of isAcceptableUri (the own-authority rule aside), for the checks that need the Android package manager (does a provider of this app own it?).
Referenced by de.yaacc.share.ContentDuration.read(), and de.yaacc.share.StreamIntake.validate().


|
static |
Picks the MIME type of a shared file.
The provider's answer (ContentResolver.getType, untrusted but about the actual content) wins; the type declared on the intent is only a fallback:
providerType if isAcceptableMimeType(String) accepts it; intentType if it is accepted too (so a wildcard such as audio/*, */* or a non-media type never wins); The result is the lower-case canonical form (ASCII, Locale.ROOT) of the chosen input, so callers compare and store one spelling. Nothing is trimmed or stripped: a type with whitespace or parameters is not accepted (see isAcceptableMimeType(String)), and the provider type application/octet-stream falls through to the intent type. Never throws; null and empty inputs count as "not acceptable".

|
static |
Accepts only concrete audio, video and image types: audio/<subtype>, video/<subtype>, image/<subtype> (type ASCII case-insensitive), the subtype a non-empty token of letters, digits and . + - _ ! # $ & ^ that starts with a letter or digit.
Wildcards, parameters (; charset=...), whitespace, a missing subtype, null, empty and over-long texts are rejected.
Referenced by de.yaacc.share.SharedContentPolicy.chooseMimeType(), and de.yaacc.share.LinkContentType.concreteMediaType().

|
static |
Accepts a URI only if all of these hold: not null, at most MAX_URI_LENGTH chars, only printable ASCII (no whitespace, no control characters, no non-ASCII), scheme content (ASCII case-insensitive) followed by //, a non-empty authority (up to the next /, ? or #) without @ (Android user id prefix) and without % (Android decodes authorities), and an authority that is not ownAuthority (ASCII case-insensitive).
| uriString | the URI text from the sending app, may be null |
| ownAuthority | the authority of yaacc's own file provider; null or empty means the caller has a bug and nothing is accepted |
Referenced by de.yaacc.share.SharedContentPolicy.authorityOf(), de.yaacc.browser.LauncherForwardPolicy.decideStream(), de.yaacc.browser.LauncherForwardPolicy.rejectionReason(), and de.yaacc.share.StreamIntake.validate().

|
static |
| sizeBytes | the number of bytes read or announced, negative for unknown |
MAX_COPY_BYTES; unknown sizes are not accepted