Java Code Examples for org.apache.axis2.description.TransportInDescription#getParameter()

The following examples show how to use org.apache.axis2.description.TransportInDescription#getParameter() . 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: 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 2
Source File: CarbonConnection.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a URL connection to the specified URL. A connection to
 * the object referenced by the URL is not created.
 *
 * @param url     the specified URL.
 * @param context BundleContext
 */
protected CarbonConnection(URL url, BundleContext context) throws Exception {
    super(url);
    ConfigurationContext configContext;
    configContext = CarbonUIServiceComponent
            .getConfigurationContextService().getServerConfigContext();

    TransportInDescription httpsInDescription = configContext.getAxisConfiguration().
            getTransportIn(ServerConstants.HTTPS_TRANSPORT);
    Parameter proxyParameter = httpsInDescription.getParameter("proxyPort");
    String httpsProxyPort = null;
    if (proxyParameter != null && !"-1".equals(proxyParameter.getValue())) {
        httpsProxyPort = (String) proxyParameter.getValue();
    }

    TransportInDescription httpInDescription = configContext.getAxisConfiguration().
            getTransportIn(ServerConstants.HTTP_TRANSPORT);
    if (httpInDescription != null) {
        proxyParameter = httpInDescription.getParameter("proxyPort");
    }
    String httpProxyPort = null;
    if (proxyParameter != null && !"-1".equals(proxyParameter.getValue())) {
        httpProxyPort = (String) proxyParameter.getValue();
    }
    try {
        String servicePath = configContext.getServicePath();
        String contextRoot = configContext.getContextRoot();
        contextRoot = contextRoot.equals("/") ? "" : contextRoot;
        String httpsPort;
        if (httpsProxyPort != null) {
            httpsPort = httpsProxyPort;
        } else {
            httpsPort =
                    CarbonUtils.
                            getTransportPort(CarbonUIServiceComponent.getConfigurationContextService(),
                                             "https") + "";
        }
        String httpPort;
        if (httpProxyPort != null) {
            httpPort = httpProxyPort;
        } else {
            if (httpInDescription != null) {
                httpPort =
                        CarbonUtils.
                                getTransportPort(CarbonUIServiceComponent.getConfigurationContextService(),
                                                 "http") + "";
            } else {
                httpPort = "-1";
            }
        }
        buf = ("var SERVICE_PATH=\"" + servicePath + "\";\n" +
               "var ROOT_CONTEXT=\"" + contextRoot + "\";\n" +
               "var HTTP_PORT=" + httpPort + ";\n" +
               "var HTTPS_PORT=" + httpsPort + ";\n").getBytes();
    } catch (Exception e) {
        String msg = "Error occurred while getting connection properties";
        log.error(msg, e);
    }
}