Java Code Examples for org.wso2.carbon.identity.entitlement.stub.EntitlementServiceStub#_getServiceClient

The following examples show how to use org.wso2.carbon.identity.entitlement.stub.EntitlementServiceStub#_getServiceClient . 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: 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 2
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 3
Source File: EntitlementServiceClient.java    From carbon-identity 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 4
Source File: EntitlementServiceStubFactory.java    From carbon-identity 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 5
Source File: EntitlementServiceClient.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * This method will initiate entitlement service client which calls PDP
 *
 * @throws Exception whenever if failed to initiate client properly.
 */
public EntitlementServiceClient() throws Exception {
    ConfigurationContext configContext;
    try {
        String repositoryBasePath = CarbonUtils.getCarbonHome() + File.separator + "repository";
        String clientRepo = repositoryBasePath +
                File.separator + "deployment" + File.separator + "client";
        String clientAxisConf = repositoryBasePath +
                File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2_client.xml";

        configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientRepo, clientAxisConf);
        String serviceEndPoint = EntitlementClientUtils.getServerUrl() + "EntitlementService";
        entitlementServiceStub =
                new EntitlementServiceStub(configContext, serviceEndPoint);
        ServiceClient client = entitlementServiceStub._getServiceClient();
        Options option = client.getOptions();
        option.setProperty(HTTPConstants.COOKIE_STRING, null);
        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
        auth.setUsername(EntitlementClientUtils.getServerUsername());
        auth.setPassword(EntitlementClientUtils.getServerPassword());
        auth.setPreemptiveAuthentication(true);
        option.setProperty(HTTPConstants.AUTHENTICATE, auth);
        option.setManageSession(true);
    } catch (Exception e) {
        logger.error("Error while initiating entitlement service client ", e);
    }
}