use of org.wso2.carbon.identity.entitlement.thrift.ThriftEntitlementServiceImpl in project carbon-identity-framework by wso2.
the class EntitlementServiceComponent method startThriftEntitlementService.
private void startThriftEntitlementService() throws Exception {
try {
// read identity.xml
IdentityUtil.populateProperties();
// if thrift based EntitlementService is enabled.
String thriftEnabled = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_ENABLE_THRIFT_SERVICE);
if (thriftEnabled != null && Boolean.parseBoolean(thriftEnabled)) {
TSSLTransportFactory.TSSLTransportParameters transportParam = new TSSLTransportFactory.TSSLTransportParameters();
// read the keystore and password used for ssl communication from config
String keystorePath = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_KEYSTORE_LOCATION);
String keystorePassword = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_KEYSTORE_PASSWORD);
// set it in parameters
transportParam.setKeyStore(keystorePath, keystorePassword);
// int receivePort = 10395;
int receivePort = readThriftReceivePort();
// int clientTimeOut = 10000;
int clientTimeOut = Integer.parseInt(IdentityUtil.getProperty(ThriftConfigConstants.PARAM_CLIENT_TIMEOUT));
// String ifAddress = "localhost";
TServerSocket serverTransport = TSSLTransportFactory.getServerSocket(receivePort, clientTimeOut, getHostAddress(readThriftHostName()), transportParam);
EntitlementService.Processor processor = new EntitlementService.Processor(new ThriftEntitlementServiceImpl());
// TODO: have to decide on the protocol.
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args())
/*
TServer server = new TThreadPoolServer(processor, serverTransport,
new TCompactProtocol.Factory());*/
Runnable serverThread = new ServerRunnable(server);
executor.submit(serverThread);
if (log.isDebugEnabled()) {
log.debug("Started thrift entitlement service at port:" + receivePort);
}
}
} catch (TTransportException e) {
String transportErrorMsg = "Error in initializing thrift transport";
log.error(transportErrorMsg, e);
throw new Exception(transportErrorMsg);
} catch (UnknownHostException e) {
String hostErrorMsg = "Error in obtaining host name";
log.error(hostErrorMsg, e);
throw new Exception(hostErrorMsg);
}
}
Aggregations