Search in sources :

Example 1 with IdentityEventServiceImpl

use of org.wso2.carbon.identity.event.services.IdentityEventServiceImpl in project carbon-identity-framework by wso2.

the class IdentityEventServiceComponent method activate.

@Activate
protected void activate(ComponentContext context) {
    try {
        IdentityEventServiceDataHolder.getInstance().setEventMgtService(new IdentityEventServiceImpl(eventHandlerList, Integer.parseInt(IdentityEventConfigBuilder.getInstance().getThreadPoolSize())));
        context.getBundleContext().registerService(IdentityEventService.class.getName(), IdentityEventServiceDataHolder.getInstance().getEventMgtService(), null);
    } catch (IdentityEventException e) {
        log.error("Error while initiating IdentityMgtService.");
    }
    if (log.isDebugEnabled()) {
        log.debug("Identity Management Listener is enabled");
    }
}
Also used : IdentityEventServiceImpl(org.wso2.carbon.identity.event.services.IdentityEventServiceImpl) IdentityEventException(org.wso2.carbon.identity.event.IdentityEventException) IdentityEventService(org.wso2.carbon.identity.event.services.IdentityEventService) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with IdentityEventServiceImpl

use of org.wso2.carbon.identity.event.services.IdentityEventServiceImpl in project carbon-identity-framework by wso2.

the class FrameworkUtilsTest method testGetSessionContextFromCacheExpiredSession.

@Test
public void testGetSessionContextFromCacheExpiredSession() throws FrameworkException {
    cacheEntry.setContext(context);
    setMockedSessionContextCache();
    when(mockedSessionContextCache.getValueFromCache(cacheKey)).thenReturn(cacheEntry);
    when(mockedSessionContextCache.isSessionExpired(any(SessionContextCacheKey.class), any(SessionContextCacheEntry.class))).thenReturn(true);
    IdentityEventService identityEventService = new IdentityEventServiceImpl(Collections.EMPTY_LIST, 1);
    FrameworkServiceDataHolder.getInstance().setIdentityEventService(identityEventService);
    AuthenticationContext authenticationContext = new AuthenticationContext();
    SessionContext sessionContext = FrameworkUtils.getSessionContextFromCache(request, authenticationContext, DUMMY_CACHE_KEY);
    assertNull(sessionContext);
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) IdentityEventServiceImpl(org.wso2.carbon.identity.event.services.IdentityEventServiceImpl) SessionContextCacheEntry(org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheEntry) SessionContext(org.wso2.carbon.identity.application.authentication.framework.context.SessionContext) SessionContextCacheKey(org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey) IdentityEventService(org.wso2.carbon.identity.event.services.IdentityEventService) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PowerMockIdentityBaseTest(org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)

Example 3 with IdentityEventServiceImpl

use of org.wso2.carbon.identity.event.services.IdentityEventServiceImpl in project carbon-identity-framework by wso2.

the class IdentityEventServiceImplTest method testHandleEvent.

@Test
public void testHandleEvent() throws IdentityEventException {
    Event event = new Event("eventName");
    event.addEventProperty("value", "value");
    abstractEventHandler = mock(AbstractEventHandler.class);
    doReturn(true).when(abstractEventHandler).canHandle(any(MessageContext.class));
    doReturn(true).when(abstractEventHandler).isAssociationAsync(anyString());
    List list = new ArrayList();
    list.add(abstractEventHandler);
    IdentityEventServiceComponent.eventHandlerList = list;
    List abstractEventHandlerList = new ArrayList();
    abstractEventHandlerList.add(abstractEventHandler);
    IdentityEventService identityEventService = new IdentityEventServiceImpl(abstractEventHandlerList, 1);
    identityEventService.handleEvent(event);
    Mockito.verify(abstractEventHandler).canHandle(any(MessageContext.class));
}
Also used : AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) ArrayList(java.util.ArrayList) Event(org.wso2.carbon.identity.event.event.Event) ArrayList(java.util.ArrayList) List(java.util.List) MessageContext(org.wso2.carbon.identity.core.bean.context.MessageContext) Test(org.testng.annotations.Test) IdentityBaseTest(org.wso2.carbon.identity.testutil.IdentityBaseTest)

Aggregations

Test (org.testng.annotations.Test)2 IdentityEventService (org.wso2.carbon.identity.event.services.IdentityEventService)2 IdentityEventServiceImpl (org.wso2.carbon.identity.event.services.IdentityEventServiceImpl)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Activate (org.osgi.service.component.annotations.Activate)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 BeforeTest (org.testng.annotations.BeforeTest)1 SessionContextCacheEntry (org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheEntry)1 SessionContextCacheKey (org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey)1 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)1 SessionContext (org.wso2.carbon.identity.application.authentication.framework.context.SessionContext)1 MessageContext (org.wso2.carbon.identity.core.bean.context.MessageContext)1 IdentityEventException (org.wso2.carbon.identity.event.IdentityEventException)1 Event (org.wso2.carbon.identity.event.event.Event)1 AbstractEventHandler (org.wso2.carbon.identity.event.handler.AbstractEventHandler)1 IdentityBaseTest (org.wso2.carbon.identity.testutil.IdentityBaseTest)1 PowerMockIdentityBaseTest (org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)1