本文整理汇总了Java中net.openid.appauth.AuthorizationRequest类的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationRequest类的具体用法?Java AuthorizationRequest怎么用?Java AuthorizationRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthorizationRequest类属于net.openid.appauth包,在下文中一共展示了AuthorizationRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Login
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
public void Login(View view) {
AuthManager authManager = AuthManager.getInstance(this);
AuthorizationService authService = authManager.getAuthService();
Auth auth = authManager.getAuth();
AuthorizationRequest authRequest = new AuthorizationRequest
.Builder(
authManager.getAuthConfig(),
auth.getClientId(),
auth.getResponseType(),
Uri.parse(auth.getRedirectUri()))
.setScope(auth.getScope())
.build();
Intent authIntent = new Intent(this, LoginAuthActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, authRequest.hashCode(), authIntent, 0);
authService.performAuthorizationRequest(
authRequest,
pendingIntent);
}
示例2: startUserAuth
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
private void startUserAuth() {
Log.i(TAG, "Starting user auth");
loginListener.onEvent(AuthRepo.this, AUTH_USER_AUTH_START);
// may need to do this off UI thread?
AuthorizationRequest.Builder authRequestBuilder = new AuthorizationRequest.Builder(
authState.getAuthorizationServiceConfiguration(),
clientId,
ResponseTypeValues.CODE,
Uri.parse(redirectUri))
.setScope(authScope);
AuthorizationRequest authRequest = authRequestBuilder.build();
CustomTabsIntent.Builder intentBuilder =
authService.createCustomTabsIntentBuilder(authRequest.toUri());
intentBuilder.setToolbarColor(app.getColorValue(R.color.colorAccent));
CustomTabsIntent authIntent = intentBuilder.build();
Intent intent = authService.getAuthorizationRequestIntent(authRequest, authIntent);
loginListener.onUserAgentRequest(AuthRepo.this, intent);
}
示例3: onClick
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
@Override
public void onClick(View view) {
AuthorizationServiceConfiguration serviceConfiguration = new AuthorizationServiceConfiguration(
Uri.parse("https://accounts.google.com/o/oauth2/v2/auth") /* auth endpoint */,
Uri.parse("https://www.googleapis.com/oauth2/v4/token") /* token endpoint */
);
String clientId = "511828570984-fuprh0cm7665emlne3rnf9pk34kkn86s.apps.googleusercontent.com";
Uri redirectUri = Uri.parse("com.google.codelabs.appauth:/oauth2callback");
AuthorizationRequest.Builder builder = new AuthorizationRequest.Builder(
serviceConfiguration,
clientId,
AuthorizationRequest.RESPONSE_TYPE_CODE,
redirectUri
);
builder.setScopes("profile");
AuthorizationRequest request = builder.build();
AuthorizationService authorizationService = new AuthorizationService(view.getContext());
String action = "com.google.codelabs.appauth.HANDLE_AUTHORIZATION_RESPONSE";
Intent postAuthorizationIntent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getActivity(view.getContext(), request.hashCode(), postAuthorizationIntent, 0);
authorizationService.performAuthorizationRequest(request, pendingIntent);
}
示例4: makeAuthRequest
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
private void makeAuthRequest(
@NonNull AuthorizationServiceConfiguration serviceConfig,
@NonNull IdentityProvider idp) {
AuthorizationRequest authRequest = new AuthorizationRequest.Builder(
serviceConfig,
idp.getClientId(),
ResponseTypeValues.CODE,
idp.getRedirectUri())
.setScope(idp.getScope())
.build();
Log.d(TAG, "Making auth request to " + idp.name);
mAuthService.performAuthorizationRequest(
authRequest,
TokenActivity.createPostAuthorizationIntent(
this,
authRequest,
serviceConfig.discoveryDoc,
idp.getClientSecret()),
mAuthService.createCustomTabsIntentBuilder()
.setToolbarColor(getCustomTabColor())
.build());
}
示例5: createPostAuthorizationIntent
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
static PendingIntent createPostAuthorizationIntent(
@NonNull Context context,
@NonNull AuthorizationRequest request,
@Nullable AuthorizationServiceDiscovery discoveryDoc,
@Nullable String clientSecret) {
Intent intent = new Intent(context, TokenActivity.class);
if (discoveryDoc != null) {
intent.putExtra(EXTRA_AUTH_SERVICE_DISCOVERY, discoveryDoc.docJson.toString());
}
if (clientSecret != null) {
intent.putExtra(EXTRA_CLIENT_SECRET, clientSecret);
}
return PendingIntent.getActivity(context, request.hashCode(), intent, 0);
}
示例6: sendAuthRequest
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
private void sendAuthRequest(AuthorizationServiceConfiguration serviceConfiguration) {
Options options = GlobalObjectRegistry.getObject(Options.class);
String clientId = options.getGoogleClientId();
String authRedirect = String.format("%s:/oauth2redirect", context.getPackageName());
Uri redirectUri = Uri.parse(authRedirect);
AuthorizationRequest request = new AuthorizationRequest.Builder(
serviceConfiguration,
clientId,
ResponseTypeValues.CODE,
redirectUri)
.setScopes(authMode.getPermissions())
.build();
PendingIntent pendingIntent = GoogleResponseHandler.createPostAuthorizationIntent(context, request);
service.performAuthorizationRequest(request, pendingIntent);
service.dispose();
}
示例7: makeAuthRequest
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
/**
* Makes authentication request to endpoints in discovery document
*
* @param authorizationServiceConfiguration: AppAuth authorizationService detail
*/
private void makeAuthRequest(
@NonNull AuthorizationServiceConfiguration authorizationServiceConfiguration
) {
AuthorizationRequest authorizationRequest = new AuthorizationRequest.Builder(
authorizationServiceConfiguration,
configuration.kClientID,
AuthorizationRequest.RESPONSE_TYPE_CODE,
Uri.parse(configuration.kRedirectURI)).setScope(SCOPE).build();
Log.d(TAG, "Making auth request to " + authorizationServiceConfiguration.authorizationEndpoint);
mAuthService.performAuthorizationRequest(
authorizationRequest,
createPostAuthorizationIntent(
this.getApplicationContext(),
authorizationRequest,
authorizationServiceConfiguration.discoveryDoc
));
}
示例8: openPostLogoutRedirectUri
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
public void openPostLogoutRedirectUri(String clientId, String postLogoutRedirectUri, PendingIntent postLogoutIntent) throws JSONException {
final AuthorizationServiceConfiguration configuration = state.getAuthorizationServiceConfiguration();
final JSONObject discoveryDoc = configuration.discoveryDoc.docJson;
final Uri endSessionEndpoint = Uri.parse(discoveryDoc.getString("end_session_endpoint"));
final Map<String, String> additionalParameters = new HashMap<>();
additionalParameters.put("post_logout_redirect_uri", postLogoutRedirectUri);
additionalParameters.put("id_token_hint", state.getIdToken());
final AuthorizationServiceConfiguration logoutConfiguration =
new AuthorizationServiceConfiguration(endSessionEndpoint, configuration.tokenEndpoint, null);
final AuthorizationRequest request = new AuthorizationRequest.Builder(
logoutConfiguration,
clientId,
"none",
Uri.parse(postLogoutRedirectUri))
.setAdditionalParameters(additionalParameters)
.build();
CustomTabsIntent customTabsIntent = service.createCustomTabsIntentBuilder(request.toUri()).build();
service.performAuthorizationRequest(request, postLogoutIntent, postLogoutIntent, customTabsIntent);
}
示例9: initiateLogin
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
@WorkerThread
private void initiateLogin() {
AuthorizationRequest request = new AuthorizationRequest.Builder(
configuration.get(),
staticConfiguration.getClientId(),
ResponseTypeValues.CODE,
Uri.parse(staticConfiguration.getRedirectUri()))
.setScope(staticConfiguration.getScope())
.setPrompt(staticConfiguration.getPrompt())
.build();
Intent postLoginIntent = new Intent(this, PostLoginActivity.class);
Intent loginCancelledIntent = new Intent(this, LoginCancelledActivity.class);
loginCancelledIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
CustomTabsIntent customTabsIntent = service.createCustomTabsIntentBuilder(request.toUri()).build();
service.performAuthorizationRequest(
request,
PendingIntent.getActivity(this, 0, postLoginIntent, 0),
PendingIntent.getActivity(this, 1, loginCancelledIntent, 0),
customTabsIntent);
}
示例10: AppAuthWebView
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private AppAuthWebView(Context context,
IAppAuthWebViewListener appAuthWebViewListener,
WebView webView,
AppAuthWebViewData appAuthWebViewData,
long connectionTimeOut
) {
this.mAppAuthWebViewListener = appAuthWebViewListener;
this.mWebView = webView;
this.mAppAuthWebViewData = appAuthWebViewData;
this.mConnectionTimeOut = connectionTimeOut == 0L ? 30000L : connectionTimeOut;
mContext = context;
mAuthConfig = new AuthorizationServiceConfiguration(
Uri.parse(mAppAuthWebViewData.getAuthorizationEndpointUri()),
Uri.parse(mAppAuthWebViewData.getTokenEndpointUri()),
Uri.parse(mAppAuthWebViewData.getRegistrationEndpointUri())
);
AppAuthConfiguration.Builder appAuthConfigBuilder = new AppAuthConfiguration.Builder();
appAuthConfigBuilder.setConnectionBuilder(AppAuthConnectionBuilderForTesting.INSTANCE);
AppAuthConfiguration appAuthConfig = appAuthConfigBuilder.build();
mAuthService = new AuthorizationService(mContext, appAuthConfig);
AuthorizationRequest.Builder authRequestBuilder = new AuthorizationRequest
.Builder(
mAuthConfig,
mAppAuthWebViewData.getClientId(),
mAppAuthWebViewData.getResponseType(),
Uri.parse(mAppAuthWebViewData.getRedirectLoginUri())
)
.setScope(mAppAuthWebViewData.getScope());
if (mAppAuthWebViewData.isGenerateCodeVerifier()) {
mCodeVerifier = CodeVerifierUtil.generateRandomCodeVerifier();
} else {
mCodeVerifier = null;
}
authRequestBuilder.setCodeVerifier(mCodeVerifier);
mAuthRequest = authRequestBuilder.build();
mWebView.setWebViewClient(new AppAuthWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
}
示例11: onClick
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
@Override
public void onClick(View view) {
AuthorizationServiceConfiguration serviceConfiguration = new AuthorizationServiceConfiguration(
Uri.parse("https://accounts.google.com/o/oauth2/v2/auth") /* auth endpoint */,
Uri.parse("https://www.googleapis.com/oauth2/v4/token") /* token endpoint */
);
AuthorizationService authorizationService = new AuthorizationService(view.getContext());
String clientId = "511828570984-fuprh0cm7665emlne3rnf9pk34kkn86s.apps.googleusercontent.com";
Uri redirectUri = Uri.parse("com.google.codelabs.appauth:/oauth2callback");
AuthorizationRequest.Builder builder = new AuthorizationRequest.Builder(
serviceConfiguration,
clientId,
AuthorizationRequest.RESPONSE_TYPE_CODE,
redirectUri
);
builder.setScopes("profile");
if(mMainActivity.getLoginHint() != null){
Map loginHintMap = new HashMap<String, String>();
loginHintMap.put(LOGIN_HINT,mMainActivity.getLoginHint());
builder.setAdditionalParameters(loginHintMap);
Log.i(LOG_TAG, String.format("login_hint: %s", mMainActivity.getLoginHint()));
}
AuthorizationRequest request = builder.build();
String action = "com.google.codelabs.appauth.HANDLE_AUTHORIZATION_RESPONSE";
Intent postAuthorizationIntent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getActivity(view.getContext(), request.hashCode(), postAuthorizationIntent, 0);
authorizationService.performAuthorizationRequest(request, pendingIntent);
}
示例12: authorize
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
private void authorize(AuthorizationServiceConfiguration authServiceConfiguration) {
// NOTE: Required for PingFederate 8.1 and below for the .setCodeVerifier() option below
// to generate "plain" code_challenge_method these versions of PingFederate do not support
// S256 PKCE.
String codeVerifier = CodeVerifierUtil.generateRandomCodeVerifier();
// OPTIONAL: Add any additional parameters to the authorization request
HashMap<String, String> additionalParams = new HashMap<>();
additionalParams.put("acr_values", "urn:acr:form");
AuthorizationRequest authRequest = new AuthorizationRequest.Builder(
authServiceConfiguration,
OIDC_CLIENT_ID,
AuthorizationRequest.RESPONSE_TYPE_CODE,
Uri.parse(OIDC_REDIRECT_URI))
.setScope(OIDC_SCOPE)
.setCodeVerifier(codeVerifier, codeVerifier, "plain")
.setAdditionalParameters(additionalParams)
.build();
Log.d(TAG, "Making auth request to " + authServiceConfiguration.authorizationEndpoint);
mAuthService.performAuthorizationRequest(
authRequest,
createPostAuthorizationIntent(
this.getApplicationContext(),
authRequest,
authServiceConfiguration.discoveryDoc));
}
示例13: createPostAuthorizationIntent
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
private PendingIntent createPostAuthorizationIntent(
@NonNull Context context,
@NonNull AuthorizationRequest request,
@Nullable AuthorizationServiceDiscovery discoveryDoc) {
Intent intent = new Intent(context, this.getClass());
if (discoveryDoc != null) {
intent.putExtra(EXTRA_AUTH_SERVICE_DISCOVERY, discoveryDoc.docJson.toString());
}
return PendingIntent.getActivity(context, request.hashCode(), intent, 0);
}
示例14: createAuthRequest
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
private void createAuthRequest(@Nullable String loginHint) {
Log.i(TAG, "Creating auth request for login hint: " + loginHint);
AuthorizationRequest.Builder authRequestBuilder = new AuthorizationRequest.Builder(
mAuthStateManager.getCurrent().getAuthorizationServiceConfiguration(),
mClientId.get(),
ResponseTypeValues.CODE,
mConfiguration.getRedirectUri())
.setScope(mConfiguration.getScope());
if (!TextUtils.isEmpty(loginHint)) {
authRequestBuilder.setLoginHint(loginHint);
}
mAuthRequest.set(authRequestBuilder.build());
}
示例15: createPostAuthorizationIntent
import net.openid.appauth.AuthorizationRequest; //导入依赖的package包/类
public static PendingIntent createPostAuthorizationIntent(@NonNull Context context,
@NonNull AuthorizationRequest request) {
String action = context.getString(R.string.es_google_auth_response);
Intent intent = new Intent(action);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return PendingIntent.getActivity(context, request.hashCode(), intent, 0);
}