protected ModelAndView buildCallbackViewViaRedirectUri ( final J2EContext context , final String clientId , final Authentication authentication , final OAuthCode code ) { val attributes = authentication . getAttributes ( ) ; val state = attributes . get ( OAuth20Constants . STATE ) . get ( 0 ) . toString ( ) ; val nonce = attributes . get ( OAuth20Constants . NONCE ) . get ( 0 ) . toString ( ) ; val redirectUri = context . getRequestParameter ( OAuth20Constants . REDIRECT_URI ) ; LOGGER . debug ( "Authorize request verification successful for client [{}] with redirect uri [{}]" , clientId , redirectUri ) ; var callbackUrl = redirectUri ; callbackUrl = CommonHelper . addParameter ( callbackUrl , OAuth20Constants . CODE , code . getId ( ) ) ; if ( StringUtils . isNotBlank ( state ) ) { callbackUrl = CommonHelper . addParameter ( callbackUrl , OAuth20Constants . STATE , state ) ; } if ( StringUtils . isNotBlank ( nonce ) ) { callbackUrl = CommonHelper . addParameter ( callbackUrl , OAuth20Constants . NONCE , nonce ) ; } LOGGER . debug ( "Redirecting to URL [{}]" , callbackUrl ) ; val params = new LinkedHashMap < String , String > ( ) ; params . put ( OAuth20Constants . CODE , code . getId ( ) ) ; params . put ( OAuth20Constants . STATE , state ) ; params . put ( OAuth20Constants . NONCE , nonce ) ; params . put ( OAuth20Constants . CLIENT_ID , clientId ) ; return buildResponseModelAndView ( context , servicesManager , clientId , callbackUrl , params ) ; }
Build callback view via redirect uri model and view .