Package com.box.restclientv2.authorization

Examples of com.box.restclientv2.authorization.DefaultAuthHeaderAuthTest


    private void handleException(final Exception e, final int sequenceId) throws BoxRestException {
        for (IBoxRestVisitor v : visitors) {
            v.visitException(e, sequenceId);
        }
        throw new BoxRestException(e);
    }
View Full Code Here


        auth.refresh();
        HttpEntity entity = boxRequest.getRequestEntity();
        if (entity == null || entity.isRepeatable()) {
            return execute(boxRequest, true);
        }
        throw new BoxRestException(ENTITY_CANNOT_BE_RETRIED);
    }
View Full Code Here

     */
    protected void doRefresh() throws AuthFatalFailureException {
        internalSetTokenState(OAuthTokenState.REFRESHING);

        if (mOAuthToken == null) {
            setRefreshFail(new BoxRestException("OAuthToken is null"));
            throw new AuthFatalFailureException(getRefreshFailException());
        }

        String refreshToken = mOAuthToken.getRefreshToken();
        try {
View Full Code Here

     * @return URI uri
     * @throws URISyntaxException
     *             exception
     */
    public URI buildUrl() throws URISyntaxException {
        HttpClientURIBuilder ub = new HttpClientURIBuilder(getUrlPath());
        ub.setHost(getHost());
        ub.setScheme(getScheme());
        ub.addParameter("response_type", getResponseType());
        ub.addParameter("client_id", getClientId());
        if (StringUtils.isNotEmpty(getOptionalState())) {
            ub.addParameter("state", getOptionalState());
        }
        HttpClientURLEncodedUtils.format(ub.getQueryParams(), "UTF-8");
        return ub.build();
    }
View Full Code Here

    }

    @Override
    public HttpRequestBase prepareRequest() throws BoxRestException, AuthFatalFailureException {
        rawRequest = constructHttpUriRequest();
        HttpClientURIBuilder ub;
        try {
            ub = new HttpClientURIBuilder();
            ub.setHost(getAuthority());
            ub.setScheme(getScheme());
            ub.setPath(getApiUrlPath().concat(uriPath).replaceAll("/{2,}", "/"));
            for (Map.Entry<String, String> entry : getQueryParams().entrySet()) {
                ub.addParameter(entry.getKey(), StringUtils.defaultIfEmpty(entry.getValue(), ""));
            }

            rawRequest.setURI(ub.build());
        }
        catch (URISyntaxException e) {
            throw new BoxRestException("URISyntaxException:" + e.getMessage());
        }
View Full Code Here

        }
    }

    private int getQueryIntValue(String str, String name) {
        int result = -1;
        HttpClientURIBuilder ub;
        try {
            ub = new HttpClientURIBuilder(str);
            List<NameValuePair> queries = ub.getQueryParams();
            for (NameValuePair pair : queries) {
                if (name.equals(pair.getName())) {
                    result = Integer.parseInt(pair.getValue());
                    break;
                }
View Full Code Here

     *
     * @param  url the URL to get the response from
     * @return     the response value
     */
    private String getResponseValueFromUrl(final String url) {
        HttpClientURIBuilder builder;
        try {
            builder = new HttpClientURIBuilder(url);
        } catch (URISyntaxException e) {
            return null;
        }

        List<NameValuePair> query = builder.getQueryParams();
        for (NameValuePair pair : query) {
            if (pair.getName().equalsIgnoreCase(mWebViewData.getResponseType())) {
                return pair.getValue();
            }
        }
View Full Code Here

        }
    }

    private int getQueryIntValue(String str, String name) {
        int result = -1;
        HttpClientURIBuilder ub;
        try {
            ub = new HttpClientURIBuilder(str);
            List<NameValuePair> queries = ub.getQueryParams();
            for (NameValuePair pair : queries) {
                if (name.equals(pair.getName())) {
                    result = Integer.parseInt(pair.getValue());
                    break;
                }
View Full Code Here

    }

    @Override
    public HttpRequestBase prepareRequest() throws BoxRestException, AuthFatalFailureException {
        rawRequest = constructHttpUriRequest();
        HttpClientURIBuilder ub;
        try {
            ub = new HttpClientURIBuilder();
            ub.setHost(getAuthority());
            ub.setScheme(getScheme());
            ub.setPath(getApiUrlPath().concat(uriPath).replaceAll("/{2,}", "/"));
            for (Map.Entry<String, String> entry : getQueryParams().entrySet()) {
                ub.addParameter(entry.getKey(), StringUtils.defaultIfEmpty(entry.getValue(), ""));
            }

            rawRequest.setURI(ub.build());
        } catch (URISyntaxException e) {
            throw new BoxRestException("URISyntaxException:" + e.getMessage());
        }

        if (getAuth() != null) {
View Full Code Here

     * @return URI uri
     * @throws URISyntaxException
     *             exception
     */
    public URI buildUrl() throws URISyntaxException {
        HttpClientURIBuilder ub = new HttpClientURIBuilder(getUrlPath());
        ub.setHost(getHost());
        ub.setScheme(getScheme());
        ub.addParameter("response_type", getResponseType());
        ub.addParameter("client_id", getClientId());
        if (StringUtils.isNotEmpty(getOptionalState())) {
            ub.addParameter(STATE, getOptionalState());
        }
        if (StringUtils.isNotEmpty(getRedirectUrl())) {
            ub.addParameter("redirect_uri", getRedirectUrl());
        }

        for (Map.Entry<String, String> entry : extraQueryParams.entrySet()) {
            ub.addParameter(entry.getKey(), entry.getValue());
        }

        HttpClientURLEncodedUtils.format(ub.getQueryParams(), "UTF-8");
        return ub.build();
    }
View Full Code Here

TOP

Related Classes of com.box.restclientv2.authorization.DefaultAuthHeaderAuthTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.