Package com.box.boxjavalibv2

Examples of com.box.boxjavalibv2.BoxConfigBuilder


    public static CachedBoxClient createBoxClient(final BoxConfiguration configuration) {

        final String clientId = configuration.getClientId();
        final String clientSecret = configuration.getClientSecret();

        final IAuthSecureStorage authSecureStorage = configuration.getAuthSecureStorage();
        final String userName = configuration.getUserName();
        final String userPassword = configuration.getUserPassword();

        if ((authSecureStorage == null && ObjectHelper.isEmpty(userPassword))
            || ObjectHelper.isEmpty(userName) || ObjectHelper.isEmpty(clientId) || ObjectHelper.isEmpty(clientSecret)) {
View Full Code Here


                return;
            }

            LOG.debug("Getting OAuth token for {}...", cachedBoxClient);

            final IAuthSecureStorage authSecureStorage = cachedBoxClient.getSecureStorage();
            if (authSecureStorage != null && authSecureStorage.getAuth() != null) {

                LOG.debug("Using secure storage for {}", cachedBoxClient);
                // authenticate using stored refresh token
                boxClient.authenticateFromSecureStorage(authSecureStorage);
            } else {
View Full Code Here

    public static CachedBoxClient createBoxClient(final BoxConfiguration configuration) {

        final String clientId = configuration.getClientId();
        final String clientSecret = configuration.getClientSecret();

        final IAuthSecureStorage authSecureStorage = configuration.getAuthSecureStorage();
        final String userName = configuration.getUserName();
        final String userPassword = configuration.getUserPassword();

        if ((authSecureStorage == null && ObjectHelper.isEmpty(userPassword))
            || ObjectHelper.isEmpty(userName) || ObjectHelper.isEmpty(clientId) || ObjectHelper.isEmpty(clientSecret)) {
View Full Code Here

                return;
            }

            LOG.debug("Getting OAuth token for {}...", cachedBoxClient);

            final IAuthSecureStorage authSecureStorage = cachedBoxClient.getSecureStorage();
            if (authSecureStorage != null && authSecureStorage.getAuth() != null) {

                LOG.debug("Using secure storage for {}", cachedBoxClient);
                // authenticate using stored refresh token
                boxClient.authenticateFromSecureStorage(authSecureStorage);
            } else {
View Full Code Here

            options.put(entry.getKey().toString(), entry.getValue());
        }

        final BoxConfiguration configuration = new BoxConfiguration();
        IntrospectionSupport.setProperties(configuration, options);
        configuration.setAuthSecureStorage(new IAuthSecureStorage() {

            @Override
            public void saveAuth(IAuthData auth) {
                if (auth == null) {
                    // revoked
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

TOP

Related Classes of com.box.boxjavalibv2.BoxConfigBuilder

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.