A Flexible Security Architecture to Support Third-party Applications on Mobile Devices.