Java源码示例:com.wuman.android.auth.DialogFragmentController

示例1
public static OAuth newInstance(Context context,
        FragmentManager fragmentManager,
        ClientParametersAuthentication client,
        String authorizationRequestUrl,
        String tokenServerUrl,
        final String redirectUri,
        List<String> scopes,
        String temporaryTokenRequestUrl) {
    Preconditions.checkNotNull(client.getClientId());
    boolean fullScreen = context.getSharedPreferences("Preference", 0)
        .getBoolean(StravaConstants.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(context,
                    StravaConstants.CREDENTIALS_STORE_PREF_FILE, JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow.Builder flowBuilder = new AuthorizationFlow.Builder(
            BearerToken.authorizationHeaderAccessMethod(),
            HTTP_TRANSPORT,
            JSON_FACTORY,
            new GenericUrl(tokenServerUrl),
            client,
            client.getClientId(),
            authorizationRequestUrl)
            .setScopes(scopes)
            .setCredentialStore(credentialStore);
    // set temporary token request url for 1.0a flow if applicable
    if (!TextUtils.isEmpty(temporaryTokenRequestUrl)) {
        flowBuilder.setTemporaryTokenRequestUrl(temporaryTokenRequestUrl);
    }
    AuthorizationFlow flow = flowBuilder.build();
    // setup authorization UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(fragmentManager, fullScreen) {

                @Override
                public String getRedirectUri() throws IOException {
                    return redirectUri;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    return new OAuth(flow, controller);
}
 
示例2
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(getActivity(), _credentialsStorePrefFile, OAuth.JSON_FACTORY);

    // setup authorization flow
    AuthorizationFlow flow = new AuthorizationFlow.Builder(
            BearerToken.queryParameterAccessMethod(),
            OAuth.HTTP_TRANSPORT,
            OAuth.JSON_FACTORY,
            new GenericUrl(_urlToken),
            new ClientParametersAuthentication(_clientId, _clientSecret),
            _clientId,
            _urlAuthorize)
            .setScopes(Arrays.asList("view_private,write"))
            .setCredentialStore(credentialStore)
            .setRequestInitializer(new HttpRequestInitializer() {
                @Override
                public void initialize(HttpRequest request) throws IOException {}
            })
            .build();
    // setup UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(getFragmentManager(), true) {
                @Override
                public String getRedirectUri() throws IOException {
                    return _redirectUrl;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    // instantiate an OAuthManager instance
    oauth = new OAuthManager(flow, controller);
}
 
示例3
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    boolean fullScreen = getActivity().getSharedPreferences("Preference", 0)
        .getBoolean(SamplesActivity.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(getActivity(),
                    SamplesConstants.CREDENTIALS_STORE_PREF_FILE, OAuth.JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow flow = new AuthorizationFlow.Builder(
            BearerToken.authorizationHeaderAccessMethod(),
            OAuth.HTTP_TRANSPORT,
            OAuth.JSON_FACTORY,
            new GenericUrl(FoursquareConstants.TOKEN_SERVER_URL),
            new ClientParametersAuthentication(FoursquareConstants.CLIENT_ID,
                    FoursquareConstants.CLIENT_SECRET),
            FoursquareConstants.CLIENT_ID,
            FoursquareConstants.AUTHORIZATION_CODE_SERVER_URL)
            .setScopes(Lists.<String> newArrayList())
            .setCredentialStore(credentialStore)
            .build();
    // setup UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(getFragmentManager(), fullScreen) {
                @Override
                public String getRedirectUri() throws IOException {
                    return FoursquareConstants.REDIRECT_URL;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    // instantiate an OAuthManager instance
    oauth = new OAuthManager(flow, controller);
}
 
示例4
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    boolean fullScreen = getActivity().getSharedPreferences("Preference", 0)
        .getBoolean(SamplesActivity.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(getActivity(),
                    SamplesConstants.CREDENTIALS_STORE_PREF_FILE, OAuth.JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow flow = new AuthorizationFlow.Builder(
            BearerToken.authorizationHeaderAccessMethod(),
            OAuth.HTTP_TRANSPORT,
            OAuth.JSON_FACTORY,
            new GenericUrl(FoursquareConstants.TOKEN_SERVER_URL),
            new ClientParametersAuthentication(FoursquareConstants.CLIENT_ID, null),
            FoursquareConstants.CLIENT_ID,
            FoursquareConstants.AUTHORIZATION_IMPLICIT_SERVER_URL)
            .setScopes(Lists.<String> newArrayList())
            .setCredentialStore(credentialStore)
            .build();
    // setup UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(getFragmentManager(), fullScreen) {
                @Override
                public String getRedirectUri() throws IOException {
                    return FoursquareConstants.REDIRECT_URL;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    // instantiate an OAuthManager instance
    oauth = new OAuthManager(flow, controller);
}
 
示例5
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    boolean fullScreen = getActivity().getSharedPreferences("Preference", 0)
            .getBoolean(SamplesActivity.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(getActivity(),
                    SamplesConstants.CREDENTIALS_STORE_PREF_FILE, OAuth.JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow flow = new AuthorizationFlow.Builder(
            BearerToken.queryParameterAccessMethod(),
            OAuth.HTTP_TRANSPORT,
            OAuth.JSON_FACTORY,
            new GenericUrl(StravaConstants.URL_TOKEN),
            new ClientParametersAuthentication(StravaConstants.CLIENT_ID,
                    StravaConstants.CLIENT_SECRET),
            StravaConstants.CLIENT_ID,
            StravaConstants.URL_AUTHORIZE)
            .setScopes(Arrays.asList(StravaScopes.SCOPE_PUBLIC))
            .setCredentialStore(credentialStore)
            .setRequestInitializer(new HttpRequestInitializer() {
                @Override
                public void initialize(HttpRequest request) throws IOException {}
            })
            .build();
    // setup UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(getFragmentManager(), fullScreen) {
                @Override
                public String getRedirectUri() throws IOException {
                    return StravaConstants.REDIRECT_URL;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    // instantiate an OAuthManager instance
    oauth = new OAuthManager(flow, controller);
}
 
示例6
public static OAuth newInstance(Context context,
        FragmentManager fragmentManager,
        ClientParametersAuthentication client,
        String authorizationRequestUrl,
        String tokenServerUrl,
        final String redirectUri,
        List<String> scopes,
        String temporaryTokenRequestUrl) {
    Preconditions.checkNotNull(client.getClientId());
    boolean fullScreen = context.getSharedPreferences("Preference", 0)
        .getBoolean(SamplesActivity.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(context,
                    SamplesConstants.CREDENTIALS_STORE_PREF_FILE, JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow.Builder flowBuilder = new AuthorizationFlow.Builder(
            BearerToken.authorizationHeaderAccessMethod(),
            HTTP_TRANSPORT,
            JSON_FACTORY,
            new GenericUrl(tokenServerUrl),
            client,
            client.getClientId(),
            authorizationRequestUrl)
            .setScopes(scopes)
            .setCredentialStore(credentialStore);
    // set temporary token request url for 1.0a flow if applicable
    if (!TextUtils.isEmpty(temporaryTokenRequestUrl)) {
        flowBuilder.setTemporaryTokenRequestUrl(temporaryTokenRequestUrl);
    }
    AuthorizationFlow flow = flowBuilder.build();
    // setup authorization UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(fragmentManager, fullScreen) {

                @Override
                public String getRedirectUri() throws IOException {
                    return redirectUri;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    return new OAuth(flow, controller);
}
 
示例7
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    boolean fullScreen = getActivity().getSharedPreferences("Preference", 0)
        .getBoolean(SamplesActivity.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(getActivity(),
                    SamplesConstants.CREDENTIALS_STORE_PREF_FILE, OAuth.JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow flow = new AuthorizationFlow.Builder(
            BearerToken.authorizationHeaderAccessMethod(),
            OAuth.HTTP_TRANSPORT,
            OAuth.JSON_FACTORY,
            new GenericUrl(LinkedInConstants.OAUTH2_TOKEN_SERVER_URL),
            new ClientParametersAuthentication(LinkedInConstants.CLIENT_ID,
                    LinkedInConstants.CLIENT_SECRET),
            LinkedInConstants.CLIENT_ID,
            LinkedInConstants.AUTHORIZATION_CODE_SERVER_URL)
            .setScopes(Arrays.asList(LinkedInScopes.READ_BASICPROFILE,
                    LinkedInScopes.READ_FULLPROFILE))
            .setCredentialStore(credentialStore)
            .build();
    // setup UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(getFragmentManager(), fullScreen) {
                @Override
                public String getRedirectUri() throws IOException {
                    return LinkedInConstants.REDIRECT_URL;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    // instantiate an OAuthManager instance
    oauth = new OAuthManager(flow, controller);
}
 
示例8
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    boolean fullScreen = getActivity().getSharedPreferences("Preference", 0)
        .getBoolean(SamplesActivity.KEY_AUTH_MODE, false);
    // setup credential store
    SharedPreferencesCredentialStore credentialStore =
            new SharedPreferencesCredentialStore(getActivity(),
                    SamplesConstants.CREDENTIALS_STORE_PREF_FILE, OAuth.JSON_FACTORY);
    // setup authorization flow
    AuthorizationFlow flow = new AuthorizationFlow.Builder(
            BearerToken.authorizationHeaderAccessMethod(),
            OAuth.HTTP_TRANSPORT,
            OAuth.JSON_FACTORY,
            new GenericUrl(LinkedInConstants.OAUTH_TOKEN_SERVER_URL),
            new ClientParametersAuthentication(LinkedInConstants.CLIENT_ID,
                    LinkedInConstants.CLIENT_SECRET),
            LinkedInConstants.CLIENT_ID,
            LinkedInConstants.AUTHORIZATION_VERIFIER_SERVER_URL)
            .setTemporaryTokenRequestUrl(LinkedInConstants.TEMPORARY_TOKEN_REQUEST_URL)
            .setScopes(Arrays.asList(LinkedInScopes.READ_BASICPROFILE,
                    LinkedInScopes.READ_FULLPROFILE))
            .setCredentialStore(credentialStore)
            .build();
    // setup UI controller
    AuthorizationDialogController controller =
            new DialogFragmentController(getFragmentManager(), fullScreen) {
                @Override
                public String getRedirectUri() throws IOException {
                    return LinkedInConstants.REDIRECT_URL;
                }

                @Override
                public boolean isJavascriptEnabledForWebView() {
                    return true;
                }

                @Override
                public boolean disableWebViewCache() {
                    return false;
                }

                @Override
                public boolean removePreviousCookie() {
                    return false;
                }

            };
    // instantiate an OAuthManager instance
    oauth10a = new OAuthManager(flow, controller);
}