use of org.wso2.siddhi.query.api.execution.query.input.stream.InputStream in project carbon-business-process by wso2.
the class HumanTaskServerConfiguration method getAuthenticationConfig.
private void getAuthenticationConfig(File file, TRegServiceAuth authentication) {
// Since secretResolver only accept Element we have to build Element here.
SecretResolver secretResolver = null;
InputStream in = null;
try {
in = new FileInputStream(file);
StAXOMBuilder builder = new StAXOMBuilder(in);
secretResolver = SecretResolverFactory.create(builder.getDocumentElement(), true);
} catch (Exception e) {
log.warn("Error occurred while retrieving secured TaskEngineProtocolHandler configuration.", e);
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
}
// Get Username
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(HumanTaskConstants.B4P_REGISTRATIONS_USERNAME_ALIAS)) {
this.registrationServiceAuthUsername = secretResolver.resolve(HumanTaskConstants.B4P_REGISTRATIONS_USERNAME_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded Registration service admin username from secure vault");
}
} else {
if (authentication.getUsername() != null) {
this.registrationServiceAuthUsername = authentication.getUsername();
}
}
// Get Password
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(HumanTaskConstants.B4P_REGISTRATIONS_PASSWORD_ALIAS)) {
this.registrationServiceAuthPassword = secretResolver.resolve(HumanTaskConstants.B4P_REGISTRATIONS_PASSWORD_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded Registration service admin password from secure vault");
}
} else {
if (authentication.getPassword() != null) {
this.registrationServiceAuthPassword = authentication.getPassword();
}
}
}
use of org.wso2.siddhi.query.api.execution.query.input.stream.InputStream in project carbon-business-process by wso2.
the class ArchiveBasedHumanTaskDeploymentUnitBuilder method readInTheWSDLFile.
/**
* Read the WSDL file given the input stream for the WSDL source
*
* @param in WSDL input stream
* @param entryName ZIP file entry name
* @param fromRegistry whether the wsdl is read from registry
* @return WSDL Definition
* @throws javax.wsdl.WSDLException at parser error
*/
public static Definition readInTheWSDLFile(InputStream in, String entryName, boolean fromRegistry) throws WSDLException {
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
// switch off the verbose mode for all usecases
reader.setFeature(HumanTaskConstants.JAVAX_WSDL_VERBOSE_MODE_KEY, false);
reader.setFeature("javax.wsdl.importDocuments", true);
Definition def;
Document doc;
try {
doc = XMLUtils.newDocument(in);
} catch (ParserConfigurationException e) {
throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Error", e);
} catch (SAXException e) {
throw new WSDLException(WSDLException.PARSER_ERROR, "Parser SAX Error", e);
} catch (IOException e) {
throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
}
// Log when and from where the WSDL is loaded.
if (log.isDebugEnabled()) {
log.debug("Reading 1.1 WSDL with base uri = " + entryName);
log.debug(" the document base uri = " + entryName);
}
if (fromRegistry) {
throw new UnsupportedOperationException("This operation is not currently " + "supported in this version of WSO2 BPS.");
} else {
def = reader.readWSDL(entryName, doc.getDocumentElement());
}
def.setDocumentBaseURI(entryName);
return def;
}
use of org.wso2.siddhi.query.api.execution.query.input.stream.InputStream in project product-iots by wso2.
the class CarbonServerManagerExtension method startServerUsingCarbonHome.
public synchronized void startServerUsingCarbonHome(String carbonHome, Map<String, String> commandMap) throws AutomationFrameworkException {
if (this.process == null) {
this.portOffset = this.checkPortAvailability(commandMap);
Process tempProcess = null;
try {
if (!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) {
System.setProperty("carbon.home", carbonHome);
}
File commandDir = new File(carbonHome);
log.info("Starting carbon server............. ");
String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);
String[] parameters = this.expandServerStartupCommandList(commandMap);
String[] cmdArray;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
commandDir = new File(carbonHome + File.separator + "bin");
cmdArray = new String[] { "cmd.exe", "/c", scriptName + ".bat" };
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, commandDir);
} else {
cmdArray = new String[] { "sh", "bin/" + scriptName + ".sh" };
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, commandDir);
}
this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream());
this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream());
this.inputStreamHandler.start();
this.errorStreamHandler.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
CarbonServerManagerExtension.this.serverShutdown(CarbonServerManagerExtension.this.portOffset);
} catch (Exception var2) {
CarbonServerManagerExtension.log.error("Error while server shutdown ..", var2);
}
}
});
ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, DEFAULT_START_STOP_WAIT_MS, false, (String) this.automationContext.getInstance().getHosts().get("default"));
long time = System.currentTimeMillis() + 60000L;
// while(true) {
// if(this.inputStreamHandler.getOutput().contains("Mgt Console URL") || System.currentTimeMillis() >= time) {
// int httpsPort = defaultHttpsPort + this.portOffset;
// String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
// User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
// ClientConnectionUtil.waitForLogin(backendURL, superUser);
// log.info("Server started successfully.");
// break;
// }
// }
int httpsPort = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.waitForLogin(backendURL, superUser);
} catch (XPathExpressionException | IOException var13) {
throw new IllegalStateException("Unable to start server", var13);
}
this.process = tempProcess;
}
}
use of org.wso2.siddhi.query.api.execution.query.input.stream.InputStream 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.siddhi.query.api.execution.query.input.stream.InputStream in project identity-test-integration by wso2-incubator.
the class SampleContextEventListener method contextInitialized.
public void contextInitialized(ServletContextEvent servletContextEvent) {
properties = new Properties();
try {
if (servletContextEvent.getServletContext().getContextPath().contains("travelocity.com")) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/travelocity.properties"));
} else if (servletContextEvent.getServletContext().getContextPath().contains("avis.com")) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/avis.properties"));
} else {
String resourcePath = "/WEB-INF/classes" + servletContextEvent.getServletContext().getContextPath() + ".properties";
InputStream resourceStream = servletContextEvent.getServletContext().getResourceAsStream(resourcePath);
if (resourceStream != null) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream(resourcePath));
}
}
InputStream keyStoreInputStream = servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/wso2carbon.jks");
SSOAgentX509Credential credential = new SSOAgentX509KeyStoreCredential(keyStoreInputStream, properties.getProperty("KeyStorePassword").toCharArray(), properties.getProperty("IdPPublicCertAlias"), properties.getProperty("PrivateKeyAlias"), properties.getProperty("PrivateKeyPassword").toCharArray());
SSOAgentConfig config = new SSOAgentConfig();
config.initConfig(properties);
config.getSAML2().setSSOAgentX509Credential(credential);
config.getOpenId().setAttributesRequestor(new SampleAttributesRequestor());
servletContextEvent.getServletContext().setAttribute(SSOAgentConstants.CONFIG_BEAN_NAME, config);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
} catch (SSOAgentException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
Aggregations