public static boolean validateTokenRequest(TokenRequestDto tokenRequestDto, OAuthApplicationDto oAuthApplicationDto) {
        // basic check
        try {
            String decodedRedirectUri = java.net.URLDecoder.decode(tokenRequestDto.getRedirectUri(), "UTF-8");
            if (StringUtils.isNotBlank(oAuthApplicationDto.getRedirectUri()) && oAuthApplicationDto.getRedirectUri().equals(decodedRedirectUri)) {
                if (StringUtils.isNotBlank(tokenRequestDto.getGrantType())) {
                    if (OAuthFields.AUTHORIZATION_CODE.equals(tokenRequestDto.getGrantType())) {
                        return true;
                    } else {
                        _logger.info("Grant Type '" + tokenRequestDto.getGrantType() + "' is not supported");
                        throw new OAuthException(ResponseCodes.GRANT_TYPE_NOT_SUPPORTED, HttpResponseStatus.BAD_REQUEST);
                    }
                } else {
                    _logger.info("Grant Type '" + tokenRequestDto.getGrantType() + "' mismatch");
                    throw new OAuthException(ResponseCodes.INVALID_OR_MISSING_GRANT_TYPE, HttpResponseStatus.BAD_REQUEST);
                }
            } else {
                _logger.info("Request Redirect URI '" + tokenRequestDto.getRedirectUri() + "' mismatch");
                throw new OAuthException(ResponseCodes.INVALID_OR_MISSING_REDIRECT_URI, HttpResponseStatus.BAD_REQUEST);
            }
        } catch (UnsupportedEncodingException e) {
            _logger.info("Request Redirect URI '" + tokenRequestDto.getRedirectUri() + "' mismatch");
            throw new OAuthException(ResponseCodes.INVALID_OR_MISSING_REDIRECT_URI, HttpResponseStatus.BAD_REQUEST);
        }

    }
public static boolean validateTokenRequest ( TokenRequestDto tokenRequestDto , OAuthApplicationDto oAuthApplicationDto ) { try { String decodedRedirectUri = java . net . URLDecoder . decode ( tokenRequestDto . getRedirectUri ( ) , "UTF-8" ) ; if ( StringUtils . isNotBlank ( oAuthApplicationDto . getRedirectUri ( ) ) && oAuthApplicationDto . getRedirectUri ( ) . equals ( decodedRedirectUri ) ) { if ( StringUtils . isNotBlank ( tokenRequestDto . getGrantType ( ) ) ) { if ( OAuthFields . AUTHORIZATION_CODE . equals ( tokenRequestDto . getGrantType ( ) ) ) { return true ; } else { _logger . info ( "Grant Type '" + tokenRequestDto . getGrantType ( ) + "' is not supported" ) ; throw new OAuthException ( ResponseCodes . GRANT_TYPE_NOT_SUPPORTED , HttpResponseStatus . BAD_REQUEST ) ; } } else { _logger . info ( "Grant Type '" + tokenRequestDto . getGrantType ( ) + "' mismatch" ) ; throw new OAuthException ( ResponseCodes . INVALID_OR_MISSING_GRANT_TYPE , HttpResponseStatus . BAD_REQUEST ) ; } } else { _logger . info ( "Request Redirect URI '" + tokenRequestDto . getRedirectUri ( ) + "' mismatch" ) ; throw new OAuthException ( ResponseCodes . INVALID_OR_MISSING_REDIRECT_URI , HttpResponseStatus . BAD_REQUEST ) ; } } catch ( UnsupportedEncodingException e ) { _logger . info ( "Request Redirect URI '" + tokenRequestDto . getRedirectUri ( ) + "' mismatch" ) ; throw new OAuthException ( ResponseCodes . INVALID_OR_MISSING_REDIRECT_URI , HttpResponseStatus . BAD_REQUEST ) ; } }
Validates Token Request
@param tokenRequestDto       Given Application DTO properties
@param oAuthApplicationDto   Expected Application DTO properties
@return  Returns boolean or OAuth Exception