Search in sources :

Example 86 with Environment

use of org.wso2.carbon.apimgt.api.model.Environment in project carbon-identity-framework by wso2.

the class PolicyEditorUtil method createMatchElement.

/**
 * This method creates a match element (such as subject,action,resource or environment) of the XACML policy
 *
 * @param matchElementDTO match element data object
 * @param doc             XML document
 * @return match Element
 * @throws PolicyEditorException if any error occurs
 */
public static Element createMatchElement(MatchElementDTO matchElementDTO, Document doc) throws PolicyEditorException {
    Element matchElement;
    if (matchElementDTO.getMatchId() != null && matchElementDTO.getMatchId().trim().length() > 0) {
        matchElement = doc.createElement(PolicyEditorConstants.MATCH_ELEMENT);
        matchElement.setAttribute(PolicyEditorConstants.MATCH_ID, matchElementDTO.getMatchId());
        if (matchElementDTO.getAttributeValueElementDTO() != null) {
            Element attributeValueElement = createAttributeValueElement(matchElementDTO.getAttributeValueElementDTO(), doc);
            matchElement.appendChild(attributeValueElement);
        }
        if (matchElementDTO.getAttributeDesignatorDTO() != null) {
            Element attributeDesignatorElement = createAttributeDesignatorElement(matchElementDTO.getAttributeDesignatorDTO(), doc);
            matchElement.appendChild(attributeDesignatorElement);
        } else if (matchElementDTO.getAttributeSelectorDTO() != null) {
            Element attributeSelectorElement = createAttributeSelectorElement(matchElementDTO.getAttributeSelectorDTO(), doc);
            matchElement.appendChild(attributeSelectorElement);
        }
    } else {
        throw new PolicyEditorException("Can not create Match element:" + " Required Attributes are missing");
    }
    return matchElement;
}
Also used : PolicyEditorException(org.wso2.carbon.identity.entitlement.common.PolicyEditorException) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element)

Example 87 with Environment

use of org.wso2.carbon.apimgt.api.model.Environment in project carbon-identity-framework by wso2.

the class IdentityUtil method getIdentityCacheConfig.

/**
 * This reads the <CacheConfig> configuration in identity.xml.
 * Since the name of the cache is different between the distributed mode and local mode,
 * that is specially handled.
 * <p>
 * When calling this method, only pass the cacheManagerName and cacheName parameters considering
 * how the names are set in a clustered environment i.e. without the CachingConstants.LOCAL_CACHE_PREFIX.
 */
public static IdentityCacheConfig getIdentityCacheConfig(String cacheManagerName, String cacheName) {
    IdentityCacheConfigKey configKey = new IdentityCacheConfigKey(cacheManagerName, cacheName);
    IdentityCacheConfig identityCacheConfig = identityCacheConfigurationHolder.get(configKey);
    if (identityCacheConfig == null && cacheName.startsWith(CachingConstants.LOCAL_CACHE_PREFIX)) {
        configKey = new IdentityCacheConfigKey(cacheManagerName, cacheName.replace(CachingConstants.LOCAL_CACHE_PREFIX, ""));
        identityCacheConfig = identityCacheConfigurationHolder.get(configKey);
    }
    return identityCacheConfig;
}
Also used : IdentityCacheConfig(org.wso2.carbon.identity.core.model.IdentityCacheConfig) IdentityCacheConfigKey(org.wso2.carbon.identity.core.model.IdentityCacheConfigKey)

Example 88 with Environment

use of org.wso2.carbon.apimgt.api.model.Environment in project product-iots by wso2.

the class IOTServerExtension method initiate.

@Override
public void initiate() {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, IOT_CORE_PORT_OFFSET);
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment = automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
    } catch (XPathExpressionException e) {
        throw new RuntimeException("Error while initiating test environment", e);
    }
}
Also used : AutomationContext(org.wso2.carbon.automation.engine.context.AutomationContext) XPathExpressionException(javax.xml.xpath.XPathExpressionException)

Example 89 with Environment

use of org.wso2.carbon.apimgt.api.model.Environment in project product-iots by wso2.

the class BrokerServerExtension method initiate.

@Override
public void initiate() throws AutomationFrameworkException {
    try {
        automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "3");
        }
        serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
        executionEnvironment = automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
    } catch (XPathExpressionException e) {
        handleException("Error while initiating test environment", e);
    }
}
Also used : AutomationContext(org.wso2.carbon.automation.engine.context.AutomationContext) XPathExpressionException(javax.xml.xpath.XPathExpressionException)

Example 90 with Environment

use of org.wso2.carbon.apimgt.api.model.Environment in project carbon-mediation by wso2.

the class ConfigurationUpdater method publishConfiguration.

private void publishConfiguration(SynapseConfiguration synCfg, Axis2SynapseEnvironment synEnv) {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    SynapseRegistrationsService registrationsService = ConfigHolder.getInstance().getSynapseRegistrationService(tenantId);
    if (registrationsService != null) {
        serverContextInformation.setSynapseConfiguration(synCfg);
        // populate the Synapse Configuration
        ServiceRegistration configRegistration = registrationsService.getSynapseConfigurationServiceRegistration();
        SynapseConfigurationService synCfgSvc = (SynapseConfigurationService) ConfigHolder.getInstance().getBundleContext().getService(configRegistration.getReference());
        synCfgSvc.setSynapseConfiguration(synCfg);
        configRegistration.setProperties(new Properties());
        // populate the Synapse Environment
        ServiceRegistration synEnvSvcRegistration = registrationsService.getSynapseEnvironmentServiceRegistration();
        SynapseEnvironmentService synEnvSvc = (SynapseEnvironmentService) ConfigHolder.getInstance().getBundleContext().getService(synEnvSvcRegistration.getReference());
        synEnvSvc.setSynapseEnvironment(synEnv);
        synEnvSvcRegistration.setProperties(new Properties());
        ConfigurationTrackingService trackingSvc = ConfigHolder.getInstance().getSynapseConfigTrackingService();
        if (trackingSvc != null) {
            trackingSvc.setSynapseConfiguration(synCfg);
        }
    } else {
        String msg = "Couldn't find the OSGi service information about this " + "ESB Configuration";
        log.error(msg);
        throw new ConfigAdminException(msg);
    }
}
Also used : SynapseRegistrationsService(org.wso2.carbon.mediation.initializer.services.SynapseRegistrationsService) SynapseConfigurationService(org.wso2.carbon.mediation.initializer.services.SynapseConfigurationService) ConfigurationTrackingService(org.wso2.carbon.mediation.dependency.mgt.services.ConfigurationTrackingService) SynapseEnvironmentService(org.wso2.carbon.mediation.initializer.services.SynapseEnvironmentService) Properties(java.util.Properties) InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

Environment (org.wso2.carbon.apimgt.api.model.Environment)67 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)53 ArrayList (java.util.ArrayList)38 HashMap (java.util.HashMap)28 API (org.wso2.carbon.apimgt.api.model.API)22 IOException (java.io.IOException)21 APIRevisionDeployment (org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)19 Map (java.util.Map)17 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)13 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)12 JsonObject (com.google.gson.JsonObject)11 Gson (com.google.gson.Gson)10 PreparedStatement (java.sql.PreparedStatement)10 SQLException (java.sql.SQLException)10 HashSet (java.util.HashSet)10 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)10 SolaceAdminApis (org.wso2.carbon.apimgt.solace.SolaceAdminApis)10 JSONObject (org.json.simple.JSONObject)9 Test (org.junit.Test)9 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)9