org.apache.axis2.context.ConfigurationContext Java Examples

The following examples show how to use org.apache.axis2.context.ConfigurationContext. 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: APIGatewayAdminClientTest.java    From carbon-apimgt with 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 #2
Source File: ServiceUtils.java    From product-private-paas with 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 #3
Source File: reportUploadExecutor.java    From carbon-commons with 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 #4
Source File: TestUtils.java    From carbon-apimgt with 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 #5
Source File: DSAxis2ConfigurationContextObserver.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: APISynchronizer.java    From carbon-apimgt with 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 #7
Source File: InfoProcessor.java    From micro-integrator with 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 #8
Source File: SynapseAppDeployer.java    From micro-integrator with 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 #9
Source File: Authenticator.java    From carbon-identity with 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 #10
Source File: UserProfileCient.java    From carbon-identity with 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 #11
Source File: ServiceUtils.java    From product-private-paas with 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 #12
Source File: Authenticator.java    From micro-integrator with 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 #13
Source File: SecureSample.java    From micro-integrator with 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 #14
Source File: AbstractTracingHandler.java    From carbon-commons with 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 #15
Source File: CompositeReportProcessor.java    From carbon-commons with 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 #16
Source File: AbstractAdmin.java    From product-private-paas with 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 #17
Source File: IWAUIAuthenticator.java    From carbon-identity with 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 #18
Source File: AbstractCarbonUIAuthenticator.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @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 #19
Source File: ApplicationCreationWSWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testWorkflowExecuteFailWhenMessageProcessingFailed() throws Exception {
	ApplicationWorkflowDTO workflowDTO = new ApplicationWorkflowDTO();
	PowerMockito.mockStatic(AXIOMUtil.class);
	PowerMockito.when(AXIOMUtil.stringToOM(Mockito.anyString())).thenThrow(new XMLStreamException("Error " +
			"converting String to OMElement"));
	Application application = new Application("TestAPP", new Subscriber(null));

	application.setTier("Gold");
	application.setCallbackUrl("www.wso2.com");
	application.setDescription("Description");
	workflowDTO.setApplication(application);
	workflowDTO.setTenantDomain("wso2");
	workflowDTO.setUserName("admin");
	workflowDTO.setCallbackUrl("http://localhost:8280/workflow-callback");
	workflowDTO.setWorkflowReference("1");
	workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());

	PowerMockito.doNothing().when(apiMgtDAO).updateSubscriptionStatus(
			Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);

	ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
	ServiceReferenceHolderMockCreator.initContextService();

	PowerMockito.whenNew(ServiceClient.class)
			.withArguments(Mockito.any(ConfigurationContext.class), Mockito.any(AxisService.class))
			.thenReturn(serviceClient);
	try {
		applicationCreationWSWorkflowExecutor.execute(workflowDTO);
		Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
	} catch (WorkflowException e) {
		Assert.assertEquals(e.getMessage(), "Error converting String to OMElement");
	}
}
 
Example #20
Source File: DefaultAuthenticationSeqMgtServiceClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public DefaultAuthenticationSeqMgtServiceClient(String cookie, String backendServerURL,
                                                ConfigurationContext configCtx) throws Exception {

    String serviceURL = backendServerURL + "IdentityDefaultSeqManagementService";
    stub = new IdentityDefaultSeqManagementServiceStub(configCtx, serviceURL);

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

    if (log.isDebugEnabled()) {
        log.debug("Invoking service " + serviceURL);
    }
}
 
Example #21
Source File: CarbonRemoteUserStoreManger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param realmConfig
 * @param properties
 * @throws Exception
 */
public CarbonRemoteUserStoreManger(RealmConfiguration realmConfig, Map properties)
        throws Exception {

    ConfigurationContext configurationContext = ConfigurationContextFactory
            .createDefaultConfigurationContext();

    Map<String, TransportOutDescription> transportsOut = configurationContext
            .getAxisConfiguration().getTransportsOut();
    for (TransportOutDescription transportOutDescription : transportsOut.values()) {
        transportOutDescription.getSender().init(configurationContext, transportOutDescription);
    }

    String[] serverUrls = realmConfig.getUserStoreProperty(SERVER_URLS).split(",");

    for (int i = 0; i < serverUrls.length; i++) {
        remoteUserStore = new WSUserStoreManager(
                realmConfig.getUserStoreProperty(REMOTE_USER_NAME),
                realmConfig.getUserStoreProperty(PASSWORD), serverUrls[i],
                configurationContext);

        if (log.isDebugEnabled()) {
            log.debug("Remote Servers for User Management : " + serverUrls[i]);
        }

        remoteServers.put(serverUrls[i], remoteUserStore);
    }

    this.realmConfig = realmConfig;
    domainName = realmConfig.getUserStoreProperty(UserStoreConfigConstants.DOMAIN_NAME);
}
 
Example #22
Source File: SAMLSSOConfigServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public SAMLSSOConfigServiceClient(String cookie, String backendServerURL, ConfigurationContext configCtx)
        throws AxisFault {
    try {
        String serviceURL = backendServerURL + "IdentitySAMLSSOConfigService";
        stub = new IdentitySAMLSSOConfigServiceStub(configCtx, serviceURL);
        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
    } catch (AxisFault ex) {
        log.error("Error generating stub for IdentitySAMLSSOConfigService", ex);
        throw new AxisFault("Error generating stub for IdentitySAMLSSOConfigService", ex);
    }
}
 
Example #23
Source File: OAuthServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * OAuth2TokenValidationService Admin Service Client
 *
 * @param backendServerURL
 * @param username
 * @param password
 * @param configCtx
 * @throws Exception
 */
public OAuthServiceClient(String backendServerURL, String username, String password,
                          ConfigurationContext configCtx) throws Exception {
    String serviceURL = backendServerURL + "OAuth2TokenValidationService";
    try {
        stub = new OAuth2TokenValidationServiceStub(configCtx, serviceURL);
        CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, stub._getServiceClient());
    } catch (AxisFault e) {
        log.error("Error initializing OAuth2 Client");
        throw new Exception("Error initializing OAuth Client", e);
    }
}
 
Example #24
Source File: IdentityManagementClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public IdentityManagementClient(String cookie, String url, ConfigurationContext configContext)
        throws java.lang.Exception {
    try {
        stub = new UserIdentityManagementServiceStub(configContext, url + "UserIdentityManagementService");
        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) {
        handleException(e.getMessage(), e);
    }
}
 
Example #25
Source File: SignupObserver.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public void createdConfigurationContext(ConfigurationContext configurationContext) {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    try {
        APIUtil.createSelfSignUpRoles(tenantId);
       
    } catch (APIManagementException e) {
       log.error("Error while adding role for tenant : "+tenantDomain,e);
    }
}
 
Example #26
Source File: EntitlementPolicyAdminServiceClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates EntitlementServiceClient
 *
 * @param cookie           For session management
 * @param backendServerURL URL of the back end server where EntitlementPolicyAdminService is
 *                         running.
 * @param configCtx        ConfigurationContext
 * @throws org.apache.axis2.AxisFault
 */
public EntitlementPolicyAdminServiceClient(String cookie, String backendServerURL,
                                           ConfigurationContext configCtx) throws AxisFault {
    String serviceURL = backendServerURL + "EntitlementPolicyAdminService";
    stub = new EntitlementPolicyAdminServiceStub(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 #27
Source File: WSRealmBuilder.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Method to create WSRealm for non-Carbon environment
 * Recommended method
 */
public static UserRealm createWSRealm(RealmConfiguration realmConfig,
                                      ConfigurationContext configContext)
        throws UserStoreException {
    WSRealm realm = new WSRealm();
    realm.init(realmConfig, configContext);
    return realm;
}
 
Example #28
Source File: XdsTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
protected ServiceClient getRepositoryServiceClient() throws AxisFault {
	ConfigurationContext configctx = getContext();
	ServiceClient sender = new ServiceClient(configctx,null);
	String action = "urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b";
	boolean enableMTOM = true;
	sender.setOptions(getOptions(action, enableMTOM, repositoryUrl));
	sender.engageModule("addressing");			
	return sender;
}
 
Example #29
Source File: FileUploadServiceClient.java    From attic-stratos with 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 #30
Source File: TierCacheInvalidationClientTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws APIManagementException, RemoteException {
    PowerMockito.mockStatic(ServiceReferenceHolder.class);
    PowerMockito.mockStatic(ConfigurationContextFactory.class);
    ServiceReferenceHolder serviceReferenceHolder = Mockito.mock(ServiceReferenceHolder.class);
    APIManagerConfigurationService amConfigService = Mockito.mock(APIManagerConfigurationService.class);
    amConfig = Mockito.mock(APIManagerConfiguration.class);
    configFactory = Mockito.mock(ConfigurationContextFactory.class);
    configurationContext = Mockito.mock(ConfigurationContext.class);
    serviceClient = Mockito.mock(ServiceClient.class);
    authStub = Mockito.mock(AuthenticationAdminStub.class);
    cacheStub = Mockito.mock(TierCacheServiceStub.class);
    OperationContext opContext = Mockito.mock(OperationContext.class);
    ServiceContext serviceContext = Mockito.mock(ServiceContext.class);

    Mockito.when(opContext.getServiceContext()).thenReturn(serviceContext);
    Mockito.when(serviceContext.getProperty(Mockito.anyString())).thenReturn("cookie");
    Mockito.when(authStub._getServiceClient()).thenReturn(serviceClient);
    Mockito.when(cacheStub._getServiceClient()).thenReturn(serviceClient);
    Mockito.when(serviceClient.getLastOperationContext()).thenReturn(opContext);
    Mockito.when(serviceClient.getOptions()).thenReturn(new Options());
    Mockito.when(serviceReferenceHolder.getAPIManagerConfigurationService()).thenReturn(amConfigService);
    Mockito.when(amConfigService.getAPIManagerConfiguration()).thenReturn(amConfig);
    Mockito.when(configFactory.createConfigurationContextFromFileSystem(null, null))
            .thenReturn(configurationContext);
    PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(serviceReferenceHolder);
}