use of org.activityinfo.server.database.hibernate.entity.Authentication 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.server.database.hibernate.entity.Authentication in project activityinfo by bedatadriven.
the class HostViewTest method templateProcesses.
@Test
public void templateProcesses() {
User user = new User();
user.setName("Alex");
user.setEmail("akbertram@gmail.com");
user.setLocale("fr");
Authentication auth = new Authentication(user);
auth.setId("XYZ12345");
auth.setUser(user);
HostPageModel pageModel = new HostPageModel("http://www.activityinfo.org");
pageModel.setBootstrapScript("/ActivityInfo/en.js");
assertProcessable(pageModel);
}
use of org.activityinfo.server.database.hibernate.entity.Authentication in project activityinfo by bedatadriven.
the class AuthTokenProvider method createNewAuthToken.
@Transactional
public Authentication createNewAuthToken(User user) {
Authentication auth = new Authentication(user);
authDAO.get().persist(auth);
return auth;
}
use of org.activityinfo.server.database.hibernate.entity.Authentication in project activityinfo by bedatadriven.
the class AuthTokenProvider method createNewAuthCookies.
public NewCookie[] createNewAuthCookies(User user) {
Authentication token = createNewAuthToken(user);
NewCookie cookie = newAuthCookie(AuthenticatedUser.AUTH_TOKEN_COOKIE, token.getId());
NewCookie userCookie = newAuthCookie(AuthenticatedUser.USER_ID_COOKIE, Integer.toString(token.getUser().getId()));
NewCookie emailCookie = newAuthCookie(AuthenticatedUser.EMAIL_COOKIE, user.getEmail());
return new NewCookie[] { cookie, userCookie, emailCookie };
}
use of org.activityinfo.server.database.hibernate.entity.Authentication in project activityinfo by bedatadriven.
the class BasicAuthentication method tryAuthenticate.
public Authentication tryAuthenticate(String authorizationHeader) {
User user;
try {
user = doAuthentication(authorizationHeader);
} catch (IOException e) {
return null;
}
Authentication auth = new Authentication(user);
auth.setId("");
return auth;
}
Aggregations