use of org.activityinfo.shared.auth.AuthenticatedUser in project activityinfo by bedatadriven.
the class ClientSideAuthProvider method persistAuthentication.
/**
* unless the user requests to stay logged in, the authToken is set to expire at the end of the user's session,
* which means that it won't be available if the user opens the app via the appcache later on. Since
* BootstrapScriptServlet relies on the token to select the appropriate locale, without the cookie set, trying to
* retrieve the latest manifest will fail
*/
public static void persistAuthentication() {
AuthenticatedUser user = new ClientSideAuthProvider().get();
Cookies.setCookie(AuthenticatedUser.AUTH_TOKEN_COOKIE, user.getAuthToken(), oneYearLater());
Cookies.setCookie(AuthenticatedUser.USER_ID_COOKIE, Integer.toString(user.getUserId()), oneYearLater());
Cookies.setCookie(AuthenticatedUser.EMAIL_COOKIE, user.getEmail(), oneYearLater());
}
use of org.activityinfo.shared.auth.AuthenticatedUser in project activityinfo by bedatadriven.
the class BasicAuthentication method doAuthentication.
public User doAuthentication(String auth) throws IOException {
User user = authenticate(auth);
if (user == null) {
return null;
}
authProvider.set(new AuthenticatedUser("", user.getId(), user.getEmail()));
return user;
}
use of org.activityinfo.shared.auth.AuthenticatedUser in project activityinfo by bedatadriven.
the class AuthenticationFilter method queryAuthToken.
private AuthenticatedUser queryAuthToken(String authToken) {
Authentication entity = entityManager.get().find(Authentication.class, authToken);
if (entity == null) {
// try as basic authentication
entity = basicAuthenticator.tryAuthenticate(authToken);
}
if (entity == null) {
throw new IllegalArgumentException();
}
AuthenticatedUser authenticatedUser = new AuthenticatedUser(authToken, entity.getUser().getId(), entity.getUser().getEmail());
authenticatedUser.setUserLocale(entity.getUser().getLocale());
return authenticatedUser;
}
use of org.activityinfo.shared.auth.AuthenticatedUser in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method setUp.
@Before
public void setUp() {
service = createMock("remoteService", RemoteCommandServiceAsync.class);
proxy = createMock("proxy", CommandCache.class);
AuthenticatedUser auth = new AuthenticatedUser(AUTH_TOKEN, 1, "alex@alex.com");
dispatcher = new CachingDispatcher(proxyManager, new MergingDispatcher(new RemoteDispatcher(new MockEventBus(), auth, service), scheduler));
}
use of org.activityinfo.shared.auth.AuthenticatedUser in project activityinfo by bedatadriven.
the class UserProfilePage method bindProfile.
private void bindProfile() {
userProfile = new UserProfileDTO();
AuthenticatedUser user = new ClientSideAuthProvider().get();
dispatcher.execute(new GetUserProfile(user.getUserId()), new AsyncCallback<UserProfileDTO>() {
@Override
public void onFailure(Throwable caught) {
Log.error("error binding profile", caught);
MessageBox.alert(I18N.CONSTANTS.serverError(), caught.getMessage(), null);
}
@Override
public void onSuccess(UserProfileDTO userProfileDTO) {
userProfile = userProfileDTO;
binding.bind(userProfile);
UserProfilePage.this.show();
}
});
}
Aggregations