Search in sources :

Example 1 with InitConfig

use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.

the class HttpIdentityRequestFactory method init.

public void init(InitConfig initConfig) {
    this.initConfig = initConfig;
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(HttpIdentityRequestFactory.class.getName(), this.getClass().getName());
    if (identityEventListenerConfig == null) {
        return;
    }
    if (identityEventListenerConfig.getProperties() != null) {
        for (Map.Entry<Object, Object> property : identityEventListenerConfig.getProperties().entrySet()) {
            String key = (String) property.getKey();
            String value = (String) property.getValue();
            if (!properties.containsKey(key)) {
                properties.setProperty(key, value);
            } else {
                log.warn("Property key " + key + " already exists. Cannot add property!!");
            }
        }
    }
}
Also used : IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with InitConfig

use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.

the class HttpIdentityResponseFactory method init.

public void init(InitConfig initConfig) {
    this.initConfig = initConfig;
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(HttpIdentityResponseFactory.class.getName(), this.getClass().getName());
    if (identityEventListenerConfig == null) {
        return;
    }
    if (identityEventListenerConfig.getProperties() != null) {
        for (Map.Entry<Object, Object> property : identityEventListenerConfig.getProperties().entrySet()) {
            String key = (String) property.getKey();
            String value = (String) property.getValue();
            if (!properties.containsKey(key)) {
                properties.setProperty(key, value);
            } else {
                log.warn("Property key " + key + " already exists. Cannot add property!!");
            }
        }
    }
}
Also used : IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig) Map(java.util.Map)

Example 3 with InitConfig

use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.

the class IdentityProcessor method init.

/**
 * Initialize IdentityProcessor
 *
 * @param initConfig IdentityProcessor properties
 */
public void init(InitConfig initConfig) {
    if (initConfig != null) {
        this.initConfig = initConfig;
    }
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(IdentityProcessor.class.getName(), this.getClass().getName());
    if (identityEventListenerConfig == null) {
        return;
    }
    if (identityEventListenerConfig.getProperties() != null) {
        for (Map.Entry<Object, Object> property : identityEventListenerConfig.getProperties().entrySet()) {
            String key = (String) property.getKey();
            String value = (String) property.getValue();
            if (!properties.containsKey(key)) {
                properties.setProperty(key, value);
            } else {
                log.warn("Property key " + key + " already exists. Cannot add property!!");
            }
        }
    }
}
Also used : IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with InitConfig

use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.

the class AbstractEventHandlerTest method testInitException.

@Test(expectedExceptions = { IdentityRuntimeException.class })
public void testInitException() {
    InitConfig configuration = new InitConfig();
    TestEventHandler testEventHandler = new TestEventHandler();
    testEventHandler.init(configuration);
    Assert.assertEquals(testEventHandler.configs, configuration);
}
Also used : InitConfig(org.wso2.carbon.identity.core.handler.InitConfig) Test(org.testng.annotations.Test) IdentityBaseTest(org.wso2.carbon.identity.testutil.IdentityBaseTest)

Example 5 with InitConfig

use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.

the class HttpIdentityResponseFactoryTest method testInit.

@Test
public void testInit() throws Exception {
    // Mock returning a null after reading event listener configs
    Util.mockReturnNullEventListenerConfig();
    InitConfig initConfig = new InitConfig();
    httpIdentityResponseFactory.init(initConfig);
    assertEquals(httpIdentityResponseFactory.properties.size(), 0);
}
Also used : InitConfig(org.wso2.carbon.identity.core.handler.InitConfig) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Test (org.testng.annotations.Test)6 InitConfig (org.wso2.carbon.identity.core.handler.InitConfig)6 Map (java.util.Map)5 IdentityEventListenerConfig (org.wso2.carbon.identity.core.model.IdentityEventListenerConfig)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 HashMap (java.util.HashMap)2 IdentityBaseTest (org.wso2.carbon.identity.testutil.IdentityBaseTest)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 ModuleConfiguration (org.wso2.carbon.identity.event.bean.ModuleConfiguration)1 EMMQSGConfig (org.wso2.mdm.qsg.dto.EMMQSGConfig)1