I want to store permissions in a bit set to compare them efficiently in Java. A 1 would mean permission granted and 0 permission denied. If the authorization is performed the required permissions would be compared to the permission set.
My idea is to use AND and compare the result with the requested permissions.
Example:
0010 1101 Granted Permissions
AND 0000 0101 Requested Permissions
= 0000 0101 Result
if (Result == Requested Permissions)
allow
else
deny
Could that be done more efficient or simple?