class AuthorizationServiceImpl implements AuthorizationService, PostConstruct {

	@Override
	public boolean isPermissionGranted(
        final Subject subject, final Permission permission) {

        // Validate inputs
        if ( null == subject ) {
            throw new IllegalArgumentException(localStrings.getLocalString("service.subject_null", "The supplied Subject is null."));
        }
        if ( null == permission ) {
            throw new IllegalArgumentException(localStrings.getLocalString("service.permission_null","The supplied Permission is null."));
        }

        Set<Principal> principalset = subject.getPrincipals();
        Principal[] principalAr = (principalset.size() == 0) ? null : principalset.toArray(new Principal[principalset.size()]);
        ProtectionDomain pd = new ProtectionDomain(NULL_CODESOURCE, null, null, principalAr); 
        Policy policy = Policy.getPolicy();
        boolean result = policy.implies(pd, permission);

        return result;
	}

}