AuthenticationResult executeOAuthRequestAndProcessResponse()
            throws ParseException, AuthenticationException, SerializeException,
            IOException, java.text.ParseException {

        AuthenticationResult result = null;
        HTTPResponse httpResponse = null;
        final AdalOAuthRequest adalOAuthHttpRequest = this.toOAuthRequest();
        httpResponse = adalOAuthHttpRequest.send();

        if (httpResponse.getStatusCode() == HTTPResponse.SC_OK) {
            final AdalAccessTokenResponse response = AdalAccessTokenResponse
                    .parseHttpResponse(httpResponse);

            OIDCTokens tokens = response.getOIDCTokens();
            String refreshToken = null;
            if (tokens.getRefreshToken() != null) {
                refreshToken = tokens.getRefreshToken().getValue();
            }

            UserInfo info = null;
            if (tokens.getIDToken() != null) {
                info = UserInfo.createFromIdTokenClaims(tokens.getIDToken()
                        .getJWTClaimsSet());
            }

            result = new AuthenticationResult(tokens.getAccessToken()
                    .getType().getValue(),
                    tokens.getAccessToken().getValue(), refreshToken,
                    tokens.getAccessToken().getLifetime(),
                    tokens.getIDTokenString(), info,
                    !StringHelper.isBlank(response.getResource()));
        } else {
            final TokenErrorResponse errorResponse = TokenErrorResponse
                    .parse(httpResponse);
            ErrorObject errorObject = errorResponse.getErrorObject();
            if(AdalErrorCode.AUTHORIZATION_PENDING.toString()
                    .equals(errorObject.getCode())){
                throw new AuthenticationException(AdalErrorCode.AUTHORIZATION_PENDING,
                        errorObject.getDescription());
            }

            if(HTTPResponse.SC_BAD_REQUEST == errorObject.getHTTPStatusCode() &&
                    AdalErrorCode.INTERACTION_REQUIRED.toString()
                            .equals(errorObject.getCode())){
                throw new AdalClaimsChallengeException(errorResponse.toJSONObject()
                        .toJSONString(), getClaims(httpResponse.getContent()));
            }
            else {
                throw new AuthenticationException(errorResponse.toJSONObject()
                        .toJSONString());
            }
        }

        return result;
    }
AuthenticationResult executeOAuthRequestAndProcessResponse ( ) throws ParseException , AuthenticationException , SerializeException , IOException , java . text . ParseException { AuthenticationResult result = null ; HTTPResponse httpResponse = null ; final AdalOAuthRequest adalOAuthHttpRequest = this . toOAuthRequest ( ) ; httpResponse = adalOAuthHttpRequest . send ( ) ; if ( httpResponse . getStatusCode ( ) == HTTPResponse . SC_OK ) { final AdalAccessTokenResponse response = AdalAccessTokenResponse . parseHttpResponse ( httpResponse ) ; OIDCTokens tokens = response . getOIDCTokens ( ) ; String refreshToken = null ; if ( tokens . getRefreshToken ( ) != null ) { refreshToken = tokens . getRefreshToken ( ) . getValue ( ) ; } UserInfo info = null ; if ( tokens . getIDToken ( ) != null ) { info = UserInfo . createFromIdTokenClaims ( tokens . getIDToken ( ) . getJWTClaimsSet ( ) ) ; } result = new AuthenticationResult ( tokens . getAccessToken ( ) . getType ( ) . getValue ( ) , tokens . getAccessToken ( ) . getValue ( ) , refreshToken , tokens . getAccessToken ( ) . getLifetime ( ) , tokens . getIDTokenString ( ) , info , ! StringHelper . isBlank ( response . getResource ( ) ) ) ; } else { final TokenErrorResponse errorResponse = TokenErrorResponse . parse ( httpResponse ) ; ErrorObject errorObject = errorResponse . getErrorObject ( ) ; if ( AdalErrorCode . AUTHORIZATION_PENDING . toString ( ) . equals ( errorObject . getCode ( ) ) ) { throw new AuthenticationException ( AdalErrorCode . AUTHORIZATION_PENDING , errorObject . getDescription ( ) ) ; } if ( HTTPResponse . SC_BAD_REQUEST == errorObject . getHTTPStatusCode ( ) && AdalErrorCode . INTERACTION_REQUIRED . toString ( ) . equals ( errorObject . getCode ( ) ) ) { throw new AdalClaimsChallengeException ( errorResponse . toJSONObject ( ) . toJSONString ( ) , getClaims ( httpResponse . getContent ( ) ) ) ; } else { throw new AuthenticationException ( errorResponse . toJSONObject ( ) . toJSONString ( ) ) ; } } return result ; }
@return
@throws ParseException
@throws AuthenticationException
@throws SerializeException
@throws IOException
@throws java.text.ParseException