Search in sources :

Example 1 with Authentication

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;
}
Also used : Authentication(org.activityinfo.server.database.hibernate.entity.Authentication) AuthenticatedUser(org.activityinfo.legacy.shared.AuthenticatedUser)

Example 2 with Authentication

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);
}
Also used : User(org.activityinfo.server.database.hibernate.entity.User) Authentication(org.activityinfo.server.database.hibernate.entity.Authentication) HostPageModel(org.activityinfo.server.login.model.HostPageModel) Test(org.junit.Test)

Example 3 with Authentication

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;
}
Also used : Authentication(org.activityinfo.server.database.hibernate.entity.Authentication) Transactional(org.activityinfo.server.database.hibernate.dao.Transactional)

Example 4 with Authentication

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 };
}
Also used : Authentication(org.activityinfo.server.database.hibernate.entity.Authentication) NewCookie(javax.ws.rs.core.NewCookie)

Example 5 with Authentication

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;
}
Also used : User(org.activityinfo.server.database.hibernate.entity.User) AuthenticatedUser(org.activityinfo.legacy.shared.AuthenticatedUser) Authentication(org.activityinfo.server.database.hibernate.entity.Authentication) IOException(java.io.IOException)

Aggregations

Authentication (org.activityinfo.server.database.hibernate.entity.Authentication)5 AuthenticatedUser (org.activityinfo.legacy.shared.AuthenticatedUser)2 User (org.activityinfo.server.database.hibernate.entity.User)2 IOException (java.io.IOException)1 NewCookie (javax.ws.rs.core.NewCookie)1 Transactional (org.activityinfo.server.database.hibernate.dao.Transactional)1 HostPageModel (org.activityinfo.server.login.model.HostPageModel)1 Test (org.junit.Test)1