Java Code Examples for org.apache.axis2.util.JavaUtils#isTrueExplicitly()

The following examples show how to use org.apache.axis2.util.JavaUtils#isTrueExplicitly() . 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: ServerStartupListener.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Override
public void completedServerStartup() {

    copyToExtensions();

    APIManagerConfiguration apiManagerConfiguration =
            ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    if (apiManagerConfiguration != null) {
        String defaultKeyManagerRegistration =
                apiManagerConfiguration.getFirstProperty(APIConstants.ENABLE_DEFAULT_KEY_MANAGER_REGISTRATION);
        if (StringUtils.isNotEmpty(defaultKeyManagerRegistration) &&
                JavaUtils.isTrueExplicitly(defaultKeyManagerRegistration)) {
            try {
                KeyMgtRegistrationService.registerDefaultKeyManager(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
            } catch (APIManagementException e) {
                log.error("Error while registering Default Key Manager for SuperTenant", e);
            }
        }
        String enableKeyManagerRetrieval =
                apiManagerConfiguration.getFirstProperty(APIConstants.ENABLE_KEY_MANAGER_RETRIVAL);
        if (JavaUtils.isTrueExplicitly(enableKeyManagerRetrieval)) {
            startConfigureKeyManagerConfigurations();
        }
    }
}
 
Example 2
Source File: APIMgtGoogleAnalyticsUtils.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public GoogleAnalyticsConfig(OMElement config) {
    googleAnalyticsTrackingID = config
            .getFirstChildWithName(new QName(APIMgtUsagePublisherConstants.API_GOOGLE_ANALYTICS_TRACKING_ID))
            .getText();
    String googleAnalyticsEnabledStr = config.getFirstChildWithName(
            new QName(APIMgtUsagePublisherConstants.API_GOOGLE_ANALYTICS_TRACKING_ENABLED)).getText();
    enabled = googleAnalyticsEnabledStr != null && JavaUtils.isTrueExplicitly(googleAnalyticsEnabledStr);
}
 
Example 3
Source File: APIMgtGoogleAnalyticsTrackingHandler.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public GoogleAnalyticsConfig(OMElement config) {
	googleAnalyticsTrackingID = config.getFirstChildWithName(new QName(
			APIMgtUsagePublisherConstants.API_GOOGLE_ANALYTICS_TRACKING_ID)).getText();
          String googleAnalyticsEnabledStr = config.getFirstChildWithName(new QName(
          		APIMgtUsagePublisherConstants.API_GOOGLE_ANALYTICS_TRACKING_ENABLED)).getText();
          enabled =  googleAnalyticsEnabledStr != null && JavaUtils.isTrueExplicitly(googleAnalyticsEnabledStr);
}
 
Example 4
Source File: JMSListenerStartupShutdownListener.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public void completedServerStartup() {

    APIManagerConfiguration apimConfiguration = ServiceReferenceHolder.getInstance().getAPIMConfiguration();
    if (apimConfiguration != null) {
        String enableKeyManagerRetrieval =
                apimConfiguration.getFirstProperty(APIConstants.ENABLE_KEY_MANAGER_RETRIVAL);
        if (JavaUtils.isTrueExplicitly(enableKeyManagerRetrieval)) {
            jmsTransportHandlerForEventHub
                    .subscribeForJmsEvents(JMSConstants.TOPIC_KEY_MANAGER, new KeyManagerJMSMessageListener());
        }
    }
}
 
Example 5
Source File: SystemStatisticsDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void serviceUpdate(AxisEvent axisEvent, AxisService axisService) {

        if (SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) || axisService.isClientSide()) {
            return;
        }
        if (axisEvent.getEventType() == AxisEvent.SERVICE_DEPLOY) {
            for (Iterator iter = axisService.getOperations(); iter.hasNext(); ) {
                AxisOperation op = (AxisOperation) iter.next();
                setCountersAndProcessors(op);
            }
            // see ESBJAVA-2327
            if (JavaUtils.isTrueExplicitly(axisService.getParameterValue("disableOperationValidation"))) {
                AxisOperation defaultOp = (AxisOperation) axisService.getParameterValue("_default_mediate_operation_");
                if (defaultOp != null) {
                    setCountersAndProcessors(defaultOp);
                }
            }
            // Service response time processor
            Parameter responseTimeProcessor = new Parameter();
            responseTimeProcessor.setName(StatisticsConstants.SERVICE_RESPONSE_TIME_PROCESSOR);
            responseTimeProcessor.setValue(new ResponseTimeProcessor());
            try {
                axisService.addParameter(responseTimeProcessor);
            } catch (AxisFault axisFault) {
                // will not occur
            }
        }
    }
 
Example 6
Source File: DiscoveryMgtUtils.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether service discovery is enabled in the configuration. This method first checks
 * whether the DiscoveryConstants.DISCOVERY_PROXY parameter is set in the given AxisConfiguration.
 * If not it checks whether service discovery status is set to 'true' in the configuration
 * registry. If discovery is enabled in the registry configuration, this method will also
 * add the corresponding parameter to AxisConfiguration.
 *
 * @param axisConfig AxisConfiguration
 * @return service discovery status
 * @throws RegistryException if an error occurs while accessing the registry
 */
public static boolean isServiceDiscoveryEnabled(AxisConfiguration axisConfig) throws RegistryException {
    Parameter parameter = getDiscoveryParam(axisConfig);
    if (parameter != null) {
        return true;
    }

    String path = DISCOVERY_CONFIG_ROOT + DISCOVERY_PUBLISHER_CONFIG;

    Registry registry = PrivilegedCarbonContext.getThreadLocalCarbonContext().
            getRegistry(RegistryType.SYSTEM_CONFIGURATION);
    if (registry.resourceExists(path)) {
        Resource publisherConfig = registry.get(path);
        String status = publisherConfig.getProperty(DISCOVERY_PUBLISHER_STATUS);
        publisherConfig.discard();
        boolean enabled = JavaUtils.isTrueExplicitly(status);

        if (enabled) {
            String discoveryProxyURL = getDiscoveryProxyURL(registry);
            try {
                Parameter discoveryProxyParam =
                        ParameterUtil.createParameter(DiscoveryConstants.DISCOVERY_PROXY,
                                                      discoveryProxyURL);
                axisConfig.addParameter(discoveryProxyParam);
            } catch (AxisFault axisFault) {
                axisFault.printStackTrace();  //TODO
            }
        }
        return enabled;
    }

    return false;
}
 
Example 7
Source File: MessageSender.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private boolean isDiscoverable(AxisService service) {
    boolean isAdminService = JavaUtils.isTrueExplicitly(
            service.getParameterValue("adminService"));
    boolean isHiddenService = JavaUtils.isTrueExplicitly(
            service.getParameterValue("hiddenService"));
    boolean isUndiscoverableService = JavaUtils.isTrueExplicitly(
            service.getParameterValue(DiscoveryConstants.UNDISCOVERABLE_SERVICE));

    // do not sent the notifications for either hidden or admin services
    if (isAdminService || isHiddenService ||
            isUndiscoverableService || service.isClientSide()){
        return false;
    }
    return true;
}
 
Example 8
Source File: PassThroughNHttpGetProcessor.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the HTML text for the list of services deployed.
 * This can be delegated to another Class as well
 * where it will handle more options of GET messages.
 *
 * @param prefix to be used for the Service names
 * @return the HTML to be displayed as a String
 */
protected String getServicesHTML(String prefix) {

    Map services = cfgCtx.getAxisConfiguration().getServices();
    Hashtable erroneousServices = cfgCtx.getAxisConfiguration().getFaultyServices();
    boolean servicesFound = false;

    StringBuffer resultBuf = new StringBuffer();
    resultBuf.append("<html><head><title>Axis2: Services</title></head>" + "<body>");

    if ((services != null) && !services.isEmpty()) {

        servicesFound = true;
        resultBuf.append("<h2>" + "Deployed services" + "</h2>");

        for (Object service : services.values()) {

            AxisService axisService = (AxisService) service;
            Parameter isHiddenService = axisService.getParameter(
                    NhttpConstants.HIDDEN_SERVICE_PARAM_NAME);
            Parameter isAdminService = axisService.getParameter("adminService");
            boolean isClientSide = axisService.isClientSide();

            boolean isSkippedService = (isHiddenService != null &&
                    JavaUtils.isTrueExplicitly(isHiddenService.getValue())) || (isAdminService != null &&
                    JavaUtils.isTrueExplicitly(isAdminService.getValue())) || isClientSide;
            if (axisService.getName().startsWith("__") || isSkippedService) {
                continue;    // skip private services
            }

            Iterator iterator = axisService.getOperations();
            resultBuf.append("<h3><a href=\"").append(prefix).append(axisService.getName()).append(
                    "?wsdl\">").append(axisService.getName()).append("</a></h3>");

            if (iterator.hasNext()) {
                resultBuf.append("Available operations <ul>");

                for (; iterator.hasNext();) {
                    AxisOperation axisOperation = (AxisOperation) iterator.next();
                    resultBuf.append("<li>").append(
                            axisOperation.getName().getLocalPart()).append("</li>");
                }
                resultBuf.append("</ul>");
            } else {
                resultBuf.append("No operations specified for this service");
            }
        }
    }

    if ((erroneousServices != null) && !erroneousServices.isEmpty()) {
        servicesFound = true;
        resultBuf.append("<hr><h2><font color=\"blue\">Faulty Services</font></h2>");
        Enumeration faultyservices = erroneousServices.keys();

        while (faultyservices.hasMoreElements()) {
            String faultyserviceName = (String) faultyservices.nextElement();
            resultBuf.append("<h3><font color=\"blue\">").append(
                    faultyserviceName).append("</font></h3>");
        }
    }

    if (!servicesFound) {
        resultBuf.append("<h2>There are no services deployed</h2>");
    }

    resultBuf.append("</body></html>");
    return resultBuf.toString();
}
 
Example 9
Source File: OAuthServerConfiguration.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
private void parseAuthorizationContextTokenGeneratorConfig(OMElement oauthConfigElem) {
    OMElement authContextTokGenConfigElem =
            oauthConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.AUTHORIZATION_CONTEXT_TOKEN_GENERATION));
    if (authContextTokGenConfigElem != null) {
        OMElement enableJWTGenerationConfigElem =
                authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.ENABLED));
        if (enableJWTGenerationConfigElem != null) {
            String enableJWTGeneration = enableJWTGenerationConfigElem.getText().trim();
            if (enableJWTGeneration != null && JavaUtils.isTrueExplicitly(enableJWTGeneration)) {
                isAuthContextTokGenEnabled = true;
                if (authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.TOKEN_GENERATOR_IMPL_CLASS)) != null) {
                    tokenGeneratorImplClass =
                            authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.TOKEN_GENERATOR_IMPL_CLASS))
                                    .getText().trim();
                }
                if (authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.CLAIMS_RETRIEVER_IMPL_CLASS)) != null) {
                    claimsRetrieverImplClass =
                            authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.CLAIMS_RETRIEVER_IMPL_CLASS))
                                    .getText().trim();
                }
                if (authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.CONSUMER_DIALECT_URI)) != null) {
                    consumerDialectURI =
                            authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.CONSUMER_DIALECT_URI))
                                    .getText().trim();
                }
                if (authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.SIGNATURE_ALGORITHM)) != null) {
                    signatureAlgorithm =
                            authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.SIGNATURE_ALGORITHM))
                                    .getText().trim();
                }
                if (authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.SECURITY_CONTEXT_TTL)) != null) {
                    authContextTTL =
                            authContextTokGenConfigElem.getFirstChildWithName(getQNameWithIdentityNS(ConfigElements.SECURITY_CONTEXT_TTL))
                                    .getText().trim();
                }
            }
        }
    }
    if (log.isDebugEnabled()) {
        if (isAuthContextTokGenEnabled) {
            log.debug("JWT Generation is enabled");
        } else {
            log.debug("JWT Generation is disabled");
        }
    }
}
 
Example 10
Source File: APIManagerAnalyticsConfiguration.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
public void setAPIManagerConfiguration(APIManagerConfiguration config){
    String usageEnabled = config.getFirstProperty(APIConstants.API_USAGE_ENABLED);
    analyticsEnabled = JavaUtils.isTrueExplicitly(usageEnabled);
    if (analyticsEnabled){
        String skipEventReceiverConnStr = config.getFirstProperty(APIConstants.API_USAGE_SKIP_EVENT_RECEIVER_CONN);
        skipEventReceiverConnection = skipEventReceiverConnStr != null && JavaUtils.isTrueExplicitly
                (skipEventReceiverConnStr);
        String skipWorkflowDataPublisherStr = config
                .getFirstProperty(APIConstants.API_USAGE_SKIP_WORKFLOW_EVENT_RECEIVER_CONN);
        skipWorkFlowEventReceiverConnection =
                skipWorkflowDataPublisherStr != null && JavaUtils.isTrueExplicitly(skipWorkflowDataPublisherStr);
        publisherClass = config.getFirstProperty(APIConstants.API_USAGE_PUBLISHER_CLASS);
        requestStreamName = config.getFirstProperty(APIConstants.API_REQUEST_STREAM_NAME);
        requestStreamVersion = config.getFirstProperty(APIConstants.API_REQUEST_STREAM_VERSION);
        if (requestStreamName == null || requestStreamVersion == null) {
            log.error("Request stream name or version is null. Check api-manager.xml");
        }
        botDataStreamName = config.getFirstProperty("Analytics.Streams.botData.Name");
        botDataStreamVersion = config.getFirstProperty("Analytics.Streams.botData.Version");

        responseStreamName = config.getFirstProperty(APIConstants.API_RESPONSE_STREAM_NAME);
        responseStreamVersion = config.getFirstProperty(APIConstants.API_RESPONSE_STREAM_VERSION);

        faultStreamName = config.getFirstProperty(APIConstants.API_FAULT_STREAM_NAME);
        faultStreamVersion = config.getFirstProperty(APIConstants.API_FAULT_STREAM_VERSION);
        if (faultStreamName == null || faultStreamVersion == null) {
            log.error("Fault stream name or version is null. Check api-manager.xml");
        }
        throttleStreamName = config.getFirstProperty(APIConstants.API_THROTTLE_STREAM_NAME);
        throttleStreamVersion = config.getFirstProperty(APIConstants.API_THRORRLE_STREAM_VERSION);
        if (throttleStreamName == null || throttleStreamVersion == null) {
            log.error("Throttle stream name or version is null. Check api-manager.xml");
        }
        executionTimeStreamName = config.getFirstProperty(APIConstants.API_EXECUTION_TIME_STREAM_NAME);
        executionTimeStreamVersion = config.getFirstProperty(APIConstants.API_EXECUTION_TIME_STREAM_VERSION);

        alertTypeStreamName = config.getFirstProperty(APIConstants.API_ALERT_TYPES_STREAM_NAME);
        alertTypeStreamVersion = config.getFirstProperty(APIConstants.API_ALERT_TYPES_STREAM_VERSION);
        if (alertTypeStreamName == null || alertTypeStreamVersion == null) {
            log.error("Execution Time stream name or version is null. Check api-manager.xml");
        }

        dasReceiverUrlGroups = config.getFirstProperty(APIConstants.API_USAGE_BAM_SERVER_URL_GROUPS);
        dasReceiverAuthUrlGroups = config.getFirstProperty(APIConstants.API_USAGE_BAM_SERVER_AUTH_URL_GROUPS);
        dasReceiverServerUser = config.getFirstProperty(APIConstants.API_USAGE_BAM_SERVER_USER);
        dasReceiverServerPassword = config.getFirstProperty(APIConstants.API_USAGE_BAM_SERVER_PASSWORD);

        dasServerUrl = config.getFirstProperty(APIConstants.API_USAGE_DAS_REST_API_URL);
        dasServerUser = config.getFirstProperty(APIConstants.API_USAGE_DAS_REST_API_USER);
        dasServerPassword = config.getFirstProperty(APIConstants.API_USAGE_DAS_REST_API_PASSWORD);
        String build = config.getFirstProperty(APIConstants.API_USAGE_BUILD_MSG);
        buildMsg = build != null && JavaUtils.isTrueExplicitly(build);
        datacenterId = System.getProperty("datacenterId");
    }
}