/** * This is an advanced constructor that can be used when implementing an authentication flow that * differs from the default oauth 2 flow. * * @param context current context. * @param authInfo authentication information that should be used. (Must at the minimum provide an * access token). * @param refreshProvider the refresh provider to use when the access token expires and needs to * be refreshed. */ public BoxSession( Context context, BoxAuthentication.BoxAuthenticationInfo authInfo, BoxAuthentication.AuthenticationRefreshProvider refreshProvider) { mApplicationContext = context.getApplicationContext(); mAuthInfo = authInfo; mRefreshProvider = refreshProvider; if (authInfo.getUser() != null) { if (!SdkUtils.isBlank(authInfo.getUser().getId())) { mUserId = authInfo.getUser().getId(); } } }
@Override public void onAuthCreated(BoxAuthentication.BoxAuthenticationInfo info) { BoxAuthentication.BoxAuthenticationInfo.cloneInfo(mSession.mAuthInfo, info); mSession.setUserId(info.getUser().getId()); mSession.onAuthCreated(info); authLatch.countDown(); }
private boolean sameUser(BoxAuthentication.BoxAuthenticationInfo info) { return info != null && info.getUser() != null && getUserId() != null && getUserId().equals(info.getUser().getId()); }
/** * @return the user associated with this session. May return null if this is a new session before * authentication. */ public BoxUser getUser() { return mAuthInfo.getUser(); }