org.apache.axis2.transport.http.HttpTransportProperties Java Examples

The following examples show how to use org.apache.axis2.transport.http.HttpTransportProperties. 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: RestCommandLineService.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the rest client and set username and password of the user
 *
 * @param serverURL server URL
 * @param username  username
 * @param password  password
 * @throws AxisFault
 */
private void initializeRestClient(String serverURL, String username, String password) throws AxisFault {
    HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
    authenticator.setUsername(username);
    authenticator.setPassword(password);
    authenticator.setPreemptiveAuthentication(true);

    ConfigurationContext configurationContext;
    try {
        configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
    } catch (Exception e) {
        String msg = "Backend error occurred. Please contact the service admins!";
        throw new AxisFault(msg, e);
    }
    HashMap<String, TransportOutDescription> transportsOut = configurationContext
            .getAxisConfiguration().getTransportsOut();
    for (TransportOutDescription transportOutDescription : transportsOut.values()) {
        transportOutDescription.getSender().init(configurationContext, transportOutDescription);
    }

    this.restClient = new RestClient(serverURL, username, password);
}
 
Example #2
Source File: WSUserStoreManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public WSUserStoreManager(String userName, String password, String serverUrl,
                          ConfigurationContext configCtxt) throws UserStoreException {
    try {

        if (serverUrl != null && !serverUrl.endsWith("/")) {
            serverUrl += "/";
        }

        stub = new RemoteUserStoreManagerServiceStub(configCtxt, serverUrl
                + SERVICE_NAME);

        HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
        authenticator.setUsername(userName);
        authenticator.setPassword(password);
        authenticator.setPreemptiveAuthentication(true);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
                authenticator);
    } catch (AxisFault e) {
        handleException(e.getMessage(), e);
    }
}
 
Example #3
Source File: WorkflowDeployerClient.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public WorkflowDeployerClient(String bpsURL, String username, char[] password) throws AxisFault {
    bpelUploaderStub = new BPELUploaderStub(bpsURL + BPEL_UPLOADER_SERVICE);
    ServiceClient serviceClient = bpelUploaderStub._getServiceClient();
    Options options = serviceClient.getOptions();
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername(username);
    auth.setPassword(new String(password));
    auth.setPreemptiveAuthentication(true);
    List<String> authSchemes = new ArrayList<>();
    authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
    auth.setAuthSchemes(authSchemes);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    serviceClient.setOptions(options);

    humanTaskUploaderStub = new HumanTaskUploaderStub(bpsURL + HT_UPLOADER_SERVICE);
    ServiceClient htServiceClient = humanTaskUploaderStub._getServiceClient();
    Options htOptions = htServiceClient.getOptions();
    htOptions.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    htServiceClient.setOptions(htOptions);
}
 
Example #4
Source File: ProcessManagementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public ProcessManagementServiceClient(String bpsURL, String username, char[] password) throws AxisFault {
    stub = new ProcessManagementServiceStub(bpsURL + WFImplConstant.BPS_PROCESS_SERVICES_URL);
    ServiceClient serviceClient = stub._getServiceClient();
    Options options = serviceClient.getOptions();
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername(username);
    auth.setPassword(new String(password));
    auth.setPreemptiveAuthentication(true);
    List<String> authSchemes = new ArrayList<>();
    authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
    auth.setAuthSchemes(authSchemes);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    serviceClient.setOptions(options);
}
 
Example #5
Source File: RemoteTaskManagerFactory.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private static RemoteTaskAdmin getRemoteTaskAdmin() throws TaskException {
    if (remoteTaskAdmin == null) {
        synchronized (RemoteTaskManagerFactory.class) {
            if (remoteTaskAdmin == null) {
                TaskServiceConfiguration serverConfig = TasksDSComponent.getTaskService()
                        .getServerConfiguration();
                String username = serverConfig.getRemoteServerUsername();
                String password = serverConfig.getRemoteServerPassword();
                String taskServerAddress = serverConfig.getRemoteServerAddress();
                try {
                    remoteTaskAdmin = new RemoteTaskAdminStub(taskServerAddress
                            + "/services/RemoteTaskAdmin");
                } catch (AxisFault e) {
                    throw new TaskException(e.getMessage(), Code.UNKNOWN, e);
                }
                HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
                auth.setUsername(username);
                auth.setPassword(password);
                auth.setPreemptiveAuthentication(true);
                remoteTaskAdmin
                        ._getServiceClient()
                        .getOptions()
                        .setProperty(
                                org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
                                auth);
                remoteTaskAdmin._getServiceClient().getOptions().setCallTransportCleanup(true);
            }
        }
    }
    return remoteTaskAdmin;
}
 
Example #6
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 #7
Source File: SubscriptionUpdateWSWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves configured ServiceClient for communication with external services
 *
 * @param action web service action to use
 * @return configured service client
 * @throws AxisFault
 */
public ServiceClient getClient(String action) throws AxisFault {
    ServiceClient client = new ServiceClient(
            ServiceReferenceHolder.getInstance().getContextService().getClientConfigContext(), null);
    Options options = new Options();
    options.setAction(action);
    options.setTo(new EndpointReference(serviceEndpoint));

    if (contentType != null) {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType);
    } else {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
    }

    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();

    // Assumes authentication is required if username and password is given
    if (username != null && !username.isEmpty() && password != null && password.length != 0) {
        auth.setUsername(username);
        auth.setPassword(String.valueOf(password));
        auth.setPreemptiveAuthentication(true);
        List<String> authSchemes = new ArrayList<String>();
        authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
        auth.setAuthSchemes(authSchemes);

        if (contentType == null) {
            options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
        }
        options.setProperty(HTTPConstants.AUTHENTICATE, auth);
        options.setManageSession(true);
    }
    client.setOptions(options);
    return client;
}
 
Example #8
Source File: SubscriptionCreationWSWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves configured ServiceClient for communication with external services
 *
 * @param action web service action to use
 * @return configured service client
 * @throws AxisFault
 */
public ServiceClient getClient(String action) throws AxisFault {
    ServiceClient client = new ServiceClient(
            ServiceReferenceHolder.getInstance().getContextService().getClientConfigContext(), null);
    Options options = new Options();
    options.setAction(action);
    options.setTo(new EndpointReference(serviceEndpoint));

    if (contentType != null) {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType);
    } else {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
    }

    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();

    // Assumes authentication is required if username and password is given
    if (username != null && !username.isEmpty() && password != null && password.length != 0) {
        auth.setUsername(username);
        auth.setPassword(String.valueOf(password));
        auth.setPreemptiveAuthentication(true);
        List<String> authSchemes = new ArrayList<String>();
        authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
        auth.setAuthSchemes(authSchemes);

        if (contentType == null) {
            options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
        }
        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
        options.setManageSession(true);
    }
    client.setOptions(options);

    return client;
}
 
Example #9
Source File: UserSignUpWSWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves configured ServiceClient for communication with external services
 *
 * @param action web service action to use
 * @return configured service client
 * @throws AxisFault
 */
public ServiceClient getClient(String action) throws AxisFault {
    ServiceClient client = new ServiceClient(
            ServiceReferenceHolder.getInstance().getContextService().getClientConfigContext(), null);
    Options options = new Options();
    options.setAction(action);
    options.setTo(new EndpointReference(serviceEndpoint));

    if (contentType != null) {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType);
    } else {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
    }

    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();

    // Assumes authentication is required if username and password is given
    if (username != null && !username.isEmpty() && password != null && password.length != 0) {
        auth.setUsername(username);
        auth.setPassword(String.valueOf(password));
        auth.setPreemptiveAuthentication(true);
        List<String> authSchemes = new ArrayList<String>();
        authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
        auth.setAuthSchemes(authSchemes);

        if (contentType == null) {
            options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
        }
        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
        options.setManageSession(true);
    }
    client.setOptions(options);

    return client;
}
 
Example #10
Source File: ApplicationRegistrationWSWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves configured ServiceClient for communication with external services
 *
 * @param action web service action to use
 * @return configured service client
 * @throws AxisFault
 */
public ServiceClient getClient(String action) throws AxisFault {
    ServiceClient client = new ServiceClient(
            ServiceReferenceHolder.getInstance().getContextService().getClientConfigContext(), null);
    Options options = new Options();
    options.setAction(action);
    options.setTo(new EndpointReference(serviceEndpoint));

    if (contentType != null) {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType);
    } else {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
    }

    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();

    // Assumes authentication is required if username and password is given
    if (username != null && !username.isEmpty() && password != null && password.length != 0) {
        auth.setUsername(username);
        auth.setPassword(String.valueOf(password));
        auth.setPreemptiveAuthentication(true);
        List<String> authSchemes = new ArrayList<String>();
        authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
        auth.setAuthSchemes(authSchemes);

        if (contentType == null) {
            options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
        }
        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
        options.setManageSession(true);
    }
    client.setOptions(options);

    return client;
}
 
Example #11
Source File: ApplicationCreationWSWorkflowExecutor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves configured ServiceClient for communication with external services
 *
 * @param action web service action to use
 * @return configured service client
 * @throws AxisFault
 */
public ServiceClient getClient(String action) throws AxisFault {
    ServiceClient client = new ServiceClient(
            ServiceReferenceHolder.getInstance().getContextService().getClientConfigContext(), null);
    Options options = new Options();
    options.setAction(action);
    options.setTo(new EndpointReference(serviceEndpoint));

    if (contentType != null) {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType);
    } else {
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
    }

    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();

    // Assumes authentication is required if username and password is given
    if (username != null && !username.isEmpty() && password != null && password.length != 0) {
        auth.setUsername(username);
        auth.setPassword(String.valueOf(password));
        auth.setPreemptiveAuthentication(true);
        List<String> authSchemes = new ArrayList<String>();
        authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
        auth.setAuthSchemes(authSchemes);

        if (contentType == null) {
            options.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_TEXT_XML);
        }
        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
        options.setManageSession(true);
    }
    client.setOptions(options);

    return client;
}
 
Example #12
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);
    }
}
 
Example #13
Source File: WSXACMLEntitlementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public WSXACMLEntitlementServiceClient(String serverUrl, String userName, String password) {
    this.serverUrl = serverUrl;
    authenticator = new HttpTransportProperties.Authenticator();
    authenticator.setUsername(userName);
    authenticator.setPassword(password);
    authenticator.setPreemptiveAuthentication(true);
}
 
Example #14
Source File: LoadBalanceSessionFullClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void updateServiceClientOptions(String trpUrl, String addUrl, String prxUrl) throws AxisFault {
    Options options = new Options();
    options.setTo(new EndpointReference(trpUrl));
    options.setAction("urn:sampleOperation");
    options.setTimeOutInMilliSeconds(10000000);

    // set addressing, transport and proxy url
    if (addUrl != null && !"null".equals(addUrl)) {
        serviceClient.engageModule("addressing");
        options.setTo(new EndpointReference(addUrl));
    }
    if (trpUrl != null && !"null".equals(trpUrl)) {
        options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
    } else {
        serviceClient.engageModule("addressing");
    }
    serviceClient.engageModule("addressing");
    if (prxUrl != null && !"null".equals(prxUrl)) {
        HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties();
        try {
            URL url = new URL(prxUrl);
            proxyProperties.setProxyName(url.getHost());
            proxyProperties.setProxyPort(url.getPort());
            proxyProperties.setUserName("");
            proxyProperties.setPassWord("");
            proxyProperties.setDomain("");
            options.setProperty(HTTPConstants.PROXY, proxyProperties);
        } catch (MalformedURLException e) {
            String msg = "Error while creating proxy URL";
            log.error(msg, e);
            throw new AxisFault(msg, e);
        }
    }
    serviceClient.setOptions(options);
}
 
Example #15
Source File: HumanTaskClientAPIAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public HumanTaskClientAPIAdminClient(String bpsURL, String username, char[] password) throws AxisFault {
    stub = new HumanTaskClientAPIAdminStub(bpsURL + WFImplConstant.HT_SERVICES_URL);
    ServiceClient serviceClient = stub._getServiceClient();
    Options options = serviceClient.getOptions();
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername(username);
    auth.setPassword(new String(password));
    auth.setPreemptiveAuthentication(true);
    List<String> authSchemes = new ArrayList<>();
    authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
    auth.setAuthSchemes(authSchemes);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    serviceClient.setOptions(options);
}
 
Example #16
Source File: BPELPackageManagementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public BPELPackageManagementServiceClient(String bpsURL, String username, char[] password) throws AxisFault {
    stub = new BPELPackageManagementServiceStub(bpsURL + WFImplConstant.BPS_PACKAGE_SERVICES_URL);
    ServiceClient serviceClient = stub._getServiceClient();
    Options options = serviceClient.getOptions();
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername(username);
    auth.setPassword(new String(password));
    auth.setPreemptiveAuthentication(true);
    List<String> authSchemes = new ArrayList<>();
    authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
    auth.setAuthSchemes(authSchemes);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    serviceClient.setOptions(options);
}
 
Example #17
Source File: BssClient.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * Ugly hack which only works due to the fact that the session server
 * doesn't verifiy the user's organization role
 * 
 * @param stub
 */
private void setBasicAuth(Stub stub) {
    HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
    basicAuth.setUsername(userKey);
    basicAuth.setPassword(password);
    basicAuth.setPreemptiveAuthentication(true);
    final Options clientOptions = stub._getServiceClient().getOptions();
    clientOptions.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);
}
 
Example #18
Source File: ServiceAuthenticator.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
public void authenticate(ServiceClient client) throws ApplicationManagementException {
    Options option = client.getOptions();
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername(username);
    auth.setPassword(password);
    auth.setPreemptiveAuthentication(true);
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    option.setManageSession(true);
}
 
Example #19
Source File: LoadBalanceSessionFullClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private void updateServiceClientOptions(String trpUrl, String addUrl, String prxUrl) throws AxisFault {
    Options options = new Options();
    options.setTo(new EndpointReference(trpUrl));
    options.setAction("urn:sampleOperation");
    options.setTimeOutInMilliSeconds(10000000);

    // set addressing, transport and proxy url
    if (addUrl != null && !"null".equals(addUrl)) {
        serviceClient.engageModule("addressing");
        options.setTo(new EndpointReference(addUrl));
    }
    if (trpUrl != null && !"null".equals(trpUrl)) {
        options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
    } else {
        serviceClient.engageModule("addressing");
    }
    serviceClient.engageModule("addressing");
    if (prxUrl != null && !"null".equals(prxUrl)) {
        HttpTransportProperties.ProxyProperties proxyProperties =
            new HttpTransportProperties.ProxyProperties();
        try {
            URL url = new URL(prxUrl);
            proxyProperties.setProxyName(url.getHost());
            proxyProperties.setProxyPort(url.getPort());
            proxyProperties.setUserName("");
            proxyProperties.setPassWord("");
            proxyProperties.setDomain("");
            options.setProperty(HTTPConstants.PROXY, proxyProperties);
        } catch (MalformedURLException e) {
            String msg = "Error while creating proxy URL";
            log.error(msg, e);
            throw new AxisFault(msg, e);
        }
    }
    serviceClient.setOptions(options);
}
 
Example #20
Source File: IdentityManagementServiceUtil.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
static void setAutheticationOptions(ServiceClient client, String accessUsername, String accessPassword) {
    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);
}
 
Example #21
Source File: WSXACMLEntitlementServiceClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public WSXACMLEntitlementServiceClient(String serverUrl, String userName, String password) {
    this.serverUrl = serverUrl;
    authenticator = new HttpTransportProperties.Authenticator();
    authenticator.setUsername(userName);
    authenticator.setPassword(password);
    authenticator.setPreemptiveAuthentication(true);
}
 
Example #22
Source File: EntitlementServiceStubFactory.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public EntitlementServiceStubFactory(ConfigurationContext configurationContext,
                                     String targetEndpoint, HttpTransportProperties.Authenticator authenticator) {
    this.configurationContext = configurationContext;
    this.targetEndpoint = targetEndpoint;
    this.authenticator = authenticator;
}
 
Example #23
Source File: RequestExecutor.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
private void callService(OMElement messagePayload) throws AxisFault {

        ServiceClient client = new ServiceClient(WorkflowImplServiceDataHolder.getInstance()
                                                         .getConfigurationContextService()
                                                         .getClientConfigContext(), null);
        Options options = new Options();
        options.setAction(WFImplConstant.DEFAULT_APPROVAL_BPEL_SOAP_ACTION);

        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();

        String host = bpsProfile.getWorkerHostURL();
        String serviceName = StringUtils.deleteWhitespace(WorkflowManagementUtil
                                                                  .getParameter(parameterList, WFConstant
                                                                          .ParameterName.WORKFLOW_NAME, WFConstant
                                                                          .ParameterHolder.WORKFLOW_IMPL)
                                                                  .getParamValue());
        serviceName = StringUtils.deleteWhitespace(serviceName);

        if (host.endsWith("/")) {
            host = host.substring(0,host.lastIndexOf("/"));
        }

        String endpoint;
        if (tenantDomain != null && !tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
            endpoint = host + "/t/" + tenantDomain + "/" + serviceName + WFConstant.TemplateConstants.SERVICE_SUFFIX;
        } else {
            endpoint = host + "/" + serviceName + WFConstant.TemplateConstants.SERVICE_SUFFIX;
        }

        options.setTo(new EndpointReference(endpoint));

        options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, SOAP11Constants
                .SOAP_11_CONTENT_TYPE);

        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
        auth.setUsername(bpsProfile.getUsername());
        auth.setPassword(String.valueOf(bpsProfile.getPassword()));
        auth.setPreemptiveAuthentication(true);
        List<String> authSchemes = new ArrayList<>();
        authSchemes.add(HttpTransportProperties.Authenticator.BASIC);
        auth.setAuthSchemes(authSchemes);
        options.setProperty(HTTPConstants.AUTHENTICATE, auth);

        options.setManageSession(true);

        client.setOptions(options);
        client.fireAndForget(messagePayload);

    }
 
Example #24
Source File: EntitlementServiceStubFactory.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public EntitlementServiceStubFactory(ConfigurationContext configurationContext, String targetEndpoint,
                                     HttpTransportProperties.Authenticator authenticator) {
    this.configurationContext = configurationContext;
    this.targetEndpoint = targetEndpoint;
    this.authenticator = authenticator;
}
 
Example #25
Source File: Proxy.java    From Java_NFe with MIT License 3 votes vote down vote up
public Proxy(String ip, int porta, String usuario, String senha) {
	   
	proxyProperties = new HttpTransportProperties.ProxyProperties();      
       
      proxyProperties.setProxyName(ip);    
        
      proxyProperties.setProxyPort(porta);    
       
      proxyProperties.setUserName(usuario);    
       
      proxyProperties.setPassWord(senha);    
}
 
Example #26
Source File: Proxy.java    From Java_CTe with MIT License 3 votes vote down vote up
public Proxy(String ip, int porta, String usuario, String senha) {
	   
	proxyProperties = new HttpTransportProperties.ProxyProperties();      
       
      proxyProperties.setProxyName(ip);    
        
      proxyProperties.setProxyPort(porta);    
       
      proxyProperties.setUserName(usuario);    
       
      proxyProperties.setPassWord(senha);    
}