Search in sources :

Example 1 with SessionEntity

use of org.simbasecurity.core.domain.SessionEntity in project simba-os by cegeka.

the class SessionDatabaseRepositoryTest method canFindBySSOToken.

@Test
public void canFindBySSOToken() throws Exception {
    User user = UserTestBuilder.aDefaultUser().build();
    SSOToken ssoToken = new SSOToken("eenSsoTokentje");
    SessionEntity session = new SessionEntity(user, ssoToken, "127.0.0.1", "192.168.1.1");
    persistAndRefresh(user, session);
    assertEquals(session, sessionDatabaseRepository.findBySSOToken(ssoToken));
}
Also used : User(org.simbasecurity.core.domain.User) SSOToken(org.simbasecurity.api.service.thrift.SSOToken) SessionEntity(org.simbasecurity.core.domain.SessionEntity) Test(org.junit.Test)

Example 2 with SessionEntity

use of org.simbasecurity.core.domain.SessionEntity in project simba-os by cegeka.

the class SessionServiceImpl method createSession.

@Override
public Session createSession(String userName, String clientIpAddress, String hostServerName, String userAgent, String requestURL) {
    User user = userRepository.findByName(userName);
    SSOToken ssoToken = new SSOToken(UUID.randomUUID().toString());
    Session session = new SessionEntity(user, ssoToken, clientIpAddress, hostServerName);
    sessionRepository.persist(session);
    audit.log(auditLogEventFactory.createEventForSession(user.getUserName(), ssoToken, clientIpAddress, hostServerName, userAgent, requestURL, SESSION_CREATED));
    return session;
}
Also used : TUser(org.simbasecurity.api.service.thrift.TUser) User(org.simbasecurity.core.domain.User) SSOToken(org.simbasecurity.api.service.thrift.SSOToken) SessionEntity(org.simbasecurity.core.domain.SessionEntity) Session(org.simbasecurity.core.domain.Session) TSession(org.simbasecurity.api.service.thrift.TSession)

Aggregations

SSOToken (org.simbasecurity.api.service.thrift.SSOToken)2 SessionEntity (org.simbasecurity.core.domain.SessionEntity)2 User (org.simbasecurity.core.domain.User)2 Test (org.junit.Test)1 TSession (org.simbasecurity.api.service.thrift.TSession)1 TUser (org.simbasecurity.api.service.thrift.TUser)1 Session (org.simbasecurity.core.domain.Session)1