当前位置: 首页>>代码示例>>Java>>正文


Java IdToken类代码示例

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


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

示例1: generateFileName

import com.google.identitytoolkit.IdToken; //导入依赖的package包/类
private String generateFileName() {
    //Get localID
    UserInfoStore client = new UserInfoStore(getActivity());
    IdToken token = client.getSavedIdToken();
    String localId = token.getLocalId();

    //Generate 8 digit random number and encode it in base64
    SecureRandom rand = new SecureRandom();

    StringBuilder rand8Dig = new StringBuilder(8);
    for (int i=0; i < 8; i++) {
        rand8Dig.append((char)('0' + rand.nextInt(10)));
    }
    String randNum = rand8Dig.toString();

    String randNumB64 = Utilities.base64Encoding(randNum);

    String fileName = localId + '.' + randNumB64;

    fileName += 'P'; //'P' marks that a photo is public, future versions will allow for private photos

    return fileName;
}
 
开发者ID:googlearchive,项目名称:Abelana-Android,代码行数:24,代码来源:FeedFragment.java

示例2: onCreate

import com.google.identitytoolkit.IdToken; //导入依赖的package包/类
@Override
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // The gRPC client
    mAbelanaClient = new AbelanaClient(getApplicationContext());

    // Is the user connected? If yes, redirect him to the MainActivity
    if (mAbelanaClient.isSignedIn()) {
        startMainActivity();
    }

    // Step 1: Create a GitkitClient.
    mGitkitClient = GitkitClient.newBuilder(this,
            new GitkitClient.SignInCallbacks() {
                // This method is called when the sign-in process succeeds.
                @Override
                public void onSignIn(final IdToken idToken,
                                     final GitkitUser user) {
                    // Get a session token from the server
                    new SignInTask().execute(idToken.getTokenString());
                }

                // This method is called when the sign-in process fails.
                @Override
                public void onSignInFailed() {
                    Toast.makeText(GitkitActivity.this, "Sign in failed",
                            Toast.LENGTH_LONG).show();
                    showSignInPage();
                }
            })
            .showProviders(AndroidConstants.PROVIDERS)
            .useGooglePlus(AndroidConstants.USE_GOOGLE_PLUS)
            .setApiKey(AndroidConstants.API_KEY)
            .setServerClientId(AndroidConstants.SERVER_CLIENT_ID)
            .setServerWidgetUrl(AndroidConstants.SERVER_WIDGET_URL)
            .build();
    showSignInPage();
}
 
开发者ID:googlearchive,项目名称:abelana,代码行数:40,代码来源:GitkitActivity.java

示例3: getSavedIdToken

import com.google.identitytoolkit.IdToken; //导入依赖的package包/类
public IdToken getSavedIdToken() {
    String tokenString = mPrefs.getString(ID_TOKEN_KEY, null);
    if (tokenString != null) {
        IdToken idToken = IdToken.parse(tokenString);
        if (idToken != null && !idToken.isExpired()) {
            return idToken;
        }
    }
    return null;
}
 
开发者ID:googlearchive,项目名称:Abelana-Android,代码行数:11,代码来源:UserInfoStore.java

示例4: showProfilePage

import com.google.identitytoolkit.IdToken; //导入依赖的package包/类
private void showProfilePage(IdToken idToken, GitkitUser user) {
  setContentView(R.layout.profile);
  showAccount(user);
  findViewById(R.id.sign_out).setOnClickListener(this);
}
 
开发者ID:googlesamples,项目名称:identity-toolkit-android,代码行数:6,代码来源:GitkitDemo.java

示例5: saveIdTokenAndGitkitUser

import com.google.identitytoolkit.IdToken; //导入依赖的package包/类
public void saveIdTokenAndGitkitUser(IdToken idToken, GitkitUser user) {
    mPrefs.edit()
            .putString(ID_TOKEN_KEY, idToken.getTokenString())
            .putString(GITKIT_USER_KEY, user.toString())
            .apply();
}
 
开发者ID:googlearchive,项目名称:Abelana-Android,代码行数:7,代码来源:UserInfoStore.java

示例6: onCreate

import com.google.identitytoolkit.IdToken; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mUserInfoStore = new UserInfoStore(this);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) actionBar.hide();

    // Step 1: Create a GitkitClient.
    // The configurations are set in the AndroidManifest.xml. You can also set or overwrite them
    // by calling the corresponding setters on the GitkitClient builder.
    //

    mGitkitClient = GitkitClient.newBuilder(this, new GitkitClient.SignInCallbacks() {
        // Implement the onSignIn method of GitkitClient.SignInCallbacks interface.
        // This method is called when the sign-in process succeeds. A Gitkit IdToken and the signed
        // in account information are passed to the callback.
        @Override
        public void onSignIn(IdToken idToken, GitkitUser user) {
            mUserInfoStore.saveIdTokenAndGitkitUser(idToken, user);
            showProfilePage(idToken, user);
        }

        // Implement the onSignInFailed method of GitkitClient.SignInCallbacks interface.
        // This method is called when the sign-in process fails.
        @Override
        public void onSignInFailed() {
            Toast.makeText(LoginActivity.this, "Sign in failed", Toast.LENGTH_LONG).show();
        }
    }).build();


    // Step 2: Check if there is an already signed in user.
    // If there is an already signed in user, show the ic_profile page and welcome message.
    // Otherwise, show a sign in button.
    //
    if (mUserInfoStore.isUserLoggedIn()) {
        showProfilePage(mUserInfoStore.getSavedIdToken(), mUserInfoStore.getSavedGitkitUser());
    } else {
        showSignInPage();
    }

}
 
开发者ID:googlearchive,项目名称:Abelana-Android,代码行数:44,代码来源:LoginActivity.java


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