• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Credential类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.auth.api.credentials.Credential的典型用法代码示例。如果您正苦于以下问题:Java Credential类的具体用法?Java Credential怎么用?Java Credential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Credential类属于com.google.android.gms.auth.api.credentials包,在下文中一共展示了Credential类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "onActivityResult:" + requestCode + ":" + resultCode + ":" + data);

    if (requestCode == RC_READ) {
        if (resultCode == RESULT_OK) {
            Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
            processRetrievedCredential(credential);
        } else {
            Log.e(TAG, "Credential Read: NOT OK");
            setSignInEnabled(true);
        }
    } else if (requestCode == RC_SAVE) {
        Log.d(TAG, "Result code: " + resultCode);
        if (resultCode == RESULT_OK) {
            Log.d(TAG, "Credential Save: OK");
        } else {
            Log.e(TAG, "Credential Save Failed");
        }
        goToContent();
    }
    mIsResolving = false;
}
 
开发者ID:obaro,项目名称:SmartLockSample,代码行数:25,代码来源:LoginActivity.java


示例2: saveCredential

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
protected void saveCredential(Credential credential) {
    // Credential is valid so save it.
    Auth.CredentialsApi.save(mGoogleApiClient,
            credential).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(Status status) {
            if (status.isSuccess()) {
                Log.d(TAG, "Credential saved");
                goToContent();
            } else {
                Log.d(TAG, "Attempt to save credential failed " +
                        status.getStatusMessage() + " " +
                        status.getStatusCode());
                resolveResult(status, RC_SAVE);
            }
        }
    });
}
 
开发者ID:obaro,项目名称:SmartLockSample,代码行数:19,代码来源:LoginActivity.java


示例3: onActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        case GoogleApiAdapter.GOOGLE_SIGN_IN:
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            handleSignInResult(result);
            break;
        case GoogleApiAdapter.REGISTER_CREDENTIAL:
            login();
            break;
        case GoogleApiAdapter.RETRIEVE_CREDENTIALS:
            if (resultCode == RESULT_OK) {
                onCredentialRetrieved((Credential) data.getParcelableExtra(Credential.EXTRA_KEY));
            }
            break;
        case REQUEST_PERMISSION:
            refreshGCMToken();
            break;

    }
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:24,代码来源:LoginActivity.java


示例4: onCredentialRetrieved

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
void onCredentialRetrieved(Credential credential) {
    if (IdentityProviders.GOOGLE.equals(credential.getAccountType())) {
        final GoogleSignInResult result = googleApi.performSilentSignIn().get();
        if (result.isSuccess()) {
            createGoogleAccount(result.getSignInAccount());
        } else if (result.getStatus().hasResolution()) {
            try {
                result.getStatus().startResolutionForResult(this, GoogleApiAdapter.GOOGLE_SIGN_IN);
            } catch (IntentSender.SendIntentException e) {
                Snackbar.make(vLoginForm, R.string.error_smartlock_failed, Snackbar.LENGTH_LONG);
            }
        }
    } else {
        etUsername.setText(credential.getId());
        etPassword.setText(credential.getPassword());
        attemptLogin();
    }
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:19,代码来源:LoginActivity.java


示例5: handleActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_READ) {
        if (resultCode == Activity.RESULT_OK && data != null) {
            Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
            getListener().onCredentialRetrieved(credential);
        } else {
            getListener().onCredentialRetrievalFailed();
        }

        return true;
    }

    if (requestCode == RC_SAVE) {
        if (resultCode == Activity.RESULT_OK) {
            Log.d(TAG, "RC_SAVE: Ok");
        } else {
            Log.d(TAG, "RC_SAVE: Failure");
        }

        return true;
    }

    return false;
}
 
开发者ID:googlearchive,项目名称:easygoogle,代码行数:26,代码来源:SmartLock.java


示例6: getCredentials

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
/**
 * Begin the process of retrieving a {@link Credential} for the device user. This can have
 * a few different results:
 *   1) If the user has auto sign-in enabled and exactly one previously saved credential,
 *      {@link SmartLockListener#onCredentialRetrieved(Credential)} will be called and
 *      you can sign the user in immediately.
 *   2) If the user has multiple saved credentials or one saved credential and has disabled
 *      auto sign-in, you will get the callback {@link SmartLockListener#onShouldShowCredentialPicker()}
 *      at which point you can choose to show the picker dialog to continue.
 *   3) If the user has no saved credentials or cancels the operation, you will receive the
 *      {@link SmartLockListener#onCredentialRetrievalFailed()} callback.
 */
public void getCredentials() {
    CredentialRequest request = buildCredentialRequest();

    Auth.CredentialsApi.request(getFragment().getGoogleApiClient(), request)
            .setResultCallback(new ResultCallback<CredentialRequestResult>() {
                @Override
                public void onResult(CredentialRequestResult result) {
                    if (result.getStatus().isSuccess()) {
                        // Single credential, auto sign-in
                        Credential credential = result.getCredential();
                        getListener().onCredentialRetrieved(credential);
                    } else if (result.getStatus().hasResolution() &&
                            result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED) {
                        // Multiple credentials or auto-sign in disabled.  If the status
                        // code is SIGN_IN_REQUIRED then it is a hint credential, which we
                        // do not want at this point.
                        getListener().onShouldShowCredentialPicker();
                    } else {
                        // Could not retrieve credentials
                        getListener().onCredentialRetrievalFailed();
                    }
                }
            });
}
 
开发者ID:googlearchive,项目名称:easygoogle,代码行数:37,代码来源:SmartLock.java


示例7: getCredentialsFromFirebaseUser

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
/**
 * Make a list of {@link Credential} from a FirebaseUser. Useful for deleting Credentials, not
 * for saving since we don't have access to the password.
 */
private static List<Credential> getCredentialsFromFirebaseUser(@NonNull FirebaseUser user) {
    if (TextUtils.isEmpty(user.getEmail()) && TextUtils.isEmpty(user.getPhoneNumber())) {
        return Collections.emptyList();
    }

    List<Credential> credentials = new ArrayList<>();
    for (UserInfo userInfo : user.getProviderData()) {
        if (FirebaseAuthProvider.PROVIDER_ID.equals(userInfo.getProviderId())) {
            continue;
        }

        String type = ProviderUtils.providerIdToAccountType(userInfo.getProviderId());

        credentials.add(new Credential.Builder(
                user.getEmail() == null ? user.getPhoneNumber() : user.getEmail())
                .setAccountType(type)
                .build());
    }

    return credentials;
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:26,代码来源:AuthUI.java


示例8: onActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case RC_HINT:
            if (data != null) {
                mLastCredential = data.getParcelableExtra(Credential.EXTRA_KEY);
                if (mLastCredential != null) {
                    // Get the email from the credential
                    mEmailEditText.setText(mLastCredential.getId());

                    // Attempt to proceed
                    validateAndProceed();
                }
            }
            break;
        case RC_SIGN_IN:
        case RC_WELCOME_BACK_IDP:
            finish(resultCode, data);
            break;
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:23,代码来源:CheckEmailFragment.java


示例9: onActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SAVE) {
        if (resultCode != Activity.RESULT_OK) {
            Log.e(TAG, "SAVE: Canceled by user");
        }
        finish();
    } else if (requestCode == RC_UPDATE_SERVICE) {
        if (resultCode == Activity.RESULT_OK) {
            Credential credential = new Credential.Builder(mEmail).setPassword(mPassword)
                    .build();

            getAuthHelper().getCredentialsApi()
                    .save(mGoogleApiClient, credential)
                    .setResultCallback(this);
        } else {
            Log.e(TAG, "SAVE: Canceled by user");
            finish();
        }
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:24,代码来源:SaveSmartLock.java


示例10: onConnected

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
void onConnected(final SmartLock smartLock, final Activity activity) {
    Log.v(TAG, "Requesting credentials from SmartLock");
    getCredentialsApi().request(smartLock.getCredentialClient(), smartLock.newCredentialRequest()).setResultCallback(new ResultCallback<CredentialRequestResult>() {
        @Override
        public void onResult(CredentialRequestResult credentialRequestResult) {
            final com.google.android.gms.common.api.Status status = credentialRequestResult.getStatus();
            if (status.isSuccess()) {
                final Credential credential = credentialRequestResult.getCredential();
                Log.v(TAG, "Retrieved credentials for type " + credential.getAccountType());
                smartLock.onCredentialsRetrieved(activity, credential);
            } else {
                smartLock.onCredentialRetrievalError(activity, status, SmartLock.SMART_LOCK_READ);
            }
        }
    });
}
 
开发者ID:auth0,项目名称:Lock-SmartLock,代码行数:18,代码来源:RequestCredentialsTask.java


示例11: onActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
/**
 * Method called in {@link Activity#onActivityResult(int, int, Intent)} callback to handle SmartLock interaction
 * @param activity that received the result
 * @param requestCode of the request
 * @param resultCode received by the activity
 * @param data of the result
 */
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case SMART_LOCK_READ:
            if (resultCode == Activity.RESULT_OK) {
                Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
                onCredentialsRetrieved(activity, credential);
            } else {
                startLockFromActivity(activity);
            }
            break;
        case SMART_LOCK_SAVE:
            final CredentialStoreCallback callback = getCallback();
            if (resultCode == Activity.RESULT_OK) {
                callback.onSuccess();
            } else {
                callback.onError(CredentialStoreCallback.CREDENTIAL_STORE_SAVE_CANCELLED, null);
            }
            clearCredentialStoreCallback();
            break;
    }
}
 
开发者ID:auth0,项目名称:Lock-SmartLock,代码行数:30,代码来源:SmartLock.java


示例12: saveFromActivity

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
/**
 * Saves the user's credentials in Smart Lock for Android
 * @param activity that wants to save the credentials
 * @param username of the used to login
 * @param email of the user
 * @param password of the used to login
 * @param pictureUrl of the user
 * @param callback that will be called when the operation is completed
 */
@Override
public void saveFromActivity(Activity activity, String username, String email, String password, String pictureUrl, CredentialStoreCallback callback) {
    if ((username == null && email == null) || password == null) {
        Log.w(TAG, "Invalid credentials to save in Smart Lock");
        callback.onError(CredentialStoreCallback.CREDENTIAL_STORE_SAVE_FAILED, null);
        clearCredentialStoreCallback();
        return;
    }
    setCallback(callback);
    String id = email != null ? email : username;
    Uri pictureUri = pictureUrl != null ? Uri.parse(pictureUrl) : null;
    final Credential credential = new Credential.Builder(id)
            .setName(username)
            .setProfilePictureUri(pictureUri)
            .setPassword(password)
            .build();
    startTask(new SaveCredentialTask(activity, credential));
}
 
开发者ID:auth0,项目名称:Lock-SmartLock,代码行数:28,代码来源:SmartLock.java


示例13: onCredentialsRetrieved

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
void onCredentialsRetrieved(final Activity activity, final Credential credential) {
    Log.v(TAG, "Credentials : " + credential.getName());
    String email = credential.getId();
    String password = credential.getPassword();

    getAPIClient().login(email, password, getAuthenticationParameters(), new AuthenticationCallback() {
        @Override
        public void onSuccess(UserProfile profile, Token token) {
            Intent result = new Intent(Lock.AUTHENTICATION_ACTION)
                    .putExtra(Lock.AUTHENTICATION_ACTION_PROFILE_PARAMETER, profile)
                    .putExtra(Lock.AUTHENTICATION_ACTION_TOKEN_PARAMETER, token);
            LocalBroadcastManager.getInstance(activity).sendBroadcast(result);
        }

        @Override
        public void onFailure(Throwable throwable) {
            LoginAuthenticationErrorBuilder builder = new LoginAuthenticationErrorBuilder();
            AuthenticationError error = builder.buildFrom(throwable);
            ErrorDialogBuilder.showAlertDialog(activity, error);
        }
    });
}
 
开发者ID:auth0,项目名称:Lock-SmartLock,代码行数:23,代码来源:SmartLock.java


示例14: onActivityResult

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CREDENTIAL_REQUEST_RC) {
        if (resultCode == RESULT_OK) {
            mSmartLock.retrieveCredentialFromIntent(data).subscribe(new Action1<Credential>() {
                @Override
                public void call(Credential credential) {
                    onSuccess(credential);
                }
            });
        } else {
            Log.e(TAG, "Credential Read: NOT OK");
        }
    }

}
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:20,代码来源:MainActivity.java


示例15: call

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
@Override
public void call(Subscriber<? super Credential> subscriber) {

    final GoogleApiClient googleApiClient = buildGoogleApiClient(subscriber);

    try {
        googleApiClient.connect();
    } catch (Exception e) {
        subscriber.onError(e);
    }

    subscriber.add(Subscriptions.create(new Action0() {
        @Override
        public void call() {
            if (googleApiClient.isConnected() || googleApiClient.isConnecting()) {
                googleApiClient.disconnect();
            }
        }
    }));

}
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:22,代码来源:RetrieveCredentialObservable.java


示例16: retrieveCredential

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
public Observable<Credential> retrieveCredential() {

        return Observable.defer(new Func0<Observable<Credential>>() {
            @Override
            public Observable<Credential> call() {
                try {
                    return Observable.create(
                            new RetrieveCredentialObservable(mContext, mCredentialRequest)
                    );
                } catch (Exception e) {
                    return Observable.error(e);
                }
            }
        });

    }
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:17,代码来源:SmartLock.java


示例17: storeCredential

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
public Observable<Boolean> storeCredential(final Credential credential) {

        return Observable.defer(new Func0<Observable<Boolean>>() {
            @Override
            public Observable<Boolean> call() {
                try {
                    return Observable.create(
                            new StoreCredentialObservable(mContext, credential)
                    );
                } catch (Exception e) {
                    return Observable.error(e);
                }
            }
        });

    }
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:17,代码来源:SmartLock.java


示例18: deleteCredential

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
public Observable<Boolean> deleteCredential(final Credential credential) {

        return Observable.defer(new Func0<Observable<Boolean>>() {
            @Override
            public Observable<Boolean> call() {
                try {
                    return Observable.create(
                            new DeleteCredentialObservable(mContext, credential)
                    );
                } catch (Exception e) {
                    return Observable.error(e);
                }
            }
        });

    }
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:17,代码来源:SmartLock.java


示例19: saveCredential

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
/**
 * Save credential in smart lock for passwords an notify a subject
 *
 * @param statusObject the subject to notify
 * @param credential the credential
 * @param smartLockOptions the options (may be null)
 */
public void saveCredential(PublishSubject<RxStatus> statusObject,
                           Credential credential,
                           @Nullable SmartLockOptions smartLockOptions) {

    mCredentialAction = CredentialAction.SAVE;
    mStatusSubject = statusObject;
    mCredential = credential;
    mSmartLockOptions = smartLockOptions;
    mCredentialsApiClient.connect();
}
 
开发者ID:pchmn,项目名称:RxSocialAuth,代码行数:18,代码来源:RxSmartLockPasswordsFragment.java


示例20: deleteCredential

import com.google.android.gms.auth.api.credentials.Credential; //导入依赖的package包/类
/**
 * Delete credential
 */
public void deleteCredential(PublishSubject<RxStatus> statusObject, Credential credential) {
    mCredentialAction = CredentialAction.DELETE;
    mStatusSubject = statusObject;
    mCredential = credential;
    mCredentialsApiClient.connect();
}
 
开发者ID:pchmn,项目名称:RxSocialAuth,代码行数:10,代码来源:RxSmartLockPasswordsFragment.java



注:本文中的com.google.android.gms.auth.api.credentials.Credential类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Animation类代码示例发布时间:2022-05-23
下一篇:
Java Status类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap