org.apache.axis2.description.Parameter Java Examples

The following examples show how to use org.apache.axis2.description.Parameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InOutMEPHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private void updateStatistics(MessageContext outMsgContext) throws AxisFault {
    // Process System Request count
    Parameter globalRequestCounter =
        outMsgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER);
    ((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet();

    // Process System Response count
    Parameter globalResponseCounter =
        outMsgContext.getParameter(StatisticsConstants.GLOBAL_RESPONSE_COUNTER);
    ((AtomicInteger) globalResponseCounter.getValue()).incrementAndGet();

    updateCurrentInvocationGlobalStatistics(outMsgContext);

    // Calculate response times
    ResponseTimeCalculator.calculateResponseTimes(outMsgContext);
}
 
Example #2
Source File: FaultHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private void updateStatistics(MessageContext msgContext) throws AxisFault {
    // Process System Request count
    Parameter globalRequestCounter =
        msgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER);
    ((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet();

    // Increment the global fault count
    Parameter globalFaultCounter =
            msgContext.getParameter(StatisticsConstants.GLOBAL_FAULT_COUNTER);
    ((AtomicInteger) globalFaultCounter.getValue()).incrementAndGet();

    updateCurrentInvocationGlobalStatistics(msgContext);

    // Calculate response times
    ResponseTimeCalculator.calculateResponseTimes(msgContext);
}
 
Example #3
Source File: AbstractTransportService.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private TransportParameter[] getParameters(ParameterInclude transport) {
    if (transport == null || transport.getParameters() == null ||
        transport.getParameters().size() == 0) {
        return null;
    }

    List<TransportParameter> params = new ArrayList<TransportParameter>();
    List<Parameter> axisParams = transport.getParameters();

    for (Parameter p : axisParams) {
        TransportParameter transportParam = new TransportParameter();
        transportParam.setName(p.getName());
        transportParam.setValue(p.getValue().toString());
        transportParam.setParamElement(p.getParameterElement().toString());
        params.add(transportParam);
    }

    return params.toArray(new TransportParameter[params.size()]);
}
 
Example #4
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Acquires the lock
 *
 * @param axisConfig AxisConfiguration instance
 * @return Lock instance
 */
protected Lock getLock(AxisConfiguration axisConfig) {
    Parameter p = axisConfig.getParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK);
    if (p != null) {
        return (Lock) p.getValue();
    } else {
        log.warn(ServiceBusConstants.SYNAPSE_CONFIG_LOCK + " is null, Recreating a new lock");
        Lock lock = new ReentrantLock();
        try {
            axisConfig.addParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK, lock);
            return lock;
        } catch (AxisFault axisFault) {
            log.error("Error while setting " + ServiceBusConstants.SYNAPSE_CONFIG_LOCK);
        }
    }

    return null;
}
 
Example #5
Source File: ResponseTimeCalculator.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private static void updateCurrentInvocationStatistic(MessageContext messageContext,
                                                     long responseTime) throws AxisFault {
    messageContext.setProperty(StatisticsConstants.GLOBAL_CURRENT_INVOCATION_RESPONSE_TIME,responseTime);

    if (messageContext.getAxisOperation() != null) {
        Parameter operationResponseTimeParam = new Parameter();
        operationResponseTimeParam.setName(StatisticsConstants.OPERATION_RESPONSE_TIME);
        operationResponseTimeParam.setValue(responseTime);
        messageContext.getAxisOperation().addParameter(operationResponseTimeParam);
    }

    if (messageContext.getAxisService() != null) {
        Parameter serviceResponseTimeParam = new Parameter();
        serviceResponseTimeParam.setName(StatisticsConstants.SERVICE_RESPONSE_TIME);
        serviceResponseTimeParam.setValue(responseTime);
        messageContext.getAxisService().addParameter(serviceResponseTimeParam);
    }
}
 
Example #6
Source File: ServiceBusInitializer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private void initPersistence(SynapseConfigurationService synCfgSvc, String configName) throws AxisFault {
    // Initialize the mediation persistence manager if required
    CarbonServerConfigurationService serverConf = CarbonServerConfigurationService.getInstance();
    String persistence = serverConf.getFirstProperty(ServiceBusConstants.PERSISTENCE);
    // Check whether persistence is disabled
    if (!ServiceBusConstants.DISABLED.equals(persistence)) {
        // Check the worker interval is set or not
        String interval = serverConf.getFirstProperty(ServiceBusConstants.WORKER_INTERVAL);
        long intervalInMillis = 5000L;
        if (interval != null && !"".equals(interval)) {
            try {
                intervalInMillis = Long.parseLong(interval);
            } catch (NumberFormatException e) {
                log.error("Invalid value " + interval + " specified for the mediation " + "persistence worker " +
                        "interval, Using defaults", e);
            }
        }
        // Finally init the persistence manager
        MediationPersistenceManager pm = new MediationPersistenceManager(configurationInformation
                .getSynapseXMLLocation(), synCfgSvc.getSynapseConfiguration(), intervalInMillis, configName);
        configCtxSvc.getServerConfigContext().getAxisConfiguration().addParameter(new Parameter
                (ServiceBusConstants.PERSISTENCE_MANAGER, pm));
    } else {
        log.info("Persistence for mediation configuration is disabled");
    }
}
 
Example #7
Source File: MediationPersistenceManager.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
protected Lock getLock(AxisConfiguration axisConfig) {
    Parameter p = axisConfig.getParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK);
    if (p != null) {
        return (Lock) p.getValue();
    } else {
        log.warn(ServiceBusConstants.SYNAPSE_CONFIG_LOCK + " is null, Recreating a new lock");
        Lock lock = new ReentrantLock();
        try {
            axisConfig.addParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK, lock);
            return lock;
        } catch (AxisFault axisFault) {
            log.error("Error while setting " + ServiceBusConstants.SYNAPSE_CONFIG_LOCK);
        }
    }

    return null;
}
 
Example #8
Source File: TracerAdmin.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private TracePersister getTracePersister(Parameter tracePersisterParam) throws AxisFault {
    TracePersister tracePersister = null;
    if (tracePersisterParam != null) {
        Object tracePersisterImplObj = tracePersisterParam.getValue();
        if (tracePersisterImplObj instanceof TracePersister) {
            tracePersister = (TracePersister) tracePersisterImplObj;
        } else if (tracePersisterImplObj instanceof String) {
            //This will need in TestSuite
            try {
                tracePersister =
                        (TracePersister) Loader
                                .loadClass(((String) tracePersisterImplObj).trim())
                                .newInstance();
            } catch (Exception e) {
                String message = "Cannot instatiate TracePersister ";
                log.error(message, e);
                throw new RuntimeException(message, e);
            }
        }
    } else {
        return new MemoryBasedTracePersister(); // The default is the MemoryBasedTRacePersister
    }
    return tracePersister;
}
 
Example #9
Source File: MediationPersistenceTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to get the persistence manger
 * @return persistence manager for this configuration context
 */
protected MediationPersistenceManager getMediationPersistenceManager() {
    Parameter p = synapseConfigSvc.getSynapseConfiguration().
            getAxisConfiguration().getParameter(
            ServiceBusConstants.PERSISTENCE_MANAGER);
    if (p != null) {
        return (MediationPersistenceManager) p.getValue();
    } else {
        MediationPersistenceManager persistenceManager =
                new MediationPersistenceManager(path,
                        synapseConfigSvc.getSynapseConfiguration(), 100, "synapse-config");

        try {
            synapseConfigSvc.getSynapseConfiguration().getAxisConfiguration().addParameter(
                new Parameter(ServiceBusConstants.PERSISTENCE_MANAGER, persistenceManager));
        } catch (AxisFault ignored) { }

        return persistenceManager;
    }
}
 
Example #10
Source File: UrlMappingDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void serviceUpdate(AxisEvent axisEvent, AxisService axisService) {

        Parameter mapping = axisService.getParameter("custom-mapping");
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (mapping == null) {
            return;
        } else {
            if (((String) mapping.getValue()).equalsIgnoreCase("true")) {
                if (axisEvent.getEventType() == 1 || axisEvent.getEventType() == 3) {
                    if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
                        HostUtil.addServiceUrlMapping(tenantId, axisService.getName());
                    }
                } else if (axisEvent.getEventType() == 0 || axisEvent.getEventType() == 2) {
                    tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
                    HostUtil.removeUrlMappingFromMap(tenantId, axisService.getName());
                }
            }
        }
    }
 
Example #11
Source File: ServiceComponent.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private void engagePoxSecurity() {
    try {
        AxisConfiguration axisConfig = DataHolder.getInstance().getConfigCtx().getAxisConfiguration();
        Parameter passwordCallbackParam = new Parameter();
        DefaultPasswordCallback passwordCallbackClass = new DefaultPasswordCallback();
        passwordCallbackParam.setName("passwordCallbackRef");
        passwordCallbackParam.setValue(passwordCallbackClass);
        axisConfig.addParameter(passwordCallbackParam);
        String enablePoxSecurity = CarbonServerConfigurationService.getInstance()
                .getFirstProperty("EnablePoxSecurity");
        if (enablePoxSecurity == null || "true".equals(enablePoxSecurity)) {
            AxisConfiguration mainAxisConfig = DataHolder.getInstance().getConfigCtx().getAxisConfiguration();
            // Check for the module availability
            if (mainAxisConfig.getModules().toString().contains(POX_SECURITY_MODULE)){
                mainAxisConfig.engageModule(POX_SECURITY_MODULE);
                log.debug("UT Security is activated");
            } else {
                log.error("UT Security is not activated UTsecurity.mar is not available");
            }
        } else {
            log.debug("POX Security Disabled");
        }
    } catch (Throwable e) {
        log.error("Failed to activate Micro Integrator UT security module ", e);
    }
}
 
Example #12
Source File: SecurityConfigAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
protected void disableRESTCalls(String serviceName, String scenrioId)
        throws SecurityConfigException {

    if (scenrioId.equals(SecurityConstants.USERNAME_TOKEN_SCENARIO_ID)) {
        return;
    }

    try {
        AxisService service = axisConfig.getServiceForActivation(serviceName);
        if (service == null) {
            throw new SecurityConfigException("nullService");
        }

        Parameter param = new Parameter();
        param.setName(DISABLE_REST);
        param.setValue(Boolean.TRUE.toString());
        service.addParameter(param);

    } catch (AxisFault e) {
        log.error(e);
        throw new SecurityConfigException("disablingREST", e);
    }
}
 
Example #13
Source File: MessageSender.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private Config getDiscoveryConfig(AxisService service) {
    Parameter parameter = service.getParameter(DiscoveryConstants.WS_DISCOVERY_PARAMS);
    Config config;
    if (parameter != null) {
        OMElement element = parameter.getParameterElement();

        // For a ProxyService, the parameter defined as XML, is returned as a string value.
        // Until this problem is solved, we'll be adopting the approach below, to make an
        // attempt to construct the parameter element.
        if (element == null) {
            if (parameter.getValue() != null) {
                try {
                    String wrappedElementText = "<wrapper>" + parameter.getValue() + "</wrapper>";
                    element = AXIOMUtil.stringToOM(wrappedElementText);
                } catch (Exception ignored) { }
            } else {
                return getDefaultConfig();
            }
        }

        config = Config.fromOM(element);
    } else {
        return getDefaultConfig();
    }
    return config;
}
 
Example #14
Source File: UrlMappingServiceListener.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void terminatingConfigurationContext(org.apache.axis2.context.ConfigurationContext configCtx) {
    HashMap<String, AxisService> serviceList = configCtx.getAxisConfiguration().getServices();
    for(Map.Entry<String, AxisService> entry : serviceList.entrySet()) {
        Parameter mapping = entry.getValue().getParameter("custom-mapping");
        int tenantId;
        if(mapping == null) {
            return;
        } else {
            if (((String)mapping.getValue()).equalsIgnoreCase("true")) {
                tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
                HostUtil.removeUrlMappingFromMap(tenantId, entry.getValue().getName());
                log.info("removing service mapping" + entry.getValue().getName() );

            }

        }
    }
}
 
Example #15
Source File: STSAdminServiceImpl.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public void setProofKeyType(String keyType) throws SecurityConfigException {
    try {
        AxisService service = getAxisConfig().getService(ServerConstants.STS_NAME);
        Parameter origParam = service.getParameter(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG
                .getLocalPart());
        if (origParam != null) {
            OMElement samlConfigElem = origParam.getParameterElement().getFirstChildWithName(
                    SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG);
            SAMLTokenIssuerConfig samlConfig = new SAMLTokenIssuerConfig(samlConfigElem);
            samlConfig.setProofKeyType(keyType);
            setSTSParameter(samlConfig);
        } else {
            throw new AxisFault("missing parameter : "
                    + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
        }

    } catch (Exception e) {
        log.error("Error setting proof key type", e);
        throw new SecurityConfigException(e.getMessage(), e);
    }
}
 
Example #16
Source File: STSAdminServiceImpl.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public String getProofKeyType() throws SecurityConfigException {
    try {
        AxisService service = getAxisConfig().getService(ServerConstants.STS_NAME);
        Parameter origParam = service.getParameter(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG
                .getLocalPart());
        if (origParam != null) {
            OMElement samlConfigElem = origParam.getParameterElement().getFirstChildWithName(
                    SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG);
            SAMLTokenIssuerConfig samlConfig = new SAMLTokenIssuerConfig(samlConfigElem);
            return samlConfig.getProofKeyType();
        } else {
            throw new SecurityConfigException("missing parameter : "
                    + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
        }
    } catch (Exception e) {
        log.error("Error while retrieving proof key type", e);
        throw new SecurityConfigException(e.getMessage(), e);
    }
}
 
Example #17
Source File: ApplicationAdmin.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the artifact type of the given service. Service type parameter is used to check this.
 *
 * @param service - AxisService instance
 * @param fileName - file name of the service artifact
 * @return - Service type
 */
private String getArtifactTypeFromService(AxisService service, String fileName) {
    String artifactType = null;

    Parameter serviceTypeParam = service.getParameter(ServerConstants.SERVICE_TYPE);
    String serviceType;
    if (serviceTypeParam != null) {
        serviceType = (String) serviceTypeParam.getValue();
    } else {
        if (fileName.endsWith(".jar")) {
            serviceType = "jaxws";
        } else {
            serviceType = "axis2";
        }
    }

    if (serviceType.equals("axis2")) {
        artifactType = DefaultAppDeployer.AAR_TYPE;
    } else if (serviceType.equals("data_service")) {
        artifactType = DS_TYPE;
    }
    return artifactType;
}
 
Example #18
Source File: RahasUtil.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static Parameter getTokenCancelerConfigParameter() {

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMElement paramElem = fac.createOMElement(new QName("parameter"), null);
        paramElem.addAttribute(fac.createOMAttribute("name",
                null,
                TokenCancelerConfig.TOKEN_CANCELER_CONFIG.
                        getLocalPart()));
        paramElem.addAttribute(fac.createOMAttribute("type",
                null, Integer.toString(Parameter.OM_PARAMETER).
                        toString()));

        fac.createOMElement(TokenCancelerConfig.TOKEN_CANCELER_CONFIG,
                paramElem);
        Parameter param = new Parameter();
        param.setName(TokenCancelerConfig.TOKEN_CANCELER_CONFIG.getLocalPart());
        param.setParameterElement(paramElem);
        param.setValue(paramElem);
        param.setParameterType(Parameter.OM_PARAMETER);
        return param;
    }
 
Example #19
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * This method returns the available data services names.
 *
 * @param axisConfiguration Axis configuration
 * @return names of available data services
 * @throws AxisFault
 */
public static String[] getAvailableDS(AxisConfiguration axisConfiguration) throws AxisFault {
    List<String> serviceList = new ArrayList<>();
    Map<String, AxisService> map = axisConfiguration.getServices();
    Set<String> set = map.keySet();
    for (String serviceName : set) {
        AxisService axisService = axisConfiguration.getService(serviceName);
        Parameter parameter = axisService.getParameter(DBConstants.AXIS2_SERVICE_TYPE);
        if (parameter != null) {
            if (DBConstants.DB_SERVICE_TYPE.equals(parameter.getValue().toString())) {
                serviceList.add(serviceName);
            }
        }
    }
    return serviceList.toArray(new String[serviceList.size()]);
}
 
Example #20
Source File: KubernetesMembershipScheme.java    From product-private-paas with Apache License 2.0 5 votes vote down vote up
public KubernetesMembershipScheme(Map<String, Parameter> parameters,
                                  String primaryDomain,
                                  Config config,
                                  HazelcastInstance primaryHazelcastInstance,
                                  List<ClusteringMessage> messageBuffer) {
    this.parameters = parameters;
    this.primaryHazelcastInstance = primaryHazelcastInstance;
    this.messageBuffer = messageBuffer;
    this.nwConfig = config.getNetworkConfig();
}
 
Example #21
Source File: Util.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Disengage the TargetServiceObserver from the given AxisConfiguration. This will
 * disable service discovery. If sendBye is set to 'true' this method will also send BYE
 * messages to the discovery proxy before disabling the TargetServiceObserver. This method
 * expects the discovery proxy parameter is available in the AxisConfiguration. Without
 * that it will not send BYE messages even if sendBye is set to 'true'.
 *
 * @param axisConf AxisConfiguration instance
 * @param sendBye true if BYE messages should be sent for all the deployed services
 */
public static void unregisterServiceObserver(AxisConfiguration axisConf, boolean sendBye) {
    if (sendBye) {
        Parameter discoveryProxyParam = axisConf.getParameter(DiscoveryConstants.DISCOVERY_PROXY);
        if (discoveryProxyParam != null) {
            MessageSender messageSender = new MessageSender();
            try {
                for (AxisService axisService : axisConf.getServices().values()) {
                    messageSender.sendBye(axisService, (String) discoveryProxyParam.getValue());
                }
            } catch (DiscoveryException e) {
                log.error("Cannot send the bye message", e);
            }
        }
    }

    List<AxisObserver> observers = axisConf.getObserversList();
    AxisObserver serviceObserver = null;
    // Locate the TargetServiceObserver instance registered earlier
    for (AxisObserver o : observers) {
        if (o instanceof TargetServiceObserver) {
            serviceObserver = o;
            break;
        }
    }

    if (serviceObserver != null) {            
        observers.remove(serviceObserver);
    }
}
 
Example #22
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public int getOperationFaultCount(AxisOperation axisOperation) throws AxisFault {
    Parameter parameter =
            axisOperation.getParameter(StatisticsConstants.OPERATION_FAULT_COUNTER);
    if (parameter != null) {
        return ((AtomicInteger) parameter.getValue()).get();
    }
    return 0;
}
 
Example #23
Source File: CoreServerInitializer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private ConfigurationContext getClientConfigurationContext() throws AxisFault {
    String clientRepositoryLocation = serverConfigurationService.getFirstProperty(CLIENT_REPOSITORY_LOCATION);
    String clientAxis2XmlLocationn = serverConfigurationService.getFirstProperty(CLIENT_AXIS2_XML_LOCATION);
    ConfigurationContext clientConfigContextToReturn = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(clientRepositoryLocation, clientAxis2XmlLocationn);
    MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();

    // Set the default max connections per host
    int defaultMaxConnPerHost = 500;
    Parameter defaultMaxConnPerHostParam = clientConfigContextToReturn.getAxisConfiguration()
            .getParameter("defaultMaxConnPerHost");
    if (defaultMaxConnPerHostParam != null) {
        defaultMaxConnPerHost = Integer.parseInt((String) defaultMaxConnPerHostParam.getValue());
    }
    params.setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost);

    // Set the max total connections
    int maxTotalConnections = 15000;
    Parameter maxTotalConnectionsParam = clientConfigContextToReturn.getAxisConfiguration()
            .getParameter("maxTotalConnections");
    if (maxTotalConnectionsParam != null) {
        maxTotalConnections = Integer.parseInt((String) maxTotalConnectionsParam.getValue());
    }
    params.setMaxTotalConnections(maxTotalConnections);

    params.setSoTimeout(600000);
    params.setConnectionTimeout(600000);

    httpConnectionManager.setParams(params);
    clientConfigContextToReturn
            .setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, httpConnectionManager);

    clientConfigContextToReturn.setProperty(MicroIntegratorBaseConstants.WORK_DIR, serverWorkDir);
    return clientConfigContextToReturn;
}
 
Example #24
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public int getServiceResponseCount(AxisService axisService) throws AxisFault {
    int count = 0;
    for (Iterator opIter = axisService.getOperations(); opIter.hasNext();) {
        AxisOperation axisOp = (AxisOperation) opIter.next();
        Parameter parameter = axisOp.getParameter(StatisticsConstants.OUT_OPERATION_COUNTER);
        if (parameter != null) {
            count += ((AtomicInteger) parameter.getValue()).get();
        }
    }
    return count;
}
 
Example #25
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public double getAvgOperationResponseTime(AxisOperation axisOperation) throws AxisFault {
    double avg = 0;
    Parameter parameter =
            axisOperation.getParameter(StatisticsConstants.OPERATION_RESPONSE_TIME_PROCESSOR);
    if (parameter != null) {
        avg = ((ResponseTimeProcessor) parameter.getValue()).getAvgResponseTime();
    }
    return avg;
}
 
Example #26
Source File: MicroIntegratorBaseUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Get Synapse Environment. This might throw NPE if called before SynapseEnvironment is initialized.
 *
 * @return SynapseEnvironment - SynapseEnvironment
 */
public static SynapseEnvironment getSynapseEnvironment() {

    Parameter synapseEnvironmentParatemer =
            CarbonCoreDataHolder.getInstance().getAxis2ConfigurationContextService().getServerConfigContext()
                    .getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_ENV);
    return (SynapseEnvironment) synapseEnvironmentParatemer.getValue();
}
 
Example #27
Source File: CertificateManagerImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes an instance of CertificateManagerImpl.
 */
private CertificateManagerImpl() {
    String isMutualTLSConfigured = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService()
            .getAPIManagerConfiguration().getFirstProperty(APIConstants.ENABLE_MTLS_FOR_APIS);
    if (StringUtils.isNotEmpty(isMutualTLSConfigured) && isMutualTLSConfigured.equalsIgnoreCase("true")) {
        isMTLSConfigured = true;
    }
    if (isMTLSConfigured) {
        if (log.isDebugEnabled()) {
            log.debug("Mutual TLS based security is enabled for APIs. Hence APIs can be secured using mutual TLS "
                    + "and OAuth2");
        }
        TransportInDescription transportInDescription = ServiceReferenceHolder.getContextService()
                .getServerConfigContext().getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTPS);
        Parameter profilePathParam = transportInDescription.getParameter("dynamicSSLProfilesConfig");
        if (profilePathParam == null) {
            listenerProfileFilePath = null;
        } else {
            OMElement pathEl = profilePathParam.getParameterElement();
            String path = pathEl.getFirstChildWithName(new QName("filePath")).getText();
            if (path != null) {
                String separator = path.startsWith(File.separator) ? "" : File.separator;
                listenerProfileFilePath = System.getProperty("user.dir") + separator + path;
            }
        }
    }
    if (log.isDebugEnabled()) {
        if (isMTLSConfigured) {
            log.debug("Mutual SSL based authentication is supported for this server.");
        } else {
            log.debug("Mutual SSL based authentication is not supported for this server.");
        }
    }
}
 
Example #28
Source File: DiscoveryAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Enable publishing services using WS-Discovery to the specified Discovery proxy
 *
 * @param proxyURL URL of the target discovery proxy
 * @throws Exception on error
 */
public void enableServiceDiscovery(String proxyURL) throws Exception {
    AxisConfiguration axisConfig = getAxisConfig();
    if (axisConfig.getParameter(DiscoveryConstants.DISCOVERY_PROXY) != null) {
        return;
    }

    Parameter param = new Parameter(DiscoveryConstants.DISCOVERY_PROXY, proxyURL);
    param.setParameterElement(AXIOMUtil.stringToOM("<parameter name=\"" +
            DiscoveryConstants.DISCOVERY_PROXY + "\">" + proxyURL + "</parameter>"));
    axisConfig.addParameter(param);
    Util.registerServiceObserver(axisConfig);
    DiscoveryMgtUtils.persistPublisherConfiguration(proxyURL, true, getConfigSystemRegistry());
}
 
Example #29
Source File: IheHttpFactory.java    From openxds with Apache License 2.0 5 votes vote down vote up
private String getStringParam(String name, String def) {
        Parameter param = httpConfiguration.getParameter(name);
        if (param != null) {
//            assert param.getParameterType() == Parameter.TEXT_PARAMETER;
            String config = (String) param.getValue();
            if (config != null) {
                return config;
            }
        }
        return def;
    }
 
Example #30
Source File: JMSTaskManagerFactory.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
private static Map<String, String> getServiceStringParameters(List<Parameter> list) {

        Map<String, String> map = new HashMap<String, String>();
        for (Parameter p : list) {
            if (p.getValue() instanceof String) {
                map.put(p.getName(), (String) p.getValue());
            }
        }
        return map;
    }