IntentSanitizer
class IntentSanitizer
This class is used to make a sanitized copy of an Intent. This could be used when UnsafeIntentLaunchViolation is detected. This class is thread safe and the object created is safe to be reused. Typical usage of the class:
Intent intent = new IntentSanitizer.Builder() .allowComponent(“com.example.ActivityA”) .allowData(“com.example”) .allowType(“text/plain”) .build() .sanitizeByThrowing(intent);
Summary
Nested types |
|---|
class IntentSanitizer.BuilderGeneral strategy of building is to only offer additive “or” operations that are chained together. |
Public functions |
|
|---|---|
Intent |
This method sanitizes the given intent. |
Intent |
Convenient method for filtering unwanted members from the input intent and log it. |
Intent |
sanitizeByThrowing(in: Intent)Convenient method for throwing a SecurityException when unwanted members of the input intent is encountered. |
Public functions
sanitize
fun sanitize(in: Intent, penalty: Consumer<String!>): Intent
This method sanitizes the given intent. If dirty members are found, the errors are consumed by the penalty object. The penalty action could be called multiple times if multiple issues exist.
| Parameters | |
|---|---|
in: Intent |
the given intent. |
penalty: Consumer<String!> |
consumer of the error message if dirty members are found. |
| Returns | |
|---|---|
Intent |
a sanitized copy of the given intent. |
sanitizeByFiltering
fun sanitizeByFiltering(in: Intent): Intent
Convenient method for filtering unwanted members from the input intent and log it.
| Parameters | |
|---|---|
in: Intent |
input intent |
| Returns | |
|---|---|
Intent |
a copy of the input intent after filtering out unwanted members. |
sanitizeByThrowing
fun sanitizeByThrowing(in: Intent): Intent
Convenient method for throwing a SecurityException when unwanted members of the input intent is encountered.
| Parameters | |
|---|---|
in: Intent |
input intent |
| Returns | |
|---|---|
Intent |
a copy of the input intent if the input intent does not contain any unwanted members. |
| Throws | |
|---|---|
java.lang.SecurityException |
if the input intent contains any unwanted members. |