Search in sources :

Example 66 with Property

use of org.wso2.carbon.identity.application.common.model.idp.xsd.Property in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getCorrelationPropertires.

private CorrelationSets_type0 getCorrelationPropertires(ScopeDAO scope) {
    CorrelationSets_type0 correlationSets = new CorrelationSets_type0();
    for (CorrelationSetDAO correlationSetDAO : scope.getCorrelationDTOs()) {
        CorrelationSet_type0 correlationset = new CorrelationSet_type0();
        correlationset.setCsetid(correlationSetDAO.getCorrelationSetId().toString());
        correlationset.setName(correlationSetDAO.getName());
        for (Map.Entry<QName, String> property : correlationSetDAO.getProperties().entrySet()) {
            CorrelationPropertyType prop = new CorrelationPropertyType();
            prop.setCsetid(correlationSetDAO.getCorrelationSetId().toString());
            prop.setPropertyName(property.getKey());
            prop.setString(property.getValue());
            correlationset.addCorrelationProperty(prop);
        }
        correlationSets.addCorrelationSet(correlationset);
    }
    return correlationSets;
}
Also used : CorrelationSet_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CorrelationSet_type0) QName(javax.xml.namespace.QName) CorrelationPropertyType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CorrelationPropertyType) CorrelationSets_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CorrelationSets_type0) CorrelationSetDAO(org.apache.ode.bpel.dao.CorrelationSetDAO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 67 with Property

use of org.wso2.carbon.identity.application.common.model.idp.xsd.Property in project carbon-business-process by wso2.

the class RESTTask method execute.

@Override
public void execute(DelegateExecution execution) {
    if (method == null) {
        String error = "HTTP method for the REST task not found. Please specify the \"method\" form property.";
        throw new RESTClientException(BAD_REQUEST, error);
    }
    if (log.isDebugEnabled()) {
        if (serviceURL != null) {
            log.debug("Executing RESTInvokeTask " + method.getValue(execution).toString() + " - " + serviceURL.getValue(execution).toString());
        } else if (serviceRef != null) {
            log.debug("Executing RESTInvokeTask " + method.getValue(execution).toString() + " - " + serviceRef.getValue(execution).toString());
        }
    }
    RESTInvoker restInvoker = BPMNRestExtensionHolder.getInstance().getRestInvoker();
    RESTResponse response = null;
    String url = null;
    String bUsername = null;
    String bPassword = null;
    JsonNodeObject jsonHeaders = null;
    boolean contentAvailable = false;
    try {
        if (serviceURL != null) {
            url = serviceURL.getValue(execution).toString();
            if (basicAuthUsername != null && basicAuthPassword != null) {
                bUsername = basicAuthUsername.getValue(execution).toString();
                bPassword = basicAuthPassword.getValue(execution).toString();
            }
        } else if (serviceRef != null) {
            String resourcePath = serviceRef.getValue(execution).toString();
            String registryPath;
            int tenantIdInt = Integer.parseInt(execution.getTenantId());
            RealmService realmService = RegistryContext.getBaseInstance().getRealmService();
            String domain = realmService.getTenantManager().getDomain(tenantIdInt);
            Registry registry;
            Resource urlResource;
            try {
                PrivilegedCarbonContext.startTenantFlow();
                if (domain != null) {
                    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(domain);
                    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantIdInt);
                } else {
                    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantIdInt);
                }
                if (resourcePath.startsWith(GOVERNANCE_REGISTRY_PREFIX)) {
                    registryPath = resourcePath.substring(GOVERNANCE_REGISTRY_PREFIX.length());
                    registry = BPMNExtensionsComponent.getRegistryService().getGovernanceSystemRegistry(tenantIdInt);
                } else if (resourcePath.startsWith(CONFIGURATION_REGISTRY_PREFIX)) {
                    registryPath = resourcePath.substring(CONFIGURATION_REGISTRY_PREFIX.length());
                    registry = BPMNExtensionsComponent.getRegistryService().getConfigSystemRegistry(tenantIdInt);
                } else {
                    String msg = "Registry type is not specified for service reference in " + getTaskDetails(execution) + ". serviceRef should begin with gov:/ or conf:/ to indicate the registry type.";
                    throw new RESTClientException(BAD_REQUEST, msg);
                }
                if (log.isDebugEnabled()) {
                    log.debug("Reading endpoint from registry location: " + registryPath + " for task " + getTaskDetails(execution));
                }
                urlResource = registry.get(registryPath);
            } finally {
                PrivilegedCarbonContext.endTenantFlow();
            }
            if (urlResource != null) {
                String uepContent = new String((byte[]) urlResource.getContent(), Charset.defaultCharset());
                UnifiedEndpointFactory uepFactory = new UnifiedEndpointFactory();
                OMElement uepElement = AXIOMUtil.stringToOM(uepContent);
                UnifiedEndpoint uep = uepFactory.createEndpoint(uepElement);
                url = uep.getAddress();
                bUsername = uep.getAuthorizationUserName();
                bPassword = uep.getAuthorizationPassword();
            } else {
                String errorMsg = "Endpoint resource " + registryPath + " is not found. Failed to execute REST invocation in task " + getTaskDetails(execution);
                throw new RESTClientException(errorMsg);
            }
        } else {
            String urlNotFoundErrorMsg = "Service URL is not provided for " + getTaskDetails(execution) + ". serviceURL or serviceRef must be provided.";
            throw new RESTClientException(BAD_REQUEST, urlNotFoundErrorMsg);
        }
        if (headers != null) {
            String headerContent = headers.getValue(execution).toString();
            jsonHeaders = JSONUtils.parse(headerContent);
        }
        if (POST_METHOD.equals(method.getValue(execution).toString().trim().toUpperCase())) {
            String inputContent = input.getValue(execution).toString();
            response = restInvoker.invokePOST(new URI(url), jsonHeaders, bUsername, bPassword, inputContent);
        } else if (GET_METHOD.equals(method.getValue(execution).toString().trim().toUpperCase())) {
            response = restInvoker.invokeGET(new URI(url), jsonHeaders, bUsername, bPassword);
        } else if (PUT_METHOD.equals(method.getValue(execution).toString().trim().toUpperCase())) {
            String inputContent = input.getValue(execution).toString();
            response = restInvoker.invokePUT(new URI(url), jsonHeaders, bUsername, bPassword, inputContent);
        } else if (DELETE_METHOD.equals(method.getValue(execution).toString().trim().toUpperCase())) {
            response = restInvoker.invokeDELETE(new URI(url), jsonHeaders, bUsername, bPassword);
        } else {
            String errorMsg = "Unsupported http method. The REST task only supports GET, POST, PUT and DELETE operations";
            throw new RESTClientException(METHOD_NOT_ALLOWED, errorMsg);
        }
        Object output = response.getContent();
        if (output != null) {
            contentAvailable = !response.getContent().equals("");
        }
        boolean contentTypeAvailable = false;
        if (response.getContentType() != null) {
            contentTypeAvailable = true;
        }
        if (contentAvailable && contentTypeAvailable && response.getContentType().contains(APPLICATION_JSON)) {
            output = JSONUtils.parse(String.valueOf(output));
        } else if (contentAvailable && contentTypeAvailable && response.getContentType().contains(APPLICATION_XML)) {
            output = Utils.parse(String.valueOf(output));
        } else {
            output = StringEscapeUtils.escapeXml(String.valueOf(output));
        }
        boolean isDefaultVarAvailable = false;
        if (enableDefaultVariable != null) {
            isDefaultVarAvailable = Boolean.valueOf(enableDefaultVariable.getValue(execution).toString());
        }
        if (outputVariable != null) {
            String outVarName = outputVariable.getValue(execution).toString();
            execution.setVariable(outVarName, output);
        } else if (outputMappings != null) {
            String outMappings = outputMappings.getValue(execution).toString();
            outMappings = outMappings.trim();
            String[] mappings = outMappings.split(",");
            for (String mapping : mappings) {
                String[] mappingParts = mapping.split(":");
                String varName = mappingParts[0];
                String expression = mappingParts[1];
                String defaultVariableStr = null;
                if (mappingParts.length == 3) {
                    defaultVariableStr = mappingParts[2];
                }
                Object value;
                if (output instanceof JsonNodeObject) {
                    try {
                        value = ((JsonNodeObject) output).jsonPath(expression);
                    } catch (BPMNJsonException e) {
                        if (isDefaultVarAvailable) {
                            value = null;
                            if (StringUtils.isNotBlank(defaultVariableStr)) {
                                value = execution.getVariable(defaultVariableStr);
                            }
                        } else {
                            throw e;
                        }
                    }
                } else if (output instanceof XMLDocument) {
                    try {
                        value = ((XMLDocument) output).xPath(expression);
                    } catch (BPMNXmlException e) {
                        if (isDefaultVarAvailable) {
                            value = null;
                            if (StringUtils.isNotBlank(defaultVariableStr)) {
                                value = execution.getVariable(defaultVariableStr);
                            }
                        } else {
                            throw e;
                        }
                    }
                } else {
                    String errorMessage = "Unrecognized content type found. " + "HTTP Status : " + response.getHttpStatus() + ", Response Content : " + output.toString();
                    setErrorDetailsForTaskExecution(execution, UNRECOGNIZED_CONTENT_TYPE, errorMessage, response);
                    throw new RESTClientException(UNRECOGNIZED_CONTENT_TYPE, errorMessage);
                }
                execution.setVariable(varName, value);
            }
        } else {
            String outputNotFoundErrorMsg = "An outputVariable or outputMappings is not provided. " + "Either an output variable or output mappings  must be provided to save " + "the response.";
            throw new RESTClientException(BAD_REQUEST, outputNotFoundErrorMsg);
        }
        if (responseHeaderVariable != null) {
            StringBuilder headerJsonStr = new StringBuilder();
            headerJsonStr.append("{");
            String prefix = "";
            for (Header header : response.getHeaders()) {
                headerJsonStr.append(prefix);
                String name = header.getName().replaceAll("\"", "");
                String value = header.getValue().replaceAll("\"", "");
                headerJsonStr.append("\"").append(name).append("\":\"").append(value).append("\"");
                prefix = ",";
            }
            headerJsonStr.append("}");
            JsonNodeObject headerJson = JSONUtils.parse(headerJsonStr.toString());
            execution.setVariable(responseHeaderVariable.getValue(execution).toString(), headerJson);
        }
        if (httpStatusVariable != null) {
            execution.setVariable(httpStatusVariable.getValue(execution).toString(), response.getHttpStatus());
        }
    } catch (RegistryException | XMLStreamException | URISyntaxException | IOException | SAXException | ParserConfigurationException e) {
        String errorMessage = "Failed to execute " + method.getValue(execution).toString() + " " + url + " within task " + getTaskDetails(execution);
        setErrorDetailsForTaskExecution(execution, REST_INVOKE_ERROR, errorMessage, response);
        log.error(errorMessage, e);
        throw new RESTClientException(REST_INVOKE_ERROR, errorMessage);
    } catch (BPMNJsonException | BPMNXmlException e) {
        String errorMessage = "Failed to extract values for output mappings, the response content" + " doesn't support the expression" + method.getValue(execution).toString() + " " + url + " within task " + getTaskDetails(execution);
        setErrorDetailsForTaskExecution(execution, INVALID_RESPONSE_CONTENT, errorMessage, response);
        log.error(errorMessage, e);
        throw new RESTClientException(INVALID_RESPONSE_CONTENT, errorMessage);
    } catch (UserStoreException e) {
        String errorMessage = "Failed to obtain tenant domain information";
        setErrorDetailsForTaskExecution(execution, INTERNAL_SERVER_ERROR, errorMessage, response);
        log.error(errorMessage, e);
        throw new RESTClientException(INTERNAL_SERVER_ERROR, errorMessage);
    }
}
Also used : BPMNJsonException(org.wso2.carbon.bpmn.core.types.datatypes.json.BPMNJsonException) JsonNodeObject(org.wso2.carbon.bpmn.core.types.datatypes.json.api.JsonNodeObject) OMElement(org.apache.axiom.om.OMElement) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) UnifiedEndpointFactory(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpointFactory) XMLDocument(org.wso2.carbon.bpmn.core.types.datatypes.xml.api.XMLDocument) SAXException(org.xml.sax.SAXException) UserStoreException(org.wso2.carbon.user.api.UserStoreException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Resource(org.wso2.carbon.registry.api.Resource) Registry(org.wso2.carbon.registry.api.Registry) IOException(java.io.IOException) RegistryException(org.wso2.carbon.registry.api.RegistryException) Header(org.apache.http.Header) XMLStreamException(javax.xml.stream.XMLStreamException) RealmService(org.wso2.carbon.user.core.service.RealmService) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint) JsonNodeObject(org.wso2.carbon.bpmn.core.types.datatypes.json.api.JsonNodeObject) BPMNXmlException(org.wso2.carbon.bpmn.core.types.datatypes.xml.BPMNXmlException)

Example 68 with Property

use of org.wso2.carbon.identity.application.common.model.idp.xsd.Property in project carbon-business-process by wso2.

the class AxisServiceUtils method createAxisService.

/**
 * Build the underlying Axis Service from Service QName and Port Name of interest using given WSDL
 * for BPEL document.
 * In the current implementation we are extracting service name from the soap:address' location property.
 * But specified port may not contain soap:adress instead it may contains http:address. We need to handle that
 * situation.
 *
 * @param axisConfiguration AxisConfiguration to which we should publish the service
 * @param processProxy      BPELProcessProxy
 * @return Axis Service build using WSDL, Service and Port
 * @throws org.apache.axis2.AxisFault on error
 */
public static AxisService createAxisService(AxisConfiguration axisConfiguration, BPELProcessProxy processProxy) throws AxisFault {
    QName serviceName = processProxy.getServiceName();
    String portName = processProxy.getPort();
    Definition wsdlDefinition = processProxy.getWsdlDefinition();
    ProcessConf processConfiguration = processProxy.getProcessConfiguration();
    if (log.isDebugEnabled()) {
        log.debug("Creating AxisService: Service=" + serviceName + " port=" + portName + " WSDL=" + wsdlDefinition.getDocumentBaseURI() + " BPEL=" + processConfiguration.getBpelDocument());
    }
    WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(processProxy);
    /**
     * Need to figure out a way to handle service name extractoin. According to my perspective extracting
     * the service name from the EPR is not a good decision. But we need to handle JMS case properly.
     * I am keeping JMS handling untouched until we figureout best solution.
     */
    /* String axisServiceName = extractServiceName(processConf, wsdlServiceName, portName);*/
    AxisService axisService = populateAxisService(processProxy, axisConfiguration, serviceBuilder);
    Iterator operations = axisService.getOperations();
    BPELMessageReceiver messageRec = new BPELMessageReceiver();
    /**
     * Set the corresponding BPELService to message receivers
     */
    messageRec.setProcessProxy(processProxy);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting WSDLAwareMessage Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(messageRec);
        axisConfiguration.getPhasesInfo().setOperationPhases(operation);
    }
    /**
     * TODO: JMS Destination handling.
     */
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) Iterator(java.util.Iterator) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) BPELMessageReceiver(org.wso2.carbon.bpel.core.ode.integration.axis2.receivers.BPELMessageReceiver)

Example 69 with Property

use of org.wso2.carbon.identity.application.common.model.idp.xsd.Property in project product-microgateway by wso2.

the class RESTAPIServiceImpl method getAPIs.

/**
 * @see RESTAPIService#getAPIs(String, String)
 */
public List<ExtendedAPI> getAPIs(String labelName, String accessToken) {
    logger.debug("Retrieving APIs with label {}", labelName);
    URL url;
    HttpsURLConnection urlConn = null;
    APIListDTO apiListDTO;
    boolean isExpand = false;
    // calling token endpoint
    try {
        publisherEp = publisherEp.endsWith("/") ? publisherEp : publisherEp + "/";
        String urlStr = publisherEp + RESTServiceConstants.APIS_GET_URI.replace(CliConstants.LABEL_PLACEHOLDER, URLEncoder.encode(labelName, CliConstants.CHARSET_UTF8));
        // Expand property is not used from APIM v3 onwards.
        if (restVersion.startsWith(CliConstants.REST_API_V1_PREFIX)) {
            urlStr = urlStr.replace(CliConstants.EXPAND_PLACEHOLDER, "false");
        } else {
            urlStr = urlStr.replace(CliConstants.EXPAND_PLACEHOLDER, "true");
            isExpand = true;
        }
        logger.debug("GET APIs URL: {}", urlStr);
        url = new URL(urlStr);
        urlConn = (HttpsURLConnection) url.openConnection();
        if (inSecure) {
            urlConn.setHostnameVerifier((s, sslSession) -> true);
        }
        urlConn.setDoOutput(true);
        urlConn.setRequestMethod(RESTServiceConstants.GET);
        urlConn.setRequestProperty(RESTServiceConstants.AUTHORIZATION, RESTServiceConstants.BEARER + " " + accessToken);
        int responseCode = urlConn.getResponseCode();
        logger.debug("Response code: {}", responseCode);
        if (responseCode == 200) {
            ObjectMapper mapper = new ObjectMapper();
            String responseStr = RESTAPIUtils.getResponseString(urlConn.getInputStream());
            logger.trace("Response body: {}", responseStr);
            // convert json string to object
            apiListDTO = mapper.readValue(responseStr, APIListDTO.class);
            for (ExtendedAPI api : apiListDTO.getList()) {
                setAdditionalConfigs(api);
                // if using APIM v3, then open API should be fetched separately and set to the API object.
                if (!isExpand) {
                    api.setApiDefinition(getOpenAPIFromAPIId(api.getId(), accessToken));
                }
            }
        } else if (responseCode == 401) {
            throw new CLIRuntimeException("Invalid user credentials or the user does not have required permissions");
        } else {
            throw new RuntimeException("Error occurred while getting token. Status code: " + responseCode);
        }
    } catch (IOException e) {
        String msg = "Error while getting all APIs with label " + labelName;
        throw new RuntimeException(msg, e);
    } finally {
        if (urlConn != null) {
            urlConn.disconnect();
        }
    }
    logger.debug("Retrieving APIs with label {} was successful.", labelName);
    return apiListDTO.getList();
}
Also used : CLIRuntimeException(org.wso2.apimgt.gateway.cli.exception.CLIRuntimeException) APIListDTO(org.wso2.apimgt.gateway.cli.model.rest.APIListDTO) ExtendedAPI(org.wso2.apimgt.gateway.cli.model.rest.ext.ExtendedAPI) IOException(java.io.IOException) CLIRuntimeException(org.wso2.apimgt.gateway.cli.exception.CLIRuntimeException) URL(java.net.URL) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 70 with Property

use of org.wso2.carbon.identity.application.common.model.idp.xsd.Property in project product-microgateway by wso2.

the class BallerinaOperation method buildContext.

@Override
public BallerinaOperation buildContext(Operation operation, ExtendedAPI api) throws BallerinaServiceGenException, CLICompileTimeException, CLIRuntimeException {
    if (operation == null) {
        return getDefaultValue();
    }
    // OperationId with spaces with special characters will cause errors in ballerina code.
    // Replacing it with uuid so that we can identify there was a ' ' when doing bal -> swagger
    operation.setOperationId(UUID.randomUUID().toString().replaceAll("-", ""));
    this.operationId = operation.getOperationId();
    this.tags = operation.getTags();
    this.summary = operation.getSummary();
    this.description = operation.getDescription();
    this.externalDocs = operation.getExternalDocs();
    this.parameters = new ArrayList<>();
    this.pathParameters = new ArrayList<>();
    // to provide resource level security in dev-first approach
    ApplicationSecurity appSecurity = OpenAPICodegenUtils.populateApplicationSecurity(api.getName(), api.getVersion(), operation.getExtensions(), api.getMutualSSL());
    this.authProviders = OpenAPICodegenUtils.getMgwResourceSecurity(operation, appSecurity);
    this.apiKeys = OpenAPICodegenUtils.generateAPIKeysFromSecurity(operation.getSecurity(), this.authProviders.contains(OpenAPIConstants.APISecurity.apikey.name()));
    ApplicationSecurity apiAppSecurity = api.getApplicationSecurity();
    if (appSecurity != null && appSecurity.isOptional() != null) {
        // if app security is made optional at resource
        this.applicationSecurityOptional = appSecurity.isOptional();
    } else if (apiAppSecurity != null && apiAppSecurity.isOptional() != null) {
        // if app security made optional at API level
        this.applicationSecurityOptional = apiAppSecurity.isOptional();
    }
    // to set resource level scopes in dev-first approach
    this.scope = OpenAPICodegenUtils.getMgwResourceScope(operation);
    // set resource level endpoint configuration
    setEpConfigDTO(operation);
    // If production/sandbox endpoints for both API and Operation is not available, Error should be thrown.
    if (api.getEndpointConfigRepresentation().getProdEndpointList() == null && api.getEndpointConfigRepresentation().getSandboxEndpointList() == null && !hasProdEpConfig && !hasSandEpConfig) {
        throw new CLICompileTimeException("The endpoint Configuration is not provided for the operation.");
    }
    Map<String, Object> exts = operation.getExtensions();
    if (exts != null) {
        // set interceptor details
        Object reqExt = exts.get(OpenAPIConstants.REQUEST_INTERCEPTOR);
        Object resExt = exts.get(OpenAPIConstants.RESPONSE_INTERCEPTOR);
        if (reqExt != null) {
            reqInterceptorContext = new BallerinaInterceptor(reqExt.toString());
            requestInterceptor = reqInterceptorContext.getInvokeStatement();
            isJavaRequestInterceptor = BallerinaInterceptor.Type.JAVA == reqInterceptorContext.getType();
        }
        if (resExt != null) {
            resInterceptorContext = new BallerinaInterceptor(resExt.toString());
            responseInterceptor = resInterceptorContext.getInvokeStatement();
            isJavaResponseInterceptor = BallerinaInterceptor.Type.JAVA == resInterceptorContext.getType();
        }
        Optional<Object> scopes = Optional.ofNullable(exts.get(X_SCOPE));
        scopes.ifPresent(value -> this.scope = "\"" + value.toString() + "\"");
        Optional<Object> authType = Optional.ofNullable(exts.get(X_AUTH_TYPE));
        authType.ifPresent(value -> {
            if (AUTH_TYPE_NONE.equals(value)) {
                this.isSecured = false;
            }
        });
        Optional<Object> resourceTier = Optional.ofNullable(exts.get(X_THROTTLING_TIER));
        resourceTier.ifPresent(value -> this.resourceTier = value.toString());
        // set dev-first resource level throttle policy
        if (this.resourceTier == null) {
            Optional<Object> extResourceTier = Optional.ofNullable(exts.get(OpenAPIConstants.THROTTLING_TIER));
            extResourceTier.ifPresent(value -> this.resourceTier = value.toString());
        }
        if (api.getApiLevelPolicy() != null && this.resourceTier != null) {
            // if api level policy exists then we are neglecting the resource level policies
            String message = "[WARN] : Resource level policy: " + this.resourceTier + " will be neglected due to the presence of API level policy: " + api.getApiLevelPolicy() + " for the API : " + api.getName() + "\n";
            CmdUtils.appendMessagesToConsole(message);
            this.resourceTier = null;
        }
        Optional<Object> extDisableSecurity = Optional.ofNullable(exts.get(OpenAPIConstants.DISABLE_SECURITY));
        extDisableSecurity.ifPresent(value -> {
            try {
                this.isSecured = !(Boolean) value;
                this.isSecuredAssignedFromOperation = true;
            } catch (ClassCastException e) {
                throw new CLIRuntimeException("The property '" + OpenAPIConstants.DISABLE_SECURITY + "' should be a boolean value. But provided '" + value.toString() + "'.");
            }
        });
    }
    if (operation.getParameters() != null) {
        for (Parameter parameter : operation.getParameters()) {
            if ("path".equals(parameter.getIn())) {
                this.pathParameters.add(new BallerinaParameter().buildContext(parameter, api));
            }
            this.parameters.add(new BallerinaParameter().buildContext(parameter, api));
        }
    }
    return this;
}
Also used : ApplicationSecurity(org.wso2.apimgt.gateway.cli.model.config.ApplicationSecurity) CLIRuntimeException(org.wso2.apimgt.gateway.cli.exception.CLIRuntimeException) Parameter(io.swagger.v3.oas.models.parameters.Parameter) CLICompileTimeException(org.wso2.apimgt.gateway.cli.exception.CLICompileTimeException)

Aggregations

ArrayList (java.util.ArrayList)114 HashMap (java.util.HashMap)114 Property (org.wso2.carbon.identity.application.common.model.Property)105 Map (java.util.Map)62 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)50 Test (org.testng.annotations.Test)42 UserStoreException (org.wso2.carbon.user.api.UserStoreException)38 IOException (java.io.IOException)37 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)36 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)33 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)32 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)31 List (java.util.List)30 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)29 Resource (org.wso2.carbon.registry.core.Resource)29 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)27 OMElement (org.apache.axiom.om.OMElement)24 PreparedStatement (java.sql.PreparedStatement)23 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)23 Property (org.wso2.carbon.identity.application.common.model.xsd.Property)23