Search in sources :

Example 16 with SSOToken

use of org.simbasecurity.api.service.thrift.SSOToken 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)

Example 17 with SSOToken

use of org.simbasecurity.api.service.thrift.SSOToken in project simba-os by cegeka.

the class AuthenticationFilterServiceImpl method getCurrentSession.

Session getCurrentSession(RequestData requestData) {
    SSOToken ssoToken;
    if (requestData.isSsoTokenMappingKeyProvided()) {
        String ssoTokenKey = requestData.getRequestParameters().get(SIMBA_SSO_TOKEN);
        ssoToken = ssoTokenMappingService.getSSOToken(ssoTokenKey);
        if (ssoToken != null) {
            ssoTokenMappingService.destroyMapping(ssoTokenKey);
        }
    } else {
        ssoToken = requestData.getSsoToken();
    }
    return sessionService.getSession(ssoToken);
}
Also used : SSOToken(org.simbasecurity.api.service.thrift.SSOToken)

Example 18 with SSOToken

use of org.simbasecurity.api.service.thrift.SSOToken in project simba-os by cegeka.

the class AuthenticationFilterServiceImplTest method testGetCurrentSession_NoTokenMappingProvided.

@Test
public void testGetCurrentSession_NoTokenMappingProvided() {
    SSOToken ssoToken = mock(SSOToken.class);
    RequestData requestData = new RequestData(null, null, null, null, ssoToken, null, false, false, false, false, false, null, null, null, null);
    serviceImpl.getCurrentSession(requestData);
    verify(sessionServiceMock).getSession(same(ssoToken));
}
Also used : SSOToken(org.simbasecurity.api.service.thrift.SSOToken) RequestData(org.simbasecurity.api.service.thrift.RequestData) Test(org.junit.Test)

Example 19 with SSOToken

use of org.simbasecurity.api.service.thrift.SSOToken in project simba-os by cegeka.

the class DatabaseAuditLogProviderTest method auditEventIsPersisted_digestEnabled.

@Test
public void auditEventIsPersisted_digestEnabled() {
    when(configurationServiceMock.getValue(SimbaConfigurationParameter.AUDIT_LOG_INTEGRITY_ENABLED)).thenReturn(Boolean.TRUE);
    SSOToken ssoToken = new SSOToken();
    AuditLogEvent event = new AuditLogEvent(AuditLogEventCategory.SESSION, "username", ssoToken, "remoteIP", "message", "userAgent", "hostServerName", "surname", "firstname", "requestURL", "CHAINID");
    provider.log(event);
    jdbcTemplate.query("SELECT * FROM SIMBA_AUDIT_LOG WHERE ssoToken=?", getRowMapper(false), ssoToken.getToken());
}
Also used : AuditLogEvent(org.simbasecurity.core.audit.AuditLogEvent) SSOToken(org.simbasecurity.api.service.thrift.SSOToken) Test(org.junit.Test)

Aggregations

SSOToken (org.simbasecurity.api.service.thrift.SSOToken)19 Test (org.junit.Test)14 RequestData (org.simbasecurity.api.service.thrift.RequestData)7 ActionDescriptor (org.simbasecurity.api.service.thrift.ActionDescriptor)5 THttpClient (org.apache.thrift.transport.THttpClient)4 Client (org.simbasecurity.api.service.thrift.AuthenticationFilterService.Client)4 AuditLogEvent (org.simbasecurity.core.audit.AuditLogEvent)4 Session (org.simbasecurity.core.domain.Session)4 SimbaCredentials (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials)4 ActionDescriptorBuilderForTests (org.simbasecurity.dwclient.test.stub.simba.ActionDescriptorBuilderForTests)4 User (org.simbasecurity.core.domain.User)3 State (org.simbasecurity.core.chain.Command.State)2 SessionEntity (org.simbasecurity.core.domain.SessionEntity)2 SimbaPrincipal (org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal)2 ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)1 Cookie (javax.servlet.http.Cookie)1 ActionType (org.simbasecurity.api.service.thrift.ActionType)1 TSession (org.simbasecurity.api.service.thrift.TSession)1 TUser (org.simbasecurity.api.service.thrift.TUser)1 LoginMapping (org.simbasecurity.core.domain.LoginMapping)1