use of org.wso2.carbon.identity.core.handler.InitConfig in project product-iots by wso2.
the class QSGUtils method initConfig.
public static EMMQSGConfig initConfig() {
Properties props = new Properties();
InputStream input = null;
EMMQSGConfig emmConfig = null;
try {
input = new FileInputStream("config.properties");
// load a properties file and set the properties
props.load(input);
emmConfig = EMMQSGConfig.getInstance();
emmConfig.setEmmHost(props.getProperty("emm-host"));
emmConfig.setDcrEndPoint(props.getProperty("dcr-endpoint"));
emmConfig.setOauthEndPoint(props.getProperty("oauth-endpoint"));
emmConfig.setUsername(props.getProperty("username"));
emmConfig.setPassword(props.getProperty("password"));
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return emmConfig;
}
use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.
the class AbstractIdentityHandler method init.
@Override
public void init(InitConfig initConfig) {
this.initConfig = initConfig;
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(AbstractIdentityHandler.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!!");
}
}
}
}
use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.
the class AbstractIdentityMessageHandler method init.
public void init(InitConfig initConfig) {
this.initConfig = initConfig;
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(AbstractIdentityMessageHandler.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!!");
}
}
}
}
use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.
the class HttpIdentityRequestFactoryTest method testInitWithDuplicateEventListenerProperties.
@Test(dataProvider = "initConfigDataProvider")
public void testInitWithDuplicateEventListenerProperties(Properties eventListenerProperties, Properties expectedListenerProperties) throws Exception {
Util.mockReturnEventListenerConfigWithProperties(eventListenerProperties);
httpIdentityRequestFactory.init(new InitConfig());
Util.assertPropertiesEqual(httpIdentityRequestFactory.properties, expectedListenerProperties);
}
use of org.wso2.carbon.identity.core.handler.InitConfig in project carbon-identity-framework by wso2.
the class HttpIdentityRequestFactoryTest method testInit.
@Test
public void testInit() throws Exception {
// Mock returning a null after reading event listener configs
Util.mockReturnNullEventListenerConfig();
InitConfig initConfig = new InitConfig();
httpIdentityRequestFactory.init(initConfig);
assertEquals(httpIdentityRequestFactory.properties.size(), 0);
}
Aggregations