Search in sources :

Example 16 with Session

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

the class AuthenticationFilterServiceImpl method processRequest.

@Transactional
public ActionDescriptor processRequest(RequestData requestData, String chainCommand) throws TException {
    return simbaExceptionHandlingCaller.call(() -> {
        if (requestData == null) {
            throw new IllegalArgumentException("Parameter 'requestData' can not be null");
        }
        if (chainCommand == null) {
            throw new IllegalArgumentException("Parameter 'chainCommand' can not be null");
        }
        Command chain = locateCommandChain(chainCommand);
        Session currentSession = getCurrentSession(requestData);
        ChainContext chainContext = createChainContext(requestData, currentSession);
        try {
            chain.execute(chainContext);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return chainContext.getActionDescriptor();
    });
}
Also used : ChainContext(org.simbasecurity.core.chain.ChainContext) Command(org.simbasecurity.core.chain.Command) TException(org.apache.thrift.TException) Session(org.simbasecurity.core.domain.Session) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with Session

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

the class AuthenticationFilterServiceImplTest method testProcessRequest.

@Test
public void testProcessRequest() throws Exception {
    Session sessionMock = mock(Session.class);
    when(sessionServiceMock.getSession(any(SSOToken.class))).thenReturn(sessionMock);
    ChainImpl authenticationChainMock = mock(ChainImpl.class);
    when(applicationContext.getBean("authenticationChain")).thenReturn(authenticationChainMock);
    serviceImpl.processRequest(new RequestData(null, null, null, null, null, null, false, false, false, false, false, null, null, "loginToken", null), "authenticationChain");
    verify(authenticationChainMock).execute(any(ChainContext.class));
}
Also used : SSOToken(org.simbasecurity.api.service.thrift.SSOToken) ChainContext(org.simbasecurity.core.chain.ChainContext) RequestData(org.simbasecurity.api.service.thrift.RequestData) ChainImpl(org.simbasecurity.core.chain.ChainImpl) Session(org.simbasecurity.core.domain.Session) Test(org.junit.Test)

Aggregations

Session (org.simbasecurity.core.domain.Session)17 Test (org.junit.Test)7 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)5 User (org.simbasecurity.core.domain.User)4 TSession (org.simbasecurity.api.service.thrift.TSession)2 AuditLogEvent (org.simbasecurity.core.audit.AuditLogEvent)2 ChainContext (org.simbasecurity.core.chain.ChainContext)2 State (org.simbasecurity.core.chain.Command.State)2 Query (javax.persistence.Query)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 TException (org.apache.thrift.TException)1 Before (org.junit.Before)1 RequestData (org.simbasecurity.api.service.thrift.RequestData)1 TUser (org.simbasecurity.api.service.thrift.TUser)1 ChainImpl (org.simbasecurity.core.chain.ChainImpl)1 Command (org.simbasecurity.core.chain.Command)1 LoginMapping (org.simbasecurity.core.domain.LoginMapping)1 SSOTokenMapping (org.simbasecurity.core.domain.SSOTokenMapping)1 SessionEntity (org.simbasecurity.core.domain.SessionEntity)1 SimbaException (org.simbasecurity.core.exception.SimbaException)1