class AtzProviderSync extends SynchronousProvider implements AuthorizationProvider {

    @Override
    protected AuthorizationResponse syncAuthorize(ProviderRequest providerRequest) {
        // just check the path contains the string "public", otherwise allow only if user is logged in
        // if no path is defined, abstain (e.g. I do not care about such requests - I can neither allow or deny them)
        return providerRequest.env().path()
                .map(path -> {
                    if (path.contains("public")) {
                        return AuthorizationResponse.permit();
                    }
                    if (providerRequest.securityContext().isAuthenticated()) {
                        return AuthorizationResponse.permit();
                    } else {
                        return AuthorizationResponse.deny();
                    }
                }).orElse(AuthorizationResponse.abstain());
    }

}