use of org.wso2.siddhi.annotation.Parameter in project carbon-business-process by wso2.
the class HumanTaskServer method initTransactionManager.
// initialize the external transaction manager.
private void initTransactionManager() throws HumanTaskServerException {
String transactionFactoryName = serverConfig.getTransactionFactoryClass();
if (log.isDebugEnabled()) {
log.debug("Initializing transaction manager using " + transactionFactoryName);
}
try {
Class txFactoryClass = this.getClass().getClassLoader().loadClass(transactionFactoryName);
Object txFactory = txFactoryClass.newInstance();
tnxManager = (TransactionManager) txFactoryClass.getMethod("getTransactionManager", (Class[]) null).invoke(txFactory);
// Didn't use Debug Transaction manager which used in ODE.
// TODO: Look for the place we use this axis parameter.
// axisConfiguration.addParameter("ode.transaction.manager", transactionManager);
} catch (Exception e) {
log.fatal("Couldn't initialize a transaction manager with factory: " + transactionFactoryName, e);
throw new HumanTaskServerException("Couldn't initialize a transaction manager with factory: " + transactionFactoryName, e);
}
}
use of org.wso2.siddhi.annotation.Parameter in project ballerina by ballerina-lang.
the class HttpUtil method extractHttpsConfig.
private static void extractHttpsConfig(Annotation configInfo, Set<ListenerConfiguration> listenerConfSet) {
// Retrieve secure port from either http of ws configuration annotation.
AnnAttrValue httpsPortAttrVal;
if (configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_HTTPS_PORT) == null) {
httpsPortAttrVal = configInfo.getAnnAttrValue(WebSocketConstants.ANN_CONFIG_ATTR_WSS_PORT);
} else {
httpsPortAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_HTTPS_PORT);
}
AnnAttrValue keyStoreFileAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_KEY_STORE_FILE);
AnnAttrValue keyStorePasswordAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_KEY_STORE_PASS);
AnnAttrValue certPasswordAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_CERT_PASS);
AnnAttrValue trustStoreFileAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_TRUST_STORE_FILE);
AnnAttrValue trustStorePasswordAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_TRUST_STORE_PASS);
AnnAttrValue sslVerifyClientAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_SSL_VERIFY_CLIENT);
AnnAttrValue sslEnabledProtocolsAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_SSL_ENABLED_PROTOCOLS);
AnnAttrValue ciphersAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_CIPHERS);
AnnAttrValue sslProtocolAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_SSL_PROTOCOL);
AnnAttrValue hostAttrVal = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_HOST);
AnnAttrValue certificateValidationEnabledAttrValue = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_VALIDATE_CERT_ENABLED);
AnnAttrValue cacheSizeAttrValue = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_CACHE_SIZE);
AnnAttrValue cacheValidityPeriodAttrValue = configInfo.getAnnAttrValue(HttpConstants.ANN_CONFIG_ATTR_CACHE_VALIDITY_PERIOD);
ListenerConfiguration listenerConfiguration = new ListenerConfiguration();
if (httpsPortAttrVal != null && httpsPortAttrVal.getIntValue() > 0) {
listenerConfiguration.setPort(Math.toIntExact(httpsPortAttrVal.getIntValue()));
listenerConfiguration.setScheme(HttpConstants.PROTOCOL_HTTPS);
if (hostAttrVal != null && hostAttrVal.getStringValue() != null) {
listenerConfiguration.setHost(hostAttrVal.getStringValue());
} else {
listenerConfiguration.setHost(HttpConstants.HTTP_DEFAULT_HOST);
}
if (keyStoreFileAttrVal == null || keyStoreFileAttrVal.getStringValue() == null) {
// TODO get from language pack, and add location
throw new BallerinaConnectorException("Keystore location must be provided for secure connection");
}
if (keyStorePasswordAttrVal == null || keyStorePasswordAttrVal.getStringValue() == null) {
// TODO get from language pack, and add location
throw new BallerinaConnectorException("Keystore password value must be provided for secure connection");
}
if (certPasswordAttrVal == null || certPasswordAttrVal.getStringValue() == null) {
// TODO get from language pack, and add location
throw new BallerinaConnectorException("Certificate password value must be provided for secure connection");
}
if ((trustStoreFileAttrVal == null || trustStoreFileAttrVal.getStringValue() == null) && sslVerifyClientAttrVal != null) {
// TODO get from language pack, and add location
throw new BallerinaException("Truststore location must be provided to enable Mutual SSL");
}
if ((trustStorePasswordAttrVal == null || trustStorePasswordAttrVal.getStringValue() == null) && sslVerifyClientAttrVal != null) {
// TODO get from language pack, and add location
throw new BallerinaException("Truststore password value must be provided to enable Mutual SSL");
}
listenerConfiguration.setTLSStoreType(HttpConstants.PKCS_STORE_TYPE);
listenerConfiguration.setKeyStoreFile(keyStoreFileAttrVal.getStringValue());
listenerConfiguration.setKeyStorePass(keyStorePasswordAttrVal.getStringValue());
listenerConfiguration.setCertPass(certPasswordAttrVal.getStringValue());
if (sslVerifyClientAttrVal != null) {
listenerConfiguration.setVerifyClient(sslVerifyClientAttrVal.getStringValue());
}
if (trustStoreFileAttrVal != null) {
listenerConfiguration.setTrustStoreFile(trustStoreFileAttrVal.getStringValue());
}
if (trustStorePasswordAttrVal != null) {
listenerConfiguration.setTrustStorePass(trustStorePasswordAttrVal.getStringValue());
}
if (certificateValidationEnabledAttrValue != null && certificateValidationEnabledAttrValue.getBooleanValue()) {
listenerConfiguration.setValidateCertEnabled(certificateValidationEnabledAttrValue.getBooleanValue());
if (cacheSizeAttrValue != null) {
listenerConfiguration.setCacheSize((int) cacheSizeAttrValue.getIntValue());
}
if (cacheValidityPeriodAttrValue != null) {
listenerConfiguration.setCacheValidityPeriod((int) cacheValidityPeriodAttrValue.getIntValue());
}
}
List<Parameter> serverParams = new ArrayList<>();
Parameter serverCiphers;
if (sslEnabledProtocolsAttrVal != null && sslEnabledProtocolsAttrVal.getStringValue() != null) {
serverCiphers = new Parameter(HttpConstants.ANN_CONFIG_ATTR_SSL_ENABLED_PROTOCOLS, sslEnabledProtocolsAttrVal.getStringValue());
serverParams.add(serverCiphers);
}
if (ciphersAttrVal != null && ciphersAttrVal.getStringValue() != null) {
serverCiphers = new Parameter(HttpConstants.ANN_CONFIG_ATTR_CIPHERS, ciphersAttrVal.getStringValue());
serverParams.add(serverCiphers);
}
if (!serverParams.isEmpty()) {
listenerConfiguration.setParameters(serverParams);
}
if (sslProtocolAttrVal != null) {
listenerConfiguration.setSSLProtocol(sslProtocolAttrVal.getStringValue());
}
listenerConfiguration.setId(getListenerInterface(listenerConfiguration.getHost(), listenerConfiguration.getPort()));
listenerConfSet.add(listenerConfiguration);
}
}
use of org.wso2.siddhi.annotation.Parameter in project ballerina by ballerina-lang.
the class Forward method createOutboundRequestMsg.
protected HTTPCarbonMessage createOutboundRequestMsg(Context context) {
BStruct bConnector = (BStruct) context.getRefArgument(0);
String path = context.getStringArgument(0);
BStruct requestStruct = ((BStruct) context.getRefArgument(1));
if (requestStruct.getNativeData(HttpConstants.REQUEST) == null) {
throw new BallerinaException("invalid inbound request parameter");
}
HTTPCarbonMessage outboundRequestMsg = HttpUtil.getCarbonMsg(requestStruct, HttpUtil.createHttpCarbonMessage(true));
prepareOutboundRequest(context, bConnector, path, outboundRequestMsg);
String httpVerb = (String) outboundRequestMsg.getProperty(HttpConstants.HTTP_METHOD);
outboundRequestMsg.setProperty(HttpConstants.HTTP_METHOD, httpVerb.trim().toUpperCase(Locale.getDefault()));
Tracer tracer = TraceUtil.getParentTracer(context.getParentWorkerExecutionContext());
HttpUtil.injectHeaders(outboundRequestMsg, tracer.getProperties());
tracer.addTags(HttpUtil.extractTraceTags(outboundRequestMsg));
return outboundRequestMsg;
}
use of org.wso2.siddhi.annotation.Parameter in project ballerina by ballerina-lang.
the class SymbolEnter method defineConnectorInitFunction.
private void defineConnectorInitFunction(BLangConnector connector, SymbolEnv conEnv) {
BLangFunction initFunction = createInitFunction(connector.pos, connector.getName().getValue(), Names.INIT_FUNCTION_SUFFIX);
// Add connector as a parameter to the init function
BLangVariable param = (BLangVariable) TreeBuilder.createVariableNode();
param.pos = connector.pos;
param.setName(this.createIdentifier(Names.CONNECTOR.getValue()));
BLangUserDefinedType connectorType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
connectorType.pos = connector.pos;
connectorType.typeName = connector.name;
connectorType.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
param.setTypeNode(connectorType);
initFunction.addParameter(param);
// Add connector level variables to the init function
connector.varDefs.stream().filter(f -> f.var.expr != null).forEachOrdered(v -> initFunction.body.addStatement(createAssignmentStmt(v.var)));
addInitReturnStatement(initFunction.body);
connector.initFunction = initFunction;
BLangAction initAction = createNativeInitAction(connector.pos);
connector.initAction = initAction;
defineNode(connector.initFunction, conEnv);
defineNode(connector.initAction, conEnv);
connector.symbol.initFunctionSymbol = connector.initFunction.symbol;
}
use of org.wso2.siddhi.annotation.Parameter in project ballerina by ballerina-lang.
the class TaintAnalyzer method visitInvokable.
private void visitInvokable(BLangFunction invNode, SymbolEnv symbolEnv) {
if (invNode.symbol.taintTable == null) {
if (Symbols.isNative(invNode.symbol) || invNode.interfaceFunction) {
attachTaintTableBasedOnAnnotations(invNode);
return;
}
Map<Integer, TaintRecord> taintTable = new HashMap<>();
returnTaintedStatusList = null;
// Check the tainted status of return values when no parameter is tainted.
analyzeAllParamsUntaintedReturnTaintedStatus(taintTable, invNode, symbolEnv);
boolean isBlocked = processBlockedNode(invNode);
if (isBlocked) {
return;
}
int requiredParamCount = invNode.requiredParams.size();
int defaultableParamCount = invNode.defaultableParams.size();
int totalParamCount = requiredParamCount + defaultableParamCount + (invNode.restParam == null ? 0 : 1);
for (int paramIndex = 0; paramIndex < totalParamCount; paramIndex++) {
BLangVariable param = getParam(invNode, paramIndex, requiredParamCount, defaultableParamCount);
// If parameter is sensitive, it is invalid to have a case where tainted status of parameter is true.
if (hasAnnotation(param, ANNOTATION_SENSITIVE)) {
continue;
}
returnTaintedStatusList = null;
// Set each parameter "tainted", then analyze the body to observe the outcome of the function.
analyzeReturnTaintedStatus(taintTable, invNode, symbolEnv, paramIndex, requiredParamCount, defaultableParamCount);
}
invNode.symbol.taintTable = taintTable;
}
}
Aggregations