Search in sources :

Example 71 with Parameter

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);
    }
}
Also used : HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException) HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException)

Example 72 with Parameter

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);
    }
}
Also used : BallerinaConnectorException(org.ballerinalang.connector.api.BallerinaConnectorException) AnnAttrValue(org.ballerinalang.connector.api.AnnAttrValue) ListenerConfiguration(org.wso2.transport.http.netty.config.ListenerConfiguration) ArrayList(java.util.ArrayList) Parameter(org.wso2.transport.http.netty.config.Parameter) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException)

Example 73 with Parameter

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;
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) HTTPCarbonMessage(org.wso2.transport.http.netty.message.HTTPCarbonMessage) Tracer(org.ballerinalang.util.tracer.Tracer) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException)

Example 74 with Parameter

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;
}
Also used : BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType) BLangReturn(org.wso2.ballerinalang.compiler.tree.statements.BLangReturn) BAttachedFunction(org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol.BAttachedFunction) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) BConnectorType(org.wso2.ballerinalang.compiler.semantics.model.types.BConnectorType) BTypeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol) BLangImportPackage(org.wso2.ballerinalang.compiler.tree.BLangImportPackage) Flag(org.ballerinalang.model.elements.Flag) IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) TopLevelNode(org.ballerinalang.model.tree.TopLevelNode) BLangCompilationUnit(org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit) BAnnotationSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol) Names(org.wso2.ballerinalang.compiler.util.Names) BServiceSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol) BEnumType(org.wso2.ballerinalang.compiler.semantics.model.types.BEnumType) EnumSet(java.util.EnumSet) BLangAssignment(org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment) BLangDiagnosticLog(org.wso2.ballerinalang.compiler.util.diagnotic.BLangDiagnosticLog) BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) BXMLNSSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol) BConnectorSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BConnectorSymbol) BStructType(org.wso2.ballerinalang.compiler.semantics.model.types.BStructType) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) CompilerPhase(org.ballerinalang.compiler.CompilerPhase) BXMLAttributeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLAttributeSymbol) BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) PackageID(org.ballerinalang.model.elements.PackageID) Set(java.util.Set) BPackageSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol) BLangXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS) BLangAnnotAttribute(org.wso2.ballerinalang.compiler.tree.BLangAnnotAttribute) Collectors(java.util.stream.Collectors) BLangTransformer(org.wso2.ballerinalang.compiler.tree.BLangTransformer) BLangNode(org.wso2.ballerinalang.compiler.tree.BLangNode) BLangService(org.wso2.ballerinalang.compiler.tree.BLangService) List(java.util.List) IMPORT(org.ballerinalang.model.tree.NodeKind.IMPORT) Scope(org.wso2.ballerinalang.compiler.semantics.model.Scope) BLangEnum(org.wso2.ballerinalang.compiler.tree.BLangEnum) NodeKind(org.ballerinalang.model.tree.NodeKind) BAnnotationAttributeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol) StatementNode(org.ballerinalang.model.tree.statements.StatementNode) BStructSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol) BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) BLangXMLNSStatement(org.wso2.ballerinalang.compiler.tree.statements.BLangXMLNSStatement) BLangInvokableNode(org.wso2.ballerinalang.compiler.tree.BLangInvokableNode) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction) BStructField(org.wso2.ballerinalang.compiler.semantics.model.types.BStructType.BStructField) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType) BAnnotationType(org.wso2.ballerinalang.compiler.semantics.model.types.BAnnotationType) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangExpressionStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt) BLangAnnotation(org.wso2.ballerinalang.compiler.tree.BLangAnnotation) BLangXMLAttribute(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute) BLangStatement(org.wso2.ballerinalang.compiler.tree.statements.BLangStatement) BLangNodeVisitor(org.wso2.ballerinalang.compiler.tree.BLangNodeVisitor) PackageLoader(org.wso2.ballerinalang.compiler.PackageLoader) TypeTags(org.wso2.ballerinalang.compiler.util.TypeTags) BServiceType(org.wso2.ballerinalang.compiler.semantics.model.types.BServiceType) Flags(org.wso2.ballerinalang.util.Flags) BLangResource(org.wso2.ballerinalang.compiler.tree.BLangResource) DocTag(org.ballerinalang.model.elements.DocTag) TreeBuilder(org.ballerinalang.model.TreeBuilder) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) DiagnosticPos(org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos) XMLConstants(javax.xml.XMLConstants) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) BTransformerSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BTransformerSymbol) BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject) BLangXMLQName(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName) Symbols(org.wso2.ballerinalang.compiler.semantics.model.symbols.Symbols) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) Name(org.wso2.ballerinalang.compiler.util.Name) SymTag(org.wso2.ballerinalang.compiler.semantics.model.symbols.SymTag) DiagnosticCode(org.ballerinalang.util.diagnostic.DiagnosticCode) BLangLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral) BLangEnumerator(org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator) BLangInvocation(org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation) BLangConnector(org.wso2.ballerinalang.compiler.tree.BLangConnector) BEndpointVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BEndpointVarSymbol) BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct) BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) SymbolTable(org.wso2.ballerinalang.compiler.semantics.model.SymbolTable) CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction)

Example 75 with Parameter

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;
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) TaintRecord(org.wso2.ballerinalang.compiler.semantics.model.symbols.TaintRecord) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Aggregations

HashMap (java.util.HashMap)26 ArrayList (java.util.ArrayList)19 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)14 JSONDecoder (org.wso2.charon3.core.encoder.JSONDecoder)11 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)11 CharonException (org.wso2.charon3.core.exceptions.CharonException)11 InternalErrorException (org.wso2.charon3.core.exceptions.InternalErrorException)11 NotFoundException (org.wso2.charon3.core.exceptions.NotFoundException)11 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)11 SCIMResourceTypeSchema (org.wso2.charon3.core.schema.SCIMResourceTypeSchema)11 Test (org.testng.annotations.Test)8 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)8 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)8 JSONEncoder (org.wso2.charon3.core.encoder.JSONEncoder)8 List (java.util.List)7 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)7 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)7 SiddhiAppValidationException (org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)7 Parameter (org.apache.axis2.description.Parameter)6 BInvokableType (org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)6