java.net.ContentHandler#org.apache.axis2.context.ConfigurationContext源码实例Demo

下面列出了java.net.ContentHandler#org.apache.axis2.context.ConfigurationContext 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: carbon-identity   文件: IWAUIAuthenticator.java
/**
 * @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;
}
 
源代码2 项目: micro-integrator   文件: SecureSample.java
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());
    }
}
 
源代码3 项目: carbon-apimgt   文件: APIGatewayAdminClientTest.java
@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);
}
 
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();
//        }
    }
 
源代码5 项目: micro-integrator   文件: Authenticator.java
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;

}
 
源代码6 项目: product-private-paas   文件: ServiceUtils.java
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);
    }
}
 
源代码7 项目: carbon-apimgt   文件: TestUtils.java
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;
}
 
源代码8 项目: product-private-paas   文件: ServiceUtils.java
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.");
        }
    }
 
源代码9 项目: carbon-commons   文件: reportUploadExecutor.java
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");
    }
}
 
源代码10 项目: micro-integrator   文件: SynapseAppDeployer.java
/**
 * 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);
}
 
源代码11 项目: carbon-commons   文件: AbstractTracingHandler.java
/**
 * 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);
}
 
/**
 * 
 * @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");
}
 
源代码13 项目: carbon-identity   文件: Authenticator.java
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;

}
 
源代码14 项目: carbon-apimgt   文件: APISynchronizer.java
/**
 * 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.");
        }
    }
}
 
源代码15 项目: micro-integrator   文件: InfoProcessor.java
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());
    }
}
 
源代码16 项目: carbon-identity   文件: UserProfileCient.java
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;
    }
}
 
源代码17 项目: carbon-commons   文件: CompositeReportProcessor.java
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");
    }
}
 
源代码18 项目: product-private-paas   文件: AbstractAdmin.java
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.");
        }
    }
 
源代码19 项目: attic-stratos   文件: FileUploadServiceClient.java
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);
}
 
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;
}
 
源代码21 项目: carbon-commons   文件: StatisticsAdminClient.java
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);            

}
 
源代码22 项目: micro-integrator   文件: MTOMSwAClient.java
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();
    }
}
 
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);
}
 
public SynapseRegistrationsServiceImpl(ServiceRegistration synCfgSvcReg,
                                       ServiceRegistration synEnvSvcReg,
                                       int tenantId,
                                       ConfigurationContext configCtx) {
    this.synapseConfigurationServiceRegistration = synCfgSvcReg;
    this.synapseEnvironmentServiceRegistration = synEnvSvcReg;
    this.tenantId = tenantId;
    this.configCtx = configCtx;
}
 
源代码25 项目: micro-integrator   文件: XsdProcessor.java
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);

}
 
public static ConfigurationContext getConfigurationContext() {

        if (configurationContextService.getServerConfigContext() == null) {
            return null;
        }
        return configurationContextService.getServerConfigContext();
    }
 
@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);

}
 
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);

}
 
源代码29 项目: carbon-commons   文件: WSDL2CodeClient.java
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);
}
 
源代码30 项目: micro-integrator   文件: DBDeployer.java
/**
 * 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;
}