class ServiceMeshInspectorImpl implements ServiceMeshInspector {

    @Override
    public boolean isRequestAllowed(RSocketAppPrincipal requesterPrincipal, String routing, RSocketAppPrincipal responderPrincipal) {
        if (!authRequired) return true;
        //org & service account relation
        int relationHashCode = (requesterPrincipal.hashCode() + ":" + responderPrincipal.hashCode()).hashCode();
        if (whiteRelationBitmap.contains(relationHashCode)) {
            return true;
        }
        //acl mapping
        int aclHashCode = (requesterPrincipal.hashCode() + ":" + routing + ":" + responderPrincipal.hashCode()).hashCode();
        if (whiteRelationBitmap.contains(aclHashCode)) {
            return true;
        }
        boolean orgFriendly = false;
        for (String principalOrg : requesterPrincipal.getOrganizations()) {
            if (responderPrincipal.getOrganizations().contains(principalOrg)) {
                orgFriendly = true;
                break;
            }
        }
        if (orgFriendly) {
            boolean serviceAccountFriendly = false;
            for (String serviceAccount : requesterPrincipal.getServiceAccounts()) {
                if (responderPrincipal.getServiceAccounts().contains(serviceAccount)) {
                    serviceAccountFriendly = true;
                    break;
                }
            }
            if (serviceAccountFriendly) {
                whiteRelationBitmap.add(relationHashCode);
                return true;
            }
        }
        return false;
    }

    public  ServiceMeshInspectorImpl();
    public  ServiceMeshInspectorImpl(boolean authRequired);

}