public static ScopePredicate createScopePredicate(String scopeStr) {
        if (StringUtils.isEmpty(scopeStr)) {
            return ((permission, action) -> false);
        }
        String[] scopes = scopeStr.split("[ ,\n]");
        Map<String, Set<String>> actions = new HashMap<>();
        for (String scope : scopes) {
            String[] permissions = scope.split("[:]");
            String per = permissions[0];
            Set<String> acts = actions.computeIfAbsent(per, k -> new HashSet<>());
            acts.addAll(Arrays.asList(permissions).subList(1, permissions.length));
        }
        //全部授权
        if (actions.containsKey("*")) {
            return ((permission, action) -> true);
        }
        return ((permission, action) -> Optional
                .ofNullable(actions.get(permission))
                .map(acts -> action.length == 0 || acts.contains("*") || acts.containsAll(Arrays.asList(action)))
                .orElse(false));
    }
@Test
    public void testScope() {
        ScopePredicate predicate = OAuth2ScopeUtils.createScopePredicate("basic user:info device:query");

        assertTrue(predicate.test("basic"));
        {

            assertTrue(predicate.test("user", "info"));
            assertFalse(predicate.test("user", "info2"));
        }

        {
            assertTrue(predicate.test("device", "query"));
            assertFalse(predicate.test("device", "query2"));
        }

    }