@Test(expected = InvalidScopeException.class) public void testValidateScopeMapMismatchScopesInRole() throws Exception { SortedMap<String, ApplicationScope> roleScopes = new TreeMap<>(); ApplicationScope debug1Scope = new ApplicationScope(); debug1Scope.setName("debug1"); roleScopes.put(debug1Scope.getName(), debug1Scope); ApplicationScope debug2Scope = new ApplicationScope(); debug2Scope.setName("debug2"); roleScopes.put(debug2Scope.getName(), debug2Scope); ApplicationScope debug3Scope = new ApplicationScope(); debug3Scope.setName("debug3"); SortedMap<String, ApplicationScope> requestedScopes = new TreeMap<>(); requestedScopes.put(debug2Scope.getName(), debug2Scope); requestedScopes.put(debug3Scope.getName(), debug3Scope); Role r = new Role(); r.setScopes(roleScopes); ValidationUtil.validateScope(requestedScopes, r); }
public static SortedMap<String, ApplicationScope> validateScope( final String[] requestedScopes, final SortedMap<String, ApplicationScope> validScopes) { if (requestedScopes == null || requestedScopes.length == 0) { return new TreeMap<>(); } if (validScopes == null) { throw new InvalidScopeException(); } SortedMap<String, ApplicationScope> results = new TreeMap<>(); for (String scope : requestedScopes) { if (validScopes.containsKey(scope)) { results.put(scope, validScopes.get(scope)); } } return results; }
ValidationUtil { public static SortedMap<String, ApplicationScope> validateScope( final String[] requestedScopes, final SortedMap<String, ApplicationScope> validScopes) { if (requestedScopes == null || requestedScopes.length == 0) { return new TreeMap<>(); } if (validScopes == null) { throw new InvalidScopeException(); } SortedMap<String, ApplicationScope> results = new TreeMap<>(); for (String scope : requestedScopes) { if (validScopes.containsKey(scope)) { results.put(scope, validScopes.get(scope)); } } return results; } }
ValidationUtil { public static SortedMap<String, ApplicationScope> validateScope( final String[] requestedScopes, final SortedMap<String, ApplicationScope> validScopes) { if (requestedScopes == null || requestedScopes.length == 0) { return new TreeMap<>(); } if (validScopes == null) { throw new InvalidScopeException(); } SortedMap<String, ApplicationScope> results = new TreeMap<>(); for (String scope : requestedScopes) { if (validScopes.containsKey(scope)) { results.put(scope, validScopes.get(scope)); } } return results; } private  ValidationUtil(); }
ValidationUtil { public static SortedMap<String, ApplicationScope> validateScope( final String[] requestedScopes, final SortedMap<String, ApplicationScope> validScopes) { if (requestedScopes == null || requestedScopes.length == 0) { return new TreeMap<>(); } if (validScopes == null) { throw new InvalidScopeException(); } SortedMap<String, ApplicationScope> results = new TreeMap<>(); for (String scope : requestedScopes) { if (validScopes.containsKey(scope)) { results.put(scope, validScopes.get(scope)); } } return results; } private  ValidationUtil(); static void validateResponseType(final Client client,
                                            final String responseType); static URI requireValidRedirect(
            final URI redirect, final List<ClientRedirect> redirects); static URI requireValidRedirect(
            final String redirect, final List<ClientRedirect> redirects); static URI requireValidRedirect(final String redirect,
                                           final Set<URI> redirects); static URI validateRedirect(final URI redirect,
                                       final List<ClientRedirect> redirects); static URI validateRedirect(final String redirect,
                                       final List<ClientRedirect> redirects); static URI validateRedirect(final URI redirect,
                                       final Set<URI> redirects); static URI validateRedirect(final String redirect,
                                       final Set<URI> redirects); static SortedMap<String, ApplicationScope> validateScope(
            final String[] requestedScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> validateScope(
            final String requestedScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> validateScope(
            final SortedMap<String, ApplicationScope> requestedScopes,
            final Role role); static SortedMap<String, ApplicationScope> validateScope(
            final String requestedScopes, final Role role); static SortedMap<String, ApplicationScope> revalidateScope(
            final String[] requestedScopes,
            final SortedMap<String, ApplicationScope> originalScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> revalidateScope(
            final String requestedScopes,
            final SortedMap<String, ApplicationScope> originalScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> revalidateScope(
            final String requestedScopes,
            final SortedMap<String, ApplicationScope> originalScopes,
            final Role role); static Authenticator validateAuthenticator(
            final AuthenticatorType type,
            final List<Authenticator> authenticators); }
ValidationUtil { public static SortedMap<String, ApplicationScope> validateScope( final String[] requestedScopes, final SortedMap<String, ApplicationScope> validScopes) { if (requestedScopes == null || requestedScopes.length == 0) { return new TreeMap<>(); } if (validScopes == null) { throw new InvalidScopeException(); } SortedMap<String, ApplicationScope> results = new TreeMap<>(); for (String scope : requestedScopes) { if (validScopes.containsKey(scope)) { results.put(scope, validScopes.get(scope)); } } return results; } private  ValidationUtil(); static void validateResponseType(final Client client,
                                            final String responseType); static URI requireValidRedirect(
            final URI redirect, final List<ClientRedirect> redirects); static URI requireValidRedirect(
            final String redirect, final List<ClientRedirect> redirects); static URI requireValidRedirect(final String redirect,
                                           final Set<URI> redirects); static URI validateRedirect(final URI redirect,
                                       final List<ClientRedirect> redirects); static URI validateRedirect(final String redirect,
                                       final List<ClientRedirect> redirects); static URI validateRedirect(final URI redirect,
                                       final Set<URI> redirects); static URI validateRedirect(final String redirect,
                                       final Set<URI> redirects); static SortedMap<String, ApplicationScope> validateScope(
            final String[] requestedScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> validateScope(
            final String requestedScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> validateScope(
            final SortedMap<String, ApplicationScope> requestedScopes,
            final Role role); static SortedMap<String, ApplicationScope> validateScope(
            final String requestedScopes, final Role role); static SortedMap<String, ApplicationScope> revalidateScope(
            final String[] requestedScopes,
            final SortedMap<String, ApplicationScope> originalScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> revalidateScope(
            final String requestedScopes,
            final SortedMap<String, ApplicationScope> originalScopes,
            final SortedMap<String, ApplicationScope> validScopes); static SortedMap<String, ApplicationScope> revalidateScope(
            final String requestedScopes,
            final SortedMap<String, ApplicationScope> originalScopes,
            final Role role); static Authenticator validateAuthenticator(
            final AuthenticatorType type,
            final List<Authenticator> authenticators);  }