ValidationUtil { public static void validateResponseType(final Client client, final String responseType) { if (client != null) { if (ClientType.Implicit.equals(client.getType()) && "token".equals(responseType)) { return; } else if (ClientType.AuthorizationGrant.equals(client.getType()) && "code".equals(responseType)) { return; } } throw new UnsupportedResponseTypeException(); } 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 testResponseTypeValidImplicitResponseType() { Client c = new Client(); c.setType(ClientType.Implicit); ValidationUtil.validateResponseType(c, "token"); }
@Test public void testResponseTypeValidGrantResponseType() { Client c = new Client(); c.setType(ClientType.AuthorizationGrant); ValidationUtil.validateResponseType(c, "code"); }
@Test(expected = UnsupportedResponseTypeException.class) public void testResponseTypeMismatchedImplicitType() { Client c = new Client(); c.setType(ClientType.Implicit); ValidationUtil.validateResponseType(c, "code"); }
@Test(expected = UnsupportedResponseTypeException.class) public void testResponseTypeMismatchedGrantType() { Client c = new Client(); c.setType(ClientType.AuthorizationGrant); ValidationUtil.validateResponseType(c, "token"); }
@Test(expected = UnsupportedResponseTypeException.class) public void testResponseTypeBogusType() { Client c = new Client(); c.setType(ClientType.OwnerCredentials); ValidationUtil.validateResponseType(c, "code"); }
@Test(expected = UnsupportedResponseTypeException.class) public void testResponseTypeNullResponseType() { Client c = new Client(); c.setType(ClientType.OwnerCredentials); ValidationUtil.validateResponseType(c, null); }
@Test(expected = UnsupportedResponseTypeException.class) public void testResponseTypeNullClient() { Client c = new Client(); c.setType(ClientType.OwnerCredentials); ValidationUtil.validateResponseType(null, "code"); }