I have an user who is not able to view the SSN field whereas he had access to view the SSN field before. It appears that the "View Encrypted Data" permission has been revoked for him. The profile of the user never had this permission and hence this permission was given to him via a permission set. Is it possible to query the profiles/permissionsets/userlicense or other objects to find which permissionset gave the user the "View Encrypted Data" permision?
The permission is named as
You can find out the PermissionSet name by running this query
SELECT ID,NAME, PermissionsViewEncryptedData FROM PermissionSet WHERE PermissionsViewEncryptedData=TRUE
Also Same Applies for Profile
SELECT ID,NAME, PermissionsViewEncryptedData FROM PROFILE WHERE PermissionsViewEncryptedData=TRUE
UPDATE: Based on your Comments
You can do that by Querying
PermissionSetAssignment, PermissionSetAssignment is the Junction between User and the PermissionSet.
SELECT ID, PermissionSet.Name, PermissionSet.PermissionsViewEncryptedData FROM PermissionSetAssignment WHERE AssigneeId='005UserId' AND PermissionSet.PermissionsViewEncryptedData =TRUE