Package com.box.boxjavalibv2.authorization

Examples of com.box.boxjavalibv2.authorization.OAuthAuthorization


    public IAuthDataController createAuthDataController(final String clientId, final String clientSecret) {
        return new OAuthDataController(this, clientId, clientSecret, DEFAULT_AUTO_REFRESH);
    }

    public IBoxRequestAuth createAuthorization(IAuthDataController controller) {
        return new OAuthAuthorization((OAuthDataController) authController);
    }
View Full Code Here


    /**
     * From auth data controller, generate IBoxRequestAuth, which can be applied to api requests.
     */
    protected IBoxRequestAuth createAuthorization(IAuthDataController controller) {
        return new OAuthAuthorization((OAuthDataController) authController);
    }
View Full Code Here

        };
    }

    private int makeRequestAndGetStatusCode() throws BoxRestException, AuthFatalFailureException {
        MockRequest request = new MockRequest();
        request.setAuth(new OAuthAuthorization(client.getOAuthDataController()));
        MockRestClient client = new MockRestClient();
        DefaultBoxResponse response = (DefaultBoxResponse) client.execute(request);
        return response.getResponseStatusCode();
    }
View Full Code Here

                final IBoxOAuthManager oAuthManager = boxClient.getOAuthManager();
                final BoxOAuthToken oAuthToken = oAuthManager.createOAuth(authorizationCode,
                    configuration.getClientId(), configuration.getClientSecret(), null);

                // send initial token to BoxClient and this.listener
                final OAuthDataMessage authDataMessage = new OAuthDataMessage(oAuthToken,
                    boxClient.getJSONParser(), boxClient.getResourceHub());
                listener.onAuthFlowEvent(OAuthEvent.OAUTH_CREATED, authDataMessage);
                this.listener.onAuthFlowEvent(OAuthEvent.OAUTH_CREATED, authDataMessage);
            }
View Full Code Here

                final IBoxOAuthManager oAuthManager = boxClient.getOAuthManager();
                final BoxOAuthToken oAuthToken = oAuthManager.createOAuth(authorizationCode,
                    configuration.getClientId(), configuration.getClientSecret(), null);

                // send initial token to BoxClient and this.listener
                final OAuthDataMessage authDataMessage = new OAuthDataMessage(oAuthToken,
                    boxClient.getJSONParser(), boxClient.getResourceHub());
                listener.onAuthFlowEvent(OAuthEvent.OAUTH_CREATED, authDataMessage);
                this.listener.onAuthFlowEvent(OAuthEvent.OAUTH_CREATED, authDataMessage);
            }
View Full Code Here

                    values.put(BoxOAuthToken.FIELD_REFRESH_TOKEN, refreshToken);
                    return new BoxOAuthToken(values);
                }
            }
        });
        configuration.setRefreshListener(new OAuthRefreshListener() {
            @Override
            public void onRefresh(IAuthData newAuthData) {
                log.debug("Refreshed OAuth data: " + ((newAuthData != null) ? newAuthData.getAccessToken() : null));
            }
        });
View Full Code Here

        // authorize application on user's behalf
        try {
            final String csrfId = String.valueOf(new SecureRandom().nextLong());

            OAuthWebViewData viewData = new OAuthWebViewData(boxClient.getOAuthDataController());
            viewData.setOptionalState(String.valueOf(csrfId));
            final HtmlPage authPage = webClient.getPage(viewData.buildUrl().toString());

            // submit login credentials
            final HtmlForm loginForm = authPage.getFormByName("login_form");
            final HtmlTextInput login = loginForm.getInputByName("login");
            login.setText(configuration.getUserName());
View Full Code Here

        // authorize application on user's behalf
        try {
            final String csrfId = String.valueOf(new SecureRandom().nextLong());

            OAuthWebViewData viewData = new OAuthWebViewData(boxClient.getOAuthDataController());
            viewData.setOptionalState(String.valueOf(csrfId));
            final HtmlPage authPage = webClient.getPage(viewData.buildUrl().toString());

            // submit login credentials
            final HtmlForm loginForm = authPage.getFormByName("login_form");
            final HtmlTextInput login = loginForm.getInputByName("login");
            login.setText(configuration.getUserName());
View Full Code Here

        // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxCollabRequestObject
        final BoxCollabRequestObject collabObject = BoxCollabRequestObject.createCollabObject(testFolderId, null,
                "camel.test@localhost.com", BoxCollaborationRole.VIEWER);
        headers.put("CamelBox.collabRequest", collabObject);

        BoxCollaboration result = requestBodyAndHeaders("direct://CREATECOLLABORATION",
                null, headers);
        assertNotNull("createCollaboration result", result);
        // wait a moment for collaboration to register
        Thread.sleep(2000);
        return result;
View Full Code Here

        LOG.debug("getAllCollaborations: " + result);
    }

    @Test
    public void testGetCollaboration() throws Exception {
        final BoxCollaboration collaboration = createCollaboration();

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.collabId", collaboration.getId());
            // parameter type is com.box.restclientv2.requestsbase.BoxDefaultRequestObject
            headers.put("CamelBox.defaultRequest", null);

            BoxCollaboration result = requestBodyAndHeaders("direct://GETCOLLABORATION", null, headers);
            assertNotNull("getCollaboration result", result);
            LOG.debug("getCollaboration: " + result);
        } finally {
            deleteCollaboration(collaboration.getId());
        }
View Full Code Here

TOP

Related Classes of com.box.boxjavalibv2.authorization.OAuthAuthorization

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.