@Test public void testAuthenticate() throws Exception { credentialStore.authenticate(accessToken, refreshToken, expiresIn, acquisitionTime); assertEquals(credentialStore.getAuthStatus(), CredentialStore.AUTHENTICATED); try { credentialStore.authenticate("", refreshToken, expiresIn, acquisitionTime); assertTrue(false); } catch (Exception ignored) { } }
synchronized void authenticate(@NonNull String accessToken, @NonNull String refreshToken, int expiresIn, @NonNull Date tokenAcquisitionTime) { if(accessToken.length() == 0 || refreshToken.length() == 0) throw new IllegalArgumentException("accessToken.isEmpty() || refreshToken.isEmpty()"); this.accessToken = accessToken; this.refreshToken = refreshToken; this.expiresIn = expiresIn; this.tokenAcquisitionTime = tokenAcquisitionTime; authStatus = AUTHENTICATED; persister.persistUser(this); }
CredentialStore { synchronized void authenticate(@NonNull String accessToken, @NonNull String refreshToken, int expiresIn, @NonNull Date tokenAcquisitionTime) { if(accessToken.length() == 0 || refreshToken.length() == 0) throw new IllegalArgumentException("accessToken.isEmpty() || refreshToken.isEmpty()"); this.accessToken = accessToken; this.refreshToken = refreshToken; this.expiresIn = expiresIn; this.tokenAcquisitionTime = tokenAcquisitionTime; authStatus = AUTHENTICATED; persister.persistUser(this); } }
CredentialStore { synchronized void authenticate(@NonNull String accessToken, @NonNull String refreshToken, int expiresIn, @NonNull Date tokenAcquisitionTime) { if(accessToken.length() == 0 || refreshToken.length() == 0) throw new IllegalArgumentException("accessToken.isEmpty() || refreshToken.isEmpty()"); this.accessToken = accessToken; this.refreshToken = refreshToken; this.expiresIn = expiresIn; this.tokenAcquisitionTime = tokenAcquisitionTime; authStatus = AUTHENTICATED; persister.persistUser(this); } CredentialStore(CredentialPersister persister); }
CredentialStore { synchronized void authenticate(@NonNull String accessToken, @NonNull String refreshToken, int expiresIn, @NonNull Date tokenAcquisitionTime) { if(accessToken.length() == 0 || refreshToken.length() == 0) throw new IllegalArgumentException("accessToken.isEmpty() || refreshToken.isEmpty()"); this.accessToken = accessToken; this.refreshToken = refreshToken; this.expiresIn = expiresIn; this.tokenAcquisitionTime = tokenAcquisitionTime; authStatus = AUTHENTICATED; persister.persistUser(this); } CredentialStore(CredentialPersister persister); void init(String accessToken, String refreshToken, int expiresIn, Date tokenAcquisitionTime, @AuthStatus int authStatus); String getAccessToken(); String getRefreshToken(); int getExpiresIn(); Date getTokenAcquisitionTime(); }
CredentialStore { synchronized void authenticate(@NonNull String accessToken, @NonNull String refreshToken, int expiresIn, @NonNull Date tokenAcquisitionTime) { if(accessToken.length() == 0 || refreshToken.length() == 0) throw new IllegalArgumentException("accessToken.isEmpty() || refreshToken.isEmpty()"); this.accessToken = accessToken; this.refreshToken = refreshToken; this.expiresIn = expiresIn; this.tokenAcquisitionTime = tokenAcquisitionTime; authStatus = AUTHENTICATED; persister.persistUser(this); } CredentialStore(CredentialPersister persister); void init(String accessToken, String refreshToken, int expiresIn, Date tokenAcquisitionTime, @AuthStatus int authStatus); String getAccessToken(); String getRefreshToken(); int getExpiresIn(); Date getTokenAcquisitionTime(); final static int NOT_AUTHENTICATED; final static int TOKEN_EXPIRED; final static int AUTHENTICATED; }