Java Code Examples for org.apache.axis2.client.Options#setManageSession()

The following examples show how to use org.apache.axis2.client.Options#setManageSession() . 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: SecurityAdminClient.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public SecurityAdminClient(String cookie, String url, ConfigurationContext configContext)
        throws java.lang.Exception {

    try {
        String serviceEndPoint = url + "SecurityAdminService";
        this.stub = new SecurityAdminServiceStub(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("Error in creating SecurityAdminClient", e);
        throw e;
    }
}
 
Example 2
Source File: ApplicationManagementServiceClient.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * @param cookie
 * @param backendServerURL
 * @param configCtx
 * @throws AxisFault
 */
public ApplicationManagementServiceClient(String cookie, String backendServerURL,
                                          ConfigurationContext configCtx) throws AxisFault {

    String serviceURL = backendServerURL + "IdentityApplicationManagementService";
    String userAdminServiceURL = backendServerURL + "UserAdmin";
    stub = new IdentityApplicationManagementServiceStub(configCtx, serviceURL);
    userAdminStub = new UserAdminStub(configCtx, userAdminServiceURL);

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

    ServiceClient userAdminClient = userAdminStub._getServiceClient();
    Options userAdminOptions = userAdminClient.getOptions();
    userAdminOptions.setManageSession(true);
    userAdminOptions.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

    if (debugEnabled) {
        log.debug("Invoking service " + serviceURL);
    }

}
 
Example 3
Source File: AuthenticationAdminClient.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public boolean login(HttpServletRequest request, String username, String password) throws java.lang.Exception {
    log.info("Logging into " + backendServerURL);
    Login loginRequest = new Login();
    loginRequest.setUsername(username);
    loginRequest.setPassword(password);
    loginRequest.setRemoteAddress(request.getRemoteAddr());
    Options option = stub._getServiceClient().getOptions();
    option.setManageSession(true);
    boolean isLoggedIn = false;
    try {
        isLoggedIn = stub.login(username, password, request.getRemoteAddr());
        if (isLoggedIn) {
            String cookie =
                    (String) stub._getServiceClient().getServiceContext().
                            getProperty(HTTPConstants.COOKIE_STRING);
            HttpSession session = request.getSession();
            session.setAttribute(ServerConstants.ADMIN_SERVICE_COOKIE, cookie);
        }
    } catch (java.lang.Exception e) {
        String msg = MessageFormat.format(bundle.getString("cannot.login.to.server"),
                                          backendServerURL);
        handleException(msg, e);
    }

    return isLoggedIn;
}
 
Example 4
Source File: UserRegistrationAdminServiceClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public UserRegistrationAdminServiceClient() throws AxisFault {

        StringBuilder builder = new StringBuilder();
        String serviceURL = null;

        serviceURL = builder.append(TenantDataManager.getPropertyValue(Constants.SERVICES_URL)).append
                (Constants.UserRegistrationConstants.USER_REGISTRATION_SERVICE).toString().replaceAll("(?<!(http:|https:))//", "/");

        stub = new UserRegistrationAdminServiceStub(serviceURL);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
    }
 
Example 5
Source File: EventingAdminClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param cookie
 * @param backendServerURL
 * @param configCtx
 * @throws AxisFault
 */
public EventingAdminClient(String cookie, String backendServerURL,
		ConfigurationContext configCtx) throws AxisFault {
	String serviceURL = backendServerURL + "EventingAdminService";
	stub = new EventingAdminServiceStub(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 6
Source File: UserRegistrationAdminServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public UserRegistrationAdminServiceClient() throws AxisFault {

        StringBuilder builder = new StringBuilder();
        String serviceURL = null;

        serviceURL = builder.append(TenantDataManager.getPropertyValue(Constants.SERVICES_URL)).append
                (Constants.UserRegistrationConstants.USER_REGISTRATION_SERVICE).toString().replaceAll("(?<!(http:|https:))//", "/");

        stub = new UserRegistrationAdminServiceStub(serviceURL);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
    }
 
Example 7
Source File: HumanTaskClientAPIServiceClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public HumanTaskClientAPIServiceClient(String cookie, String backendServerURL, ConfigurationContext configContext)
        throws AxisFault {
    String serviceURL = backendServerURL + HumanTaskSampleConstants.TASK_OPERATIONS_SERVICE;
    stub = new HumanTaskClientAPIAdminStub(configContext, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
 
Example 8
Source File: ReportTemplateClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public ReportTemplateClient(ConfigurationContext configCtx, String backendServerURL, String cookie) throws Exception{
	String serviceURL = backendServerURL + "ReportTemplateAdmin";
       stub = new ReportTemplateAdminStub(configCtx, serviceURL);
       ServiceClient client = stub._getServiceClient();
       Options options = client.getOptions();
       options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
       options.setManageSession(true);
       options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

}
 
Example 9
Source File: ServiceAuthenticator.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public void authenticate(ServiceClient client) throws AuthenticationException {

        if (accessUsername != null && accessPassword != null) {
            Options option = client.getOptions();
            HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
            auth.setUsername(accessUsername);
            auth.setPassword(accessPassword);
            auth.setPreemptiveAuthentication(true);
            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
            option.setManageSession(true);

        } else {
            throw new AuthenticationException("Authentication username or password not set");
        }
    }
 
Example 10
Source File: EntitlementServiceClient.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 EntitlementService is running.
 * @param configCtx        ConfigurationContext
 * @throws org.apache.axis2.AxisFault
 */
public EntitlementServiceClient(String cookie, String backendServerURL,
                                ConfigurationContext configCtx) throws AxisFault {
    String serviceURL = backendServerURL + "EntitlementService";
    stub = new EntitlementServiceStub(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 11
Source File: UserAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public UserAdminClient(String cookie, String url, String serviceName,
        ConfigurationContext configContext) throws java.lang.Exception {
    try {
        stub = new UserAdminStub(configContext, url + serviceName);
        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);


        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example 12
Source File: WSRealmTenantManager.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    try {
        synchronized (stub) {
            String sessionCookie = login();
            ServiceClient client = stub._getServiceClient();
            Options option = client.getOptions();
            option.setManageSession(true);
            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING,
                    sessionCookie);
        }
    } catch (UserStoreException e) {
        log.error(ERROR_MESSAGE, e);
    }
}
 
Example 13
Source File: EntitlementServiceStubFactory.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
public Object makeObject() throws Exception {
    EntitlementServiceStub stub = new EntitlementServiceStub(configurationContext, targetEndpoint);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
    return stub;
}
 
Example 14
Source File: SecurityAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public SecurityAdminClient(String cookie, String url, ConfigurationContext configContext)
        throws java.lang.Exception {
    try {
        String serviceEndPoint = url + "SecurityAdminService";
        this.stub = new SecurityAdminServiceStub(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("Error in creating SecurityAdminClient", e);
        throw e;
    }
}
 
Example 15
Source File: ReportResourceSupplierClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public ReportResourceSupplierClient(String cookie,
                                   String backEndServerURL,
                                   ConfigurationContext configCtx
                                   ) throws AxisFault {
    String serviceURL = backEndServerURL + "ReportingResourcesSupplier";


    stub = new ReportingResourcesSupplierStub(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 16
Source File: ApplicationAdminClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public ApplicationAdminClient(String cookie,
                          String backendServerURL,
                          ConfigurationContext configCtx,
                          Locale locale) throws AxisFault {
    String serviceURL = backendServerURL + "ApplicationAdmin";
    bundle = ResourceBundle.getBundle(BUNDLE, locale);

    stub = new ApplicationAdminStub(configCtx, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
    option.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
}
 
Example 17
Source File: RemoteUserManagerClient.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
public RemoteUserManagerClient(String cookie) throws APIManagementException {

		APIManagerConfiguration config = ServiceReferenceHolder.getInstance()
		                                                       .getAPIManagerConfigurationService()
		                                                       .getAPIManagerConfiguration();
		String serviceURL = config.getFirstProperty(APIConstants.AUTH_MANAGER_URL);
		String username = config.getFirstProperty(APIConstants.AUTH_MANAGER_USERNAME);
		String password = config.getFirstProperty(APIConstants.AUTH_MANAGER_PASSWORD);
		if (serviceURL == null || username == null || password == null) {
			throw new APIManagementException("Required connection details for authentication");
		}
		
		try {

			String clientRepo = CarbonUtils.getCarbonHome() + File.separator + "repository" +
                    File.separator + "deployment" + File.separator + "client";
			String clientAxisConf = CarbonUtils.getCarbonHome() + File.separator + "repository" +
                    File.separator + "conf" + File.separator + "axis2"+ File.separator +"axis2_client.xml";
			
			ConfigurationContext configContext = ConfigurationContextFactory. createConfigurationContextFromFileSystem(clientRepo,clientAxisConf);
			userStoreManagerStub = new RemoteUserStoreManagerServiceStub(configContext, serviceURL +
			                                                                   "RemoteUserStoreManagerService");
			ServiceClient svcClient = userStoreManagerStub._getServiceClient();
			CarbonUtils.setBasicAccessSecurityHeaders(username, password, svcClient);
			Options options = svcClient.getOptions();
			options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS);
			options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS);
			options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS);
			options.setCallTransportCleanup(true);
			options.setManageSession(true);		
			options.setProperty(HTTPConstants.COOKIE_STRING, cookie);	
		
		} catch (AxisFault axisFault) {
			throw new APIManagementException(
			                                 "Error while initializing the remote user store manager stub",
			                                 axisFault);
		}
	}
 
Example 18
Source File: UserManagementWorkflowServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param cookie
 * @param backendServerURL
 * @param configCtx
 * @throws org.apache.axis2.AxisFault
 */
public UserManagementWorkflowServiceClient(String cookie, String backendServerURL,
                                           ConfigurationContext configCtx) throws AxisFault {

    String serviceURL = backendServerURL + "UserManagementWorkflowService";
    stub = new UserManagementWorkflowServiceStub(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 19
Source File: DTPBatchRequestSampleTestcase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = {"wso2.dss"}, dependsOnMethods = "testServiceDeployment")
public void testDTPWithBatchRequests() throws DataServiceFault, RemoteException {
    DTPSampleServiceStub stub = new DTPSampleServiceStub(serverEpr);
    stub._getServiceClient().getOptions().setManageSession(true);
    stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);

    //Add two accounts to Bank 1
    Entry[] entry1_1 = stub.addAccountToBank1(1000.00);
    Entry[] entry1_2 = stub.addAccountToBank1(1000.00);
    //Add an account to Bank 2
    Entry[] entry2 = stub.addAccountToBank2(2000.00);

    ServiceClient sender = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(serverEpr));
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
    options.setManageSession(true);
    sender.setOptions(options);
    
    options.setAction("urn:" + "begin_boxcar");
    sender.setOptions(options);
    sender.sendRobust(begin_boxcar());
    

    //Send a batch request to Bank 1 to update two accounts
    OMElement payload = createBatchRequestPayload(entry1_1[0].getID().intValue(), entry1_2[0].getID().intValue());
    options.setAction("urn:" + "addToAccountBalanceInBank1_batch_req");
    sender.setOptions(options);
    sender.sendRobust(payload);
             

    //this line will cases dss fault due to service input parameter validation
    payload = createAccountUpdatePayload(entry2[0].getID().intValue());
    options.setAction("urn:" + "addToAccountBalanceInBank2");
    sender.setOptions(options);
    sender.sendRobust(payload);

    try {
    	options.setAction("urn:" + "end_boxcar");
        sender.setOptions(options);
    	sender.sendRobust(end_boxcar());
    } catch (AxisFault dssFault) {
        log.error("DSS fault ignored");
    }

    assertEquals(stub.getAccountBalanceFromBank1(entry1_1[0].getID().intValue()), 1000.00);
    assertEquals(stub.getAccountBalanceFromBank1(entry1_2[0].getID().intValue()), 1000.00);
    assertEquals(stub.getAccountBalanceFromBank2(entry2[0].getID().intValue()), 2000.00);
}
 
Example 20
Source File: DTPBatchRequestSampleTestcase.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@Test(groups = { "wso2.dss" }, dependsOnMethods = "testServiceDeployment")
public void testDTPWithBatchRequests() throws DataServiceFault, RemoteException {
    DTPSampleServiceStub stub = new DTPSampleServiceStub(serverEpr);
    stub._getServiceClient().getOptions().setManageSession(true);
    stub._getServiceClient().getOptions()
            .setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);

    //Add two accounts to Bank 1
    Entry[] entry1_1 = stub.addAccountToBank1(1000.00);
    Entry[] entry1_2 = stub.addAccountToBank1(1000.00);
    //Add an account to Bank 2
    Entry[] entry2 = stub.addAccountToBank2(2000.00);

    ServiceClient sender = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(serverEpr));
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
    options.setManageSession(true);
    sender.setOptions(options);

    options.setAction("urn:" + "begin_boxcar");
    sender.setOptions(options);
    sender.sendRobust(begin_boxcar());

    //Send a batch request to Bank 1 to update two accounts
    OMElement payload = createBatchRequestPayload(entry1_1[0].getID().intValue(), entry1_2[0].getID().intValue());
    options.setAction("urn:" + "addToAccountBalanceInBank1_batch_req");
    sender.setOptions(options);
    sender.sendRobust(payload);

    //this line will cases dss fault due to service input parameter validation
    payload = createAccountUpdatePayload(entry2[0].getID().intValue());
    options.setAction("urn:" + "addToAccountBalanceInBank2");
    sender.setOptions(options);
    sender.sendRobust(payload);

    try {
        options.setAction("urn:" + "end_boxcar");
        sender.setOptions(options);
        sender.sendRobust(end_boxcar());
    } catch (AxisFault dssFault) {
        log.error("DSS fault ignored");
    }

    assertEquals(stub.getAccountBalanceFromBank1(entry1_1[0].getID().intValue()), 1000.00);
    assertEquals(stub.getAccountBalanceFromBank1(entry1_2[0].getID().intValue()), 1000.00);
    assertEquals(stub.getAccountBalanceFromBank2(entry2[0].getID().intValue()), 2000.00);
}