Java Code Examples for org.apache.axis2.context.ConfigurationContext

The following examples show how to use org.apache.axis2.context.ConfigurationContext. These examples are extracted from open source projects. 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 Project: carbon-identity   Source File: IWAUIAuthenticator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param request
 * @return
 * @throws AxisFault
 */
private IWAAuthenticatorStub getIWAClient(HttpServletRequest request)
        throws AxisFault, IdentityException {

    HttpSession session = request.getSession();
    ServletContext servletContext = session.getServletContext();
    String backendServerURL = request.getParameter("backendURL");
    if (backendServerURL == null) {
        backendServerURL = CarbonUIUtil.getServerURL(servletContext, request.getSession());
    }

    ConfigurationContext configContext = (ConfigurationContext) servletContext
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);

    String serviceEPR = backendServerURL + "IWAAuthenticator";
    IWAAuthenticatorStub stub = new IWAAuthenticatorStub(configContext, serviceEPR);
    ServiceClient client = stub._getServiceClient();
    client.engageModule("rampart");
    Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
    Policy signOnly = IdentityBaseUtil.getSignOnlyPolicy();
    Policy mergedPolicy = signOnly.merge(rampartConfig);
    Options options = client.getOptions();
    options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, mergedPolicy);
    options.setManageSession(true);
    return stub;
}
 
Example 2
Source Project: micro-integrator   Source File: SecureSample.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    String epr = "https://" + HOST_IP + ":" + HOST_HTTPS_PORT + "/services/samples/SecureDataService";
    System.setProperty("javax.net.ssl.trustStore", (new File(CLIENT_JKS_PATH)).getAbsolutePath());
    ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    SecureDataServiceStub stub = new SecureDataServiceStub(ctx, epr);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    client.engageModule("rampart");
    options.setUserName("admin");
    options.setPassword("admin");

    options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(SECURITY_POLICY_PATH));
    Office[] offices = stub.showAllOffices();
    for (Office office : offices) {
        System.out.println("\t-----------------------------");
        System.out.println("\tOffice Code: " + office.getOfficeCode());
        System.out.println("\tPhone: " + office.getPhone());
        System.out.println("\tAddress Line 1: " + office.getAddressLine1());
        System.out.println("\tAddress Line 2: " + office.getAddressLine2());
        System.out.println("\tCity: " + office.getCity());
        System.out.println("\tState: " + office.getState());
        System.out.println("\tPostal Code: " + office.getPostalCode());
        System.out.println("\tCountry: " + office.getCountry());
    }
}
 
Example 3
Source Project: carbon-apimgt   Source File: APIGatewayAdminClientTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test(expected = AxisFault.class)
public void testDeleteDefaultApiException() throws Exception {

    PowerMockito.whenNew(APIGatewayAdminStub.class)
            .withArguments(Mockito.any(ConfigurationContext.class), Mockito.anyString())
            .thenReturn(apiGatewayAdminStub);
    Mockito.when(
            apiGatewayAdminStub.deleteDefaultApi(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
            .thenThrow(Exception.class);
    Mockito.when(apiGatewayAdminStub
            .deleteDefaultApiForTenant(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
                    Mockito.anyString())).thenThrow(Exception.class);
    APIIdentifier identifier = new APIIdentifier("P1_API1_v1.0.0");
    APIGatewayAdminClient client = new APIGatewayAdminClient(environment);
    client.deleteDefaultApi("", identifier);
    client.deleteDefaultApi("tenant", identifier);
}
 
Example 4
public void createdConfigurationContext(ConfigurationContext configurationContext) {

//		int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
//        try {
//        	PrivilegedCarbonContext.startTenantFlow();
//        	PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);

//            AxisConfiguration axisConfigOfCurrentTenant = configurationContext.getAxisConfiguration();
//            DeploymentEngine axisDeploymentEngine =
//                    (DeploymentEngine)axisConfigOfCurrentTenant.getConfigurator();
//            
//            DBDeployer dbDeployer = new DBDeployer();
//            dbDeployer.setDirectory(DBConstants.DB_SERVICE_REPO_VALUE);
//            dbDeployer.setExtension(DBConstants.DB_SERVICE_EXTENSION_VALUE);
//            axisDeploymentEngine.addDeployer(dbDeployer, dbDeployer.getRepoDir(),
//                    dbDeployer.getExtension());
//        } catch (Exception e) {
//            log.error("Error in setting tenant details ", e);
//        } finally {
//        	PrivilegedCarbonContext.endTenantFlow();
//        }
    }
 
Example 5
Source Project: micro-integrator   Source File: Authenticator.java    License: Apache License 2.0 6 votes vote down vote up
private boolean authenticate() throws Exception {
    ConfigurationContext configurationContext;
    configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
    Map<String, TransportOutDescription> transportsOut = configurationContext.getAxisConfiguration()
            .getTransportsOut();
    for (TransportOutDescription transportOutDescription : transportsOut.values()) {
        transportOutDescription.getSender().init(configurationContext, transportOutDescription);
    }
    boolean isAuthenticated = false;
    if (StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(password)) {
        //if authorized cookie is not available authorize using credentials
        AuthenticationAdminStub authAdmin = new AuthenticationAdminStub(configurationContext, serverUrl);
        isAuthenticated = authAdmin.login(userName, password, "localhost");
        cookie = (String) authAdmin._getServiceClient().getServiceContext()
                .getProperty(HTTPConstants.COOKIE_STRING);
        authAdmin._getServiceClient().cleanupTransport();
    } else if (StringUtils.isNotEmpty(authorizedCookie)) {
        //when authorized cookie is available assign it to local variable
        isAuthenticated = true;
        cookie = authorizedCookie;
    }
    return isAuthenticated;

}
 
Example 6
Source Project: product-private-paas   Source File: ServiceUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static SubscriptionDomainBean getSubscriptionDomain(ConfigurationContext configurationContext,
        String cartridgeType, String subscriptionAlias, String domain) throws RestAPIException {
    try {
        int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
        SubscriptionDomainBean subscriptionDomain = PojoConverter.populateSubscriptionDomainPojo(
                cartridgeSubsciptionManager.getSubscriptionDomain(tenantId, subscriptionAlias, domain));

        if (subscriptionDomain == null) {
            String message =
                    "Could not find a subscription [domain] " + domain + " for Cartridge [type] " + cartridgeType
                            + " and [alias] " + subscriptionAlias;
            log.error(message);
            throw new RestAPIException(Status.NOT_FOUND, message);
        }

        return subscriptionDomain;

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new RestAPIException(e.getMessage(), e);
    }
}
 
Example 7
Source Project: carbon-apimgt   Source File: TestUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static MessageContext getMessageContext(String context, String version) {
    SynapseConfiguration synCfg = new SynapseConfiguration();
    org.apache.axis2.context.MessageContext axisMsgCtx = new org.apache.axis2.context.MessageContext();
    axisMsgCtx.setIncomingTransportName("http");
    axisMsgCtx.setProperty(Constants.Configuration.TRANSPORT_IN_URL, "/test/1.0.0/search.atom");
    AxisConfiguration axisConfig = new AxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
    MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg,
            new Axis2SynapseEnvironment(cfgCtx, synCfg));
    synCtx.setProperty(RESTConstants.REST_API_CONTEXT, context);
    synCtx.setProperty(RESTConstants.SYNAPSE_REST_API_VERSION, version);
    Map map = new TreeMap();
    map.put(X_FORWARDED_FOR, "127.0.0.1,1.10.0.4");
    ((Axis2MessageContext) synCtx).getAxis2MessageContext()
            .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map);
    return synCtx;
}
 
Example 8
Source Project: product-private-paas   Source File: ServiceUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static ConfigurationContext getConfigContext() {

        // If a tenant has been set, then try to get the ConfigurationContext of that tenant
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext
                .getOSGiService(ConfigurationContextService.class);
        ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext();
        String domain = carbonContext.getTenantDomain();
        if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) {
            return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext);
        } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
            return mainConfigContext;
        } else {
            throw new UnsupportedOperationException("Tenant domain unidentified. " +
                    "Upstream code needs to identify & set the tenant domain & tenant ID. " +
                    " The TenantDomain SOAP header could be set by the clients or " +
                    "tenant authentication should be carried out.");
        }
    }
 
Example 9
Source Project: carbon-commons   Source File: reportUploadExecutor.java    License: Apache License 2.0 6 votes vote down vote up
private void init(HttpServletRequest request) throws Exception {
    HttpSession session = request.getSession();
    String serverURL = CarbonUIUtil.getServerURL(session.getServletContext(), session);
    ConfigurationContext configContext =
            (ConfigurationContext) session.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

    client = new ReportTemplateClient(configContext, serverURL, cookie);
    Map<String, ArrayList<FileItemData>> fileItemsMap = getFileItemsMap();
    formFieldsMap = getFormFieldsMap();

    images = fileItemsMap.get("logo");

    String type = null;
    if(formFieldsMap.get("reportType") != null){
       type = formFieldsMap.get("reportType").get(0);
    }

    if(type == null){
      tableReport= (TableReportDTO)session.getAttribute("table-report");
    }
    else {
      chartReport = (ChartReportDTO)session.getAttribute("chart-report");
    }
}
 
Example 10
Source Project: micro-integrator   Source File: SynapseAppDeployer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Function to add synapse deployer
 *
 * @param type     artifact type that deployed by the deployer
 * @param deployer deployer implementation
 */
private void addSynapseDeployer(String type, Deployer deployer) {
    ConfigurationContext configContext =
            ConfigurationHolder.getInstance().getAxis2ConfigurationContextService().getServerConfigContext();
    if (deployer == null) {
        log.error("Failed to add Deployer : deployer is null");
        return;
    }
    if (configContext != null) {
        // Initialize and register Deployer
        deployer.init(configContext);
        registerSynapseDeployer(configContext.getAxisConfiguration(), type, deployer);
    } else {
        log.warn("ConfigurationContext has not been set. Deployer: " +
                 deployer.getClass() + "is not initialized");
    }
    synapseDeployers.put(type, deployer);
}
 
Example 11
Source Project: carbon-commons   Source File: AbstractTracingHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Appends SOAP message metadata to a message buffer
 *
 * @param configCtx  The server ConfigurationContext
 * @param serviceName  The service name
 * @param operationName  The operation name
 * @param msgSeq The message sequence. Use -1 if unknown.
 */
protected void appendMessage(ConfigurationContext configCtx,
                             String serviceName,
                             String operationName,
                             Long msgSeq) {
    CircularBuffer<MessageInfo> buffer =
        (CircularBuffer<MessageInfo>) configCtx.getProperty(TracerConstants.MSG_SEQ_BUFFER);
    if (buffer == null){
        buffer = new CircularBuffer<MessageInfo>(TracerConstants.MSG_BUFFER_SZ);
        configCtx.setProperty(TracerConstants.MSG_SEQ_BUFFER, buffer);
    }
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(new Date());
    MessageInfo messageInfo = new MessageInfo();
    messageInfo.setMessageSequence(msgSeq);
    messageInfo.setOperationName(operationName);
    messageInfo.setServiceId(serviceName);
    messageInfo.setTimestamp(cal);
    buffer.append(messageInfo);
}
 
Example 12
/**
 * 
 * @param backendServerURL
 * @param session
 * @return
 * @throws AxisFault
 */
private LoggedUserInfoAdminStub getLoggedUserInfoAdminStub(String backendServerURL,
        HttpSession session) throws AxisFault {

    ServletContext servletContext = session.getServletContext();
    ConfigurationContext configContext = (ConfigurationContext) servletContext
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);

    if (configContext == null) {
        String msg = "Configuration context is null.";
        log.error(msg);
        throw new AxisFault(msg);
    }

    return new LoggedUserInfoAdminStub(configContext, backendServerURL + "LoggedUserInfoAdmin");
}
 
Example 13
Source Project: carbon-identity   Source File: Authenticator.java    License: Apache License 2.0 6 votes vote down vote up
private boolean authenticate() throws Exception {
    ConfigurationContext configurationContext;
    configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
    Map<String, TransportOutDescription> transportsOut =configurationContext
            .getAxisConfiguration().getTransportsOut();
    for (TransportOutDescription transportOutDescription : transportsOut.values()) {
        transportOutDescription.getSender().init(configurationContext, transportOutDescription);
    }
    AuthenticationAdminStub authAdmin = new AuthenticationAdminStub(configurationContext,
            serverUrl);
    boolean isAuthenticated = authAdmin.login(userName, password, "localhost");
    cookie = (String) authAdmin._getServiceClient().getServiceContext()
            .getProperty(HTTPConstants.COOKIE_STRING);
    authAdmin._getServiceClient().cleanupTransport();
    return isAuthenticated;

}
 
Example 14
Source Project: carbon-apimgt   Source File: APISynchronizer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Method to load the configurations of a tenant
 */
private void loadTenant(String username) {
    String tenantDomain = MultitenantUtils.getTenantDomain(username);
    PrivilegedCarbonContext.startTenantFlow();
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        ConfigurationContext context = ServiceDataHolder.getInstance().getConfigurationContextService()
                .getServerConfigContext();
        TenantAxisUtils.getTenantAxisConfiguration(tenantDomain, context);
        if (log.isDebugEnabled()) {
            log.debug("Tenant was loaded into Carbon Context. Tenant : " + tenantDomain
                    + ", Username : " + username);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Skipping loading super tenant space since execution is currently in super tenant flow.");
        }
    }
}
 
Example 15
Source Project: micro-integrator   Source File: InfoProcessor.java    License: Apache License 2.0 6 votes vote down vote up
public void process(CarbonHttpRequest request,
                    CarbonHttpResponse response,
                    ConfigurationContext configurationContext) throws Exception {
    String requestURI = request.getRequestURI();
    String contextPath = configurationContext.getServiceContextPath();
    String serviceName =
            requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    AxisService axisService =
            configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
    if (!RequestProcessorUtil.canExposeServiceMetadata(axisService)) {
        response.setError(HttpStatus.SC_FORBIDDEN,
                          "Access to service metadata for service: " + serviceName +
                          " has been forbidden");
        return;
    }
    String serviceHtml = ServiceHTMLProcessor.printServiceHTML(
            serviceName, configurationContext);
    if (serviceHtml != null) {
        response.setStatus(HttpStatus.SC_OK);
        response.addHeader(HTTP.CONTENT_TYPE, "text/html");
        response.getOutputStream().write(serviceHtml.getBytes());
    }
}
 
Example 16
Source Project: carbon-identity   Source File: UserProfileCient.java    License: Apache License 2.0 6 votes vote down vote up
public UserProfileCient(String cookie, String url,
                        ConfigurationContext configContext) throws java.lang.Exception {
    try {
        this.serviceEndPoint = url + "UserProfileMgtService";
        stub = new UserProfileMgtServiceStub(configContext, serviceEndPoint);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option
                .setProperty(
                        org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING,
                        cookie);
    } catch (java.lang.Exception e) {
        log.error(e);
        throw e;
    }
}
 
Example 17
Source Project: carbon-commons   Source File: CompositeReportProcessor.java    License: Apache License 2.0 6 votes vote down vote up
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws
        Exception {
    String webContext = (String) request.getAttribute(CarbonConstants.WEB_CONTEXT);
    HttpSession session = request.getSession();
    String serverURL = CarbonUIUtil.getServerURL(getServletContext(), session);
    ConfigurationContext configContext =
            (ConfigurationContext) getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

    ReportTemplateClient client;
    String errorString = "";

    client = new ReportTemplateClient(configContext, serverURL, cookie);
    String reportname = request.getParameter("reportName");
    String[] reports = getSubReportsName(request);

    if (reports != null) {
        client.addNewCompositeReport(reports, reportname);
        response.sendRedirect("../reporting_custom/list-reports.jsp?region=region5&item=reporting_list");
    } else {
        errorString = "No reports was sleected to form the composite report";
        request.setAttribute("errorString", errorString);
        response.sendRedirect("../reporting-template/add-composite-report.jsp");
    }
}
 
Example 18
Source Project: product-private-paas   Source File: AbstractAdmin.java    License: Apache License 2.0 6 votes vote down vote up
protected ConfigurationContext getConfigContext() {

        // If a tenant has been set, then try to get the ConfigurationContext of that tenant
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext
                .getOSGiService(ConfigurationContextService.class);
        ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext();
        String domain = carbonContext.getTenantDomain();
        if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) {
            return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext);
        } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
            return mainConfigContext;
        } else {
            throw new UnsupportedOperationException("Tenant domain unidentified. " +
                    "Upstream code needs to identify & set the tenant domain & tenant ID. " +
                    " The TenantDomain SOAP header could be set by the clients or " +
                    "tenant authentication should be carried out.");
        }
    }
 
Example 19
Source Project: attic-stratos   Source File: FileUploadServiceClient.java    License: Apache License 2.0 5 votes vote down vote up
public FileUploadServiceClient(ConfigurationContext ctx,
                               String serverURL,
                               String cookie) throws AxisFault {
    String serviceEPR = serverURL + "FileUploadService";
    stub = new FileUploadServiceStub(ctx, serviceEPR);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    if (cookie != null) {
        options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
    }
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
}
 
Example 20
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
    AxisService axisService = msgContext.getAxisService();

    if (axisService == null || axisService.isClientSide()) {
        return InvocationResponse.CONTINUE;
    }

    // Do not trace messages from admin services
    if (axisService.getParent() != null) {
        if (SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup())) {
            return InvocationResponse.CONTINUE;
        }
    }

    ConfigurationContext configCtx = msgContext.getConfigurationContext();
    TraceFilter traceFilter =
        (TraceFilter) configCtx.getAxisConfiguration().
            getParameter(TracerConstants.TRACE_FILTER_IMPL).getValue();
    if (traceFilter.isFilteredOut(msgContext)) {
        return InvocationResponse.CONTINUE;
    }

    if ((msgContext.getAxisOperation() != null) &&
        (msgContext.getAxisOperation().getName() != null)) {
        String operationName =
            msgContext.getAxisOperation().getName().getLocalPart();
        String serviceName = axisService.getName();

        // Add the message id to the CircularBuffer.
        // We need to track only the IN_FLOW msg, since with that sequence number,
        // we can retrieve all other related messages from the persister.
        appendMessage(msgContext.getConfigurationContext(),
                      serviceName, operationName,
                      storeMessage(serviceName, operationName, msgContext));
    }
    return InvocationResponse.CONTINUE;
}
 
Example 21
Source Project: carbon-commons   Source File: StatisticsAdminClient.java    License: Apache License 2.0 5 votes vote down vote up
public StatisticsAdminClient(String cookie,
                             String backendServerURL,
                             ConfigurationContext configCtx,
                             Locale locale) throws AxisFault {
    String serviceURL = backendServerURL + "StatisticsAdmin";
    bundle = ResourceBundle.getBundle(BUNDLE, locale);

    stub = new StatisticsAdminStub(configCtx, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);            

}
 
Example 22
Source Project: micro-integrator   Source File: MTOMSwAClient.java    License: Apache License 2.0 5 votes vote down vote up
private static ServiceClient createServiceClient() throws AxisFault {
    String repo = getProperty("repository", "client_repo");
    if (repo != null && !"null".equals(repo)) {
        ConfigurationContext configContext =
                ConfigurationContextFactory.
                        createConfigurationContextFromFileSystem(repo,
                                repo + File.separator + "conf" + File.separator + "axis2.xml");
        return new ServiceClient(configContext, null);
    } else {
        return new ServiceClient();
    }
}
 
Example 23
public NDataSourceAdminServiceClient(String cookie, String backendServerURL,
		ConfigurationContext configCtx) throws AxisFault {
	String serviceURL = backendServerURL + "NDataSourceAdmin";
	stub = new NDataSourceAdminStub(configCtx, serviceURL);
	ServiceClient client = stub._getServiceClient();
	Options option = client.getOptions();
	option.setManageSession(true);
	option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
 
Example 24
public SynapseRegistrationsServiceImpl(ServiceRegistration synCfgSvcReg,
                                       ServiceRegistration synEnvSvcReg,
                                       int tenantId,
                                       ConfigurationContext configCtx) {
    this.synapseConfigurationServiceRegistration = synCfgSvcReg;
    this.synapseEnvironmentServiceRegistration = synEnvSvcReg;
    this.tenantId = tenantId;
    this.configCtx = configCtx;
}
 
Example 25
Source Project: micro-integrator   Source File: XsdProcessor.java    License: Apache License 2.0 5 votes vote down vote up
public void process(CarbonHttpRequest request,
                    CarbonHttpResponse response,
                    ConfigurationContext configCtx) throws Exception {
    String requestURI = request.getRequestURI();
    String contextPath = configCtx.getServiceContextPath();
    String serviceName = requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    AxisService axisService =
            configCtx.getAxisConfiguration().getServiceForActivation(serviceName);
    XsdUtil.printXsd(request, response, configCtx, serviceName, axisService);

}
 
Example 26
public static ConfigurationContext getConfigurationContext() {

        if (configurationContextService.getServerConfigContext() == null) {
            return null;
        }
        return configurationContextService.getServerConfigContext();
    }
 
Example 27
@Before
public void init() throws Exception {
    ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
    ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
    configurationContext = Mockito.mock(ConfigurationContext.class);
    PowerMockito.when(serviceReferenceHolder.getContextService()).thenReturn(configurationContextService);
    PowerMockito.when(configurationContextService.getClientConfigContext()).thenReturn(configurationContext);
    serviceClient = Mockito.mock(ServiceClient.class);
    PowerMockito.whenNew(ServiceClient.class).withAnyArguments().thenReturn(serviceClient);
    applicationRegistrationWSWorkflowExecutor = new ApplicationRegistrationWSWorkflowExecutor();
    apiMgtDAO = TestUtils.getApiMgtDAO();
    application = new Application("test", new Subscriber("testUser"));
    application.setCallbackUrl(callBaclURL);
    application.setTier("Unlimited");
    PowerMockito.mockStatic(KeyManagerHolder.class);
    keyManager = Mockito.mock(KeyManager.class);
    KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
    Mockito.when(keyManager.getKeyManagerConfiguration()).thenReturn(keyManagerConfiguration);
    PowerMockito.when(KeyManagerHolder.getKeyManagerInstance("carbon.super", "default")).thenReturn(keyManager);
    OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
    PowerMockito.when(keyManager.createApplication((OAuthAppRequest) Mockito.anyObject())).thenReturn
            (oAuthApplicationInfo);
    OAuthAppRequest oAuthAppRequest = new OAuthAppRequest();
    oAuthAppRequest.setOAuthApplicationInfo(oAuthApplicationInfo);
    workflowDTO = new ApplicationRegistrationWorkflowDTO();
    workflowDTO.setWorkflowReference("1");
    workflowDTO.setApplication(application);
    workflowDTO.setCallbackUrl(callBaclURL);
    workflowDTO.setTenantDomain("carbon.super");
    workflowDTO.setUserName("testUser");
    workflowDTO.setExternalWorkflowReference("testUser");
    workflowDTO.setKeyType("PRODUCTION");
    workflowDTO.setAppInfoDTO(oAuthAppRequest);

}
 
Example 28
public static NDataSourceAdminServiceClient getInstance(ServletConfig config,
		HttpSession session) throws AxisFault {
	String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
	ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
			.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);

	String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
	return new NDataSourceAdminServiceClient(cookie, backendServerURL, configContext);

}
 
Example 29
Source Project: carbon-commons   Source File: WSDL2CodeClient.java    License: Apache License 2.0 5 votes vote down vote up
public WSDL2CodeClient(ConfigurationContext configContext, String backendServerURL,
                       String cookie) throws AxisFault {

    String backendServiceURL = backendServerURL + "WSDL2CodeService";
    stub = new WSDL2CodeServiceStub(configContext, backendServiceURL);
    ServiceClient client = stub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
 
Example 30
Source Project: micro-integrator   Source File: DBDeployer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisService with the given deployment information.
 */
private AxisService processService(DeploymentFileData currentFile,
		AxisServiceGroup axisServiceGroup, ConfigurationContext configCtx)
		throws DataServiceFault {
	/*
		Security Comment
		CurrentFile contains the actual dbs data location in the server. there isn't any input from the user.
	 */
	AxisService axisService = createDBService(currentFile.getAbsolutePath(), configCtx.getAxisConfiguration());
	axisService.setParent(axisServiceGroup);
	axisService.setClassLoader(axisConfig.getServiceClassLoader());
       /* handle services.xml, if exists */
	this.handleTransports(currentFile, axisService);
	return axisService;
}