Package com.box.restclientv2.httpclientsupport

Examples of com.box.restclientv2.httpclientsupport.HttpClientURIBuilder


    @Test
    public void testCreateRequestObject() throws BoxRestException {
        String code = "testcode";
        String url = "testurl";
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.createOAuthRequestObject(code, CLIENT_ID, CLIENT_SECRET, url);

        Assert.assertEquals(CLIENT_ID, obj.getFromEntity("client_id"));
        Assert.assertEquals(CLIENT_SECRET, obj.getFromEntity("client_secret"));
        Assert.assertEquals(code, obj.getFromEntity("code"));
        Assert.assertEquals(url, obj.getFromEntity("redirect_url"));
    }
View Full Code Here


    }

    @Test
    public void testRefreshRequestObject() throws BoxRestException {
        String token = "testrefreshtoken";
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.refreshOAuthRequestObject(token, CLIENT_ID, CLIENT_SECRET);

        Assert.assertEquals(CLIENT_ID, obj.getFromEntity("client_id"));
        Assert.assertEquals(CLIENT_SECRET, obj.getFromEntity("client_secret"));
        Assert.assertEquals(token, obj.getFromEntity("refresh_token"));
    }
View Full Code Here

    @Test
    public void testDeviceNameId() {
        String deviceId = "deviceidtest";
        String deviceName = "devicenametest";
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.createOAuthRequestObject("", "", "", "").setDevice(deviceId, deviceName);

        Assert.assertEquals(deviceId, obj.getFromEntity(DEVICE_ID));
        Assert.assertEquals(deviceName, obj.getFromEntity(DEVICE_NAME));

        BoxOAuthRequestObject obj2 = BoxOAuthRequestObject.refreshOAuthRequestObject("", "", "").setDevice(deviceId, deviceName);

        Assert.assertEquals(deviceId, obj2.getFromEntity(DEVICE_ID));
        Assert.assertEquals(deviceName, obj2.getFromEntity(DEVICE_NAME));
    }
View Full Code Here

     *            null if don't want to supply this field.
     */
    @Override
    public BoxOAuthToken createOAuth(final String code, final String clientId, final String clientSecret, final String redirectUrl) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.createOAuthRequestObject(code, clientId, clientSecret, redirectUrl);
        return createOAuth(obj);
    }
View Full Code Here

     *            device name
     */
    @Override
    public BoxOAuthToken createOAuth(final String code, final String clientId, final String clientSecret, final String redirectUrl, final String deviceId,
        final String deviceName) throws BoxRestException, BoxServerException, AuthFatalFailureException {
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.createOAuthRequestObject(code, clientId, clientSecret, redirectUrl).setDevice(deviceId, deviceName);
        return createOAuth(obj);
    }
View Full Code Here

    }

    @Override
    public BoxOAuthToken refreshOAuth(String refreshToken, String clientId, String clientSecret, String deviceId, String deviceName) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.refreshOAuthRequestObject(refreshToken, clientId, clientSecret).setDevice(deviceId, deviceName);
        return refreshOAuth(obj);
    }
View Full Code Here

    }

    @Override
    public BoxOAuthToken refreshOAuth(String refreshToken, String clientId, String clientSecret) throws BoxRestException, BoxServerException,
        AuthFatalFailureException {
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.refreshOAuthRequestObject(refreshToken, clientId, clientSecret);
        return refreshOAuth(obj);
    }
View Full Code Here

        return refreshOAuth(obj);
    }

    @Override
    public void revokeOAuth(String accessToken, String clientId, String clientSecret) throws BoxServerException, BoxRestException, AuthFatalFailureException {
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.revokeOAuthRequestObject(accessToken, clientId, clientSecret);
        revokeOAuth(obj);
    }
View Full Code Here

    @Override
    public void setAuth(IBoxRequest request) throws BoxRestException, AuthFatalFailureException {
        super.setAuth(request);

        DefaultBoxRequest defaultRequest = ((DefaultBoxRequest) request);
        defaultRequest.addQueryParam(PASSWORD, getPassword());
        defaultRequest.addQueryParam(LOGIN, getUserName());
        defaultRequest.addQueryParam(ACTION, AUTH_ACTION);
    }
View Full Code Here

    }

    @Test
    public void prepareRequestTest() throws AuthFatalFailureException {
        try {
            DefaultBoxRequest request = new DefaultBoxRequest(config, new BoxJSONParser(new BoxResourceHub()), uri, restMethod, null);
            request.addQueryParam("a", "b");
            request.setEntity(requestEntity);
            request.prepareRequest();
            HttpRequestBase rawRequest = request.getRawRequest();
            Assert.assertEquals(HttpPost.class, rawRequest.getClass());
            URI url = rawRequest.getURI();
            Assert.assertEquals(scheme, url.getScheme());
            Assert.assertEquals(host, url.getHost());
            Assert.assertEquals(TestUtils.getConfig().getApiUrlPath().concat(uri), url.getPath());
View Full Code Here

TOP

Related Classes of com.box.restclientv2.httpclientsupport.HttpClientURIBuilder

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.