ValidationUtil { public static URI requireValidRedirect( final URI redirect, final List<ClientRedirect> redirects) { URI validRedirect = validateRedirect(redirect, redirects); if (validRedirect == null) { throw new InvalidRequestException(); } return validRedirect; } 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);  }
@Test public void testValidateClientRedirects() throws Exception { List<ClientRedirect> testRedirects = new ArrayList<>(); ClientRedirect redirect1 = new ClientRedirect(); redirect1.setUri(new URI("http: testRedirects.add(redirect1); ClientRedirect redirect2 = new ClientRedirect(); redirect2.setUri(new URI("http: testRedirects.add(redirect2); URI result = ValidationUtil.requireValidRedirect("http: testRedirects); assertEquals("http: }
@Test public void testValidateClientRedirectsWithUri() throws Exception { List<ClientRedirect> testRedirects = new ArrayList<>(); ClientRedirect redirect1 = new ClientRedirect(); redirect1.setUri(new URI("http: testRedirects.add(redirect1); ClientRedirect redirect2 = new ClientRedirect(); redirect2.setUri(new URI("http: testRedirects.add(redirect2); URI validUri = URI.create("http: URI result = ValidationUtil.requireValidRedirect(validUri, testRedirects); assertEquals(validUri, result); }
@Test(expected = InvalidRequestException.class) public void testValidateClientRedirectsWithNullUri() throws Exception { List<ClientRedirect> testRedirects = new ArrayList<>(); ClientRedirect redirect1 = new ClientRedirect(); redirect1.setUri(new URI("http: testRedirects.add(redirect1); ClientRedirect redirect2 = new ClientRedirect(); redirect2.setUri(new URI("http: testRedirects.add(redirect2); ValidationUtil.requireValidRedirect((URI) null, testRedirects); }
@Test(expected = InvalidRequestException.class) public void testValidateClientRedirectsWithNullString() throws Exception { List<ClientRedirect> testRedirects = new ArrayList<>(); ClientRedirect redirect1 = new ClientRedirect(); redirect1.setUri(new URI("http: testRedirects.add(redirect1); ClientRedirect redirect2 = new ClientRedirect(); redirect2.setUri(new URI("http: testRedirects.add(redirect2); URI result = ValidationUtil.requireValidRedirect((String) null, testRedirects); assertNull(result); }
@Test(expected = InvalidRequestException.class) public void testInvalidRedirectHost() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: testSet.add(new URI("http: ValidationUtil.requireValidRedirect("http: testSet); }
@Test(expected = InvalidRequestException.class) public void testInvalidRedirectPort() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: testSet.add(new URI("http: ValidationUtil.requireValidRedirect("http: testSet); }
@Test(expected = InvalidRequestException.class) public void testInvalidRedirectScheme() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("https: ValidationUtil.requireValidRedirect("http: testSet); }
@Test(expected = InvalidRequestException.class) public void testInvalidRedirectPath() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: ValidationUtil.requireValidRedirect("http: testSet); }
@Test public void testValidateRedirectDefault() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: URI result = ValidationUtil.requireValidRedirect("", testSet); assertEquals("http: }
@Test(expected = InvalidRequestException.class) public void testValidateRedirectDefaultTooMany() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: testSet.add(new URI("http: ValidationUtil.requireValidRedirect("", testSet); }
@Test(expected = InvalidRequestException.class) public void testValidateRedirectNoOptions() throws Exception { ValidationUtil.requireValidRedirect("http: new HashSet<>()); }
@Test(expected = InvalidRequestException.class) public void testValidateRedirectMalformed() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: ValidationUtil.requireValidRedirect("http:\\", testSet); }
@Test public void testValidateRedirectCustomQueryParams() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: testSet.add(new URI("http: URI test = new URI("http: URI result = ValidationUtil .requireValidRedirect(test.toString(), testSet); assertEquals(test, result); }
@Test public void testValidateRedirectAdditionalQueryParams() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: URI test = new URI("http: URI result = ValidationUtil .requireValidRedirect(test.toString(), testSet); assertEquals(test, result); }
@Test public void testValidateRedirectMultipleQueryParams() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: URI test = new URI("http: URI result = ValidationUtil .requireValidRedirect(test.toString(), testSet); assertEquals(test, result); }
@Test public void testValidateRedirectMultipleQueryParamsOverlap() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: URI test = new URI("http: URI result = ValidationUtil.requireValidRedirect(test.toString(), testSet); assertEquals(test, result); }
@Test(expected = InvalidRequestException.class) public void testValidateRedirectConflictingQueryParams() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: URI test = new URI("http: ValidationUtil.requireValidRedirect(test.toString(), testSet); }
@Test public void testValidateRedirectConflictingMultiParams() throws Exception { Set<URI> testSet = new HashSet<>(); testSet.add(new URI("http: testSet.add(new URI("http: URI test = new URI("http: URI result = ValidationUtil.requireValidRedirect(test.toString(), testSet); assertEquals(test, result); }