org.apache.axis2.client.Options Java Examples

The following examples show how to use org.apache.axis2.client.Options. 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
@Before
public void setup() throws Exception {

    environment = new Environment();
    environment.setName(ENV_NAME);
    environment.setPassword(PASSWORD);
    environment.setUserName(USERNAME);
    environment.setServerURL(SERVER_URL);
    apiGatewayAdminStub = Mockito.mock(APIGatewayAdminStub.class);

    Options options = new Options();
    ServiceContext serviceContext = new ServiceContext();
    OperationContext operationContext = Mockito.mock(OperationContext.class);
    serviceContext.setProperty(HTTPConstants.COOKIE_STRING, "");
    ServiceClient serviceClient = Mockito.mock(ServiceClient.class);
    AuthenticationAdminStub authAdminStub = Mockito.mock(AuthenticationAdminStub.class);
    Mockito.doReturn(true).when(authAdminStub).login(Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
    Mockito.when(authAdminStub._getServiceClient()).thenReturn(serviceClient);
    Mockito.when(serviceClient.getLastOperationContext()).thenReturn(operationContext);
    Mockito.when(operationContext.getServiceContext()).thenReturn(serviceContext);
    Mockito.when(apiGatewayAdminStub._getServiceClient()).thenReturn(serviceClient);
    Mockito.when(serviceClient.getOptions()).thenReturn(options);
    PowerMockito.whenNew(AuthenticationAdminStub.class)
            .withArguments(Mockito.any(ConfigurationContext.class), Mockito.anyString()).thenReturn(authAdminStub);
}
 
Example #2
Source File: RegistryCacheInvalidationClient.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Invalidates registry cache of the resource in the given path in given server
 * @param path registry path of the resource
 * @param tenantDomain
 * @param serverURL
 * @param cookie
 * @throws AxisFault
 * @throws RemoteException
 * @throws APIManagementException
 */
public void clearCache(String path, String tenantDomain, String serverURL, String cookie) 
        throws AxisFault, RemoteException, APIManagementException {
    RegistryCacheInvalidationServiceStub registryCacheServiceStub;

    ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    registryCacheServiceStub = getRegistryCacheInvalidationServiceStub(serverURL, ctx);
    ServiceClient client = registryCacheServiceStub._getServiceClient();
    Options options = client.getOptions();
    options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS);
    options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS);
    options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS);
    options.setManageSession(true);
    options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
    
    try {
        registryCacheServiceStub.invalidateCache(path, tenantDomain);      
    } catch (RegistryCacheInvalidationServiceAPIManagementExceptionException e) {
        APIUtil.handleException(e.getMessage(), e);
    }
}
 
Example #3
Source File: EmailVerificationServiceClient.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public EmailVerificationServiceClient(
        String cookie, String backendServerURL, ConfigurationContext configContext)
        throws RegistryException {

    epr = backendServerURL + "EmailVerificationService";

    try {
        stub = new EmailVerificationServiceStub(configContext, epr);

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

    } catch (AxisFault axisFault) {
        String msg = "Failed to initiate AddServices service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}
 
Example #4
Source File: APIAuthenticationHandlerTestCase.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleRequest() {

    APIAuthenticationHandler apiAuthenticationHandler = createAPIAuthenticationHandler();
    apiAuthenticationHandler.init(synapseEnvironment);
    Assert.assertEquals(apiAuthenticationHandler.startMetricTimer(), null);

    Options options = Mockito.mock(Options.class);
    Mockito.when(options.getMessageId()).thenReturn("1");
    Mockito.when(axis2MsgCntxt.getOptions()).thenReturn(options);

    TreeMap transportHeaders = new TreeMap();
    transportHeaders.put(APIConstants.USER_AGENT, "");
    transportHeaders.put(APIMgtGatewayConstants.AUTHORIZATION, "gsu64r874tcin7ry8oe");
    messageContext.setProperty(RESTConstants.REST_FULL_REQUEST_PATH, "");
    messageContext.setProperty(APIMgtGatewayConstants.APPLICATION_NAME, "abc");
    messageContext.setProperty(APIMgtGatewayConstants.END_USER_NAME, "admin");
    Mockito.when(axis2MsgCntxt.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS)).thenReturn(transportHeaders);
    Assert.assertTrue(apiAuthenticationHandler.handleRequest(messageContext));
}
 
Example #5
Source File: AuthenticateStub.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static Stub authenticateStub(Stub stub, String sessionCookie, String backendURL) {
    long soTimeout = 5 * 60 * 1000; // Three minutes

    ServiceClient client = stub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);
    option.setTimeOutInMilliSeconds(soTimeout);
    System.out.println("XXXXXXXXXXXXXXXXXXX" + backendURL + client.getServiceContext().getAxisService().getName()
            .replaceAll("[^a-zA-Z]", ""));
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, sessionCookie);
    option.setTo(new EndpointReference(
            backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", "")));
    if (log.isDebugEnabled()) {
        log.debug("AuthenticateStub : Stub created with session " + sessionCookie);
    }

    return stub;
}
 
Example #6
Source File: WSClaimManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public WSClaimManager(String serverUrl, String cookie, ConfigurationContext configCtxt)
        throws UserStoreException {
    try {
        stub =
                new RemoteClaimManagerServiceStub(configCtxt, serverUrl +
                        SERVICE_NAME);

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

        throw new UserStoreException("Axis error occurred while creating service client stub", e);
    }
}
 
Example #7
Source File: WSRealm.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize WSRealm by Non-carbon environment
 */
void init(String url, String cookie, ConfigurationContext configCtxt)
        throws UserStoreException {
    try {

        stub = new RemoteUserRealmServiceStub(configCtxt, url + REALM_SERVICE_NAME);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING,
                this
                        .getSessionCookie());
    } catch (AxisFault e) {

        throw new UserStoreException("Axis error occurred while creating service client stub");
    }

    userStoreMan = new WSUserStoreManager(url, cookie, configCtxt);
    authzMan = new WSAuthorizationManager(url, cookie, configCtxt);
    claimManager = new WSClaimManager(url, cookie, configCtxt);
    profileManager = new WSProfileConfigurationManager(url, cookie, configCtxt);
}
 
Example #8
Source File: RetrieveB.java    From openxds with Apache License 2.0 6 votes vote down vote up
private OMElement call(OMElement metadata_ele, String endpoint)
throws XdsWSException, XdsException, AxisFault {
		Options options = new Options();
		options.setTo(new EndpointReference(endpoint)); // this sets the location of MyService service
		ServiceClient serviceClient = new ServiceClient();
		serviceClient.setOptions(options);
		OMElement result;
		Soap soap = new Soap();
		soap.setAsync(async);
		soap.soapCall(metadata_ele, 
				null,   //Protocol 
				endpoint, 
				true,    // mtom
				true,     // addressing
				soap12,     // soap12
				getRequestAction(),
				getResponseAction());
		result = soap.getResult();
		return result;
}
 
Example #9
Source File: WSEventDispatcher.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
protected synchronized void sendNotification(OMElement topicHeader,
                                OMElement tenantDomainHeader,
                                OMElement payload,
                                String endpoint)
        throws AxisFault {
    // The parameter args is used as a mechanism to pass any argument into this method, which
    // is used by the implementations that extend the behavior of the default Carbon Event
    // Dispatcher.
    ConfigurationContextService configurationContextService =
            WSEventBrokerHolder.getInstance().getConfigurationContextService();

    ServiceClient serviceClient =
            new ServiceClient(configurationContextService.getClientConfigContext(), null);

    Options options = new Options();
    options.setTo(new EndpointReference(endpoint));
    options.setAction(EventingConstants.WSE_PUBLISH);
    serviceClient.setOptions(options);
    serviceClient.addHeader(topicHeader);

    if (tenantDomainHeader != null){
        serviceClient.addHeader(tenantDomainHeader);
    }

    serviceClient.fireAndForget(payload);
}
 
Example #10
Source File: SOAPClient.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a SOAP message with MTOM attachment and returns response as a OMElement.
 *
 * @param fileName   name of file to be sent as an attachment
 * @param targetEPR  service url
 * @param soapAction SOAP Action to set. Specify with "urn:"
 * @return OMElement response from BE service
 * @throws AxisFault in case of an invocation failure
 */
public OMElement sendSOAPMessageWithAttachment(String fileName, String targetEPR, String soapAction) throws AxisFault {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction(soapAction);
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    return serviceClient.sendReceive(payload);
}
 
Example #11
Source File: Sample701TestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Sampling Processor " +
        "test case")
public void messageStoreFIXStoringTest() throws Exception {

    // The count should be 0 as soon as the message store is created
    Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0,
            "Message store should be initially empty");

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(getBackEndServiceUrl("StockQuoteProxy")));
    options.setAction("urn:placeOrder");
    options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL());
    serviceClient.setOptions(options);

    for (int i = 0; i < 10; i++) {
        serviceClient.sendRobust(createPayload());
    }

    Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) > 0,
            "Messages are not stored");

}
 
Example #12
Source File: ESBJAVA4909MultipartRelatedTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
    final String EXPECTED = "<m0:uploadFileUsingMTOMResponse xmlns:m0=\"http://services.samples\"><m0:response>" +
            "<m0:image>PHByb3h5PkFCQzwvcHJveHk+</m0:image></m0:response></m0:uploadFileUsingMTOMResponse>";
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction("urn:uploadFileUsingMTOM");
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    OMElement response = serviceClient.sendReceive(payload);
    Assert.assertTrue(response.toString().contains(EXPECTED), "Attachment is missing in the response");
}
 
Example #13
Source File: KeyStoreAdminClient.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public KeyStoreAdminClient(String cookie, String url, ConfigurationContext configContext)
        throws java.lang.Exception {

    try {
        this.serviceEndPoint = url + "KeyStoreAdminService";
        this.stub = new KeyStoreAdminServiceStub(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 (AxisFault e) {
        log.error("Error in creating KeyStoreAdminClient", e);
        throw e;
    }

}
 
Example #14
Source File: CallOutMediatorWithMTOMTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction("urn:uploadFileUsingMTOM");
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    OMElement response = serviceClient.sendReceive(payload);
    Assert.assertTrue(response.toString().contains(
            "<m:testMTOM xmlns:m=\"http://services.samples/xsd\">" + "<m:test1>testMTOM</m:test1></m:testMTOM>"));
}
 
Example #15
Source File: Sample701TestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "Introduction to Message Sampling Processor " + "test case")
public void messageStoreFIXStoringTest() throws Exception {

    // The count should be 0 as soon as the message store is created
    Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0,
            "Message store should be initially empty");

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(getBackEndServiceUrl("StockQuoteProxy")));
    options.setAction("urn:placeOrder");
    options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL());
    serviceClient.setOptions(options);

    for (int i = 0; i < 10; i++) {
        serviceClient.sendRobust(createPayload());
    }

    Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) > 0, "Messages are not stored");

}
 
Example #16
Source File: Sample704TestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "RESTful Invocations with Message Forwarding" + " Processor test case")
public void messageStoreFIXStoringTest() throws Exception {

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(getBackEndServiceUrl("StockQuoteProxy")));
    options.setAction("urn:placeOrder");
    options.setProperty(Constants.Configuration.TRANSPORT_URL, getMainSequenceURL());
    serviceClient.setOptions(options);

    for (int i = 0; i < 10; i++) {
        serviceClient.sendRobust(createPayload());
    }

    Thread.sleep(2000);
    Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Messages are stored");
}
 
Example #17
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 #18
Source File: WorkflowDeployerClient.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public WorkflowDeployerClient(String bpsURL, String username) throws AxisFault {

        bpelUploaderStub = new BPELUploaderStub(bpsURL + BPEL_UPLOADER_SERVICE);
        ServiceClient serviceClient = bpelUploaderStub._getServiceClient();
        OMElement mutualSSLHeader;
        try {
            String headerString = WFImplConstant.MUTUAL_SSL_HEADER.replaceAll("\\$username", username);
            mutualSSLHeader = AXIOMUtil.stringToOM(headerString);
            serviceClient.addHeader(mutualSSLHeader);
        } catch (XMLStreamException e) {
            throw new AxisFault("Error while creating mutualSSLHeader XML Element.", e);
        }
        Options options = serviceClient.getOptions();
        serviceClient.setOptions(options);

        humanTaskUploaderStub = new HumanTaskUploaderStub(bpsURL + HT_UPLOADER_SERVICE);
        ServiceClient htServiceClient = humanTaskUploaderStub._getServiceClient();
        Options htOptions = htServiceClient.getOptions();
        htServiceClient.setOptions(htOptions);
        htServiceClient.addHeader(mutualSSLHeader);
    }
 
Example #19
Source File: SOAPClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a SOAP message with MTOM attachment and returns response as a OMElement.
 *
 * @param fileName   name of file to be sent as an attachment
 * @param targetEPR  service url
 * @param soapAction SOAP Action to set. Specify with "urn:"
 * @return OMElement response from BE service
 * @throws AxisFault in case of an invocation failure
 */
public OMElement sendSOAPMessageWithAttachment(String fileName, String targetEPR, String soapAction) throws AxisFault {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction(soapAction);
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    return serviceClient.sendReceive(payload);
}
 
Example #20
Source File: UserSignUpWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
    ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
    RealmService realmService = Mockito.mock(RealmService.class);
    UserRealm userRealm = Mockito.mock(UserRealm.class);
    userStoreManager = Mockito.mock(UserStoreManager.class);
    PowerMockito.mockStatic(CarbonUtils.class);
    userAdminStub = Mockito.mock(UserAdminStub.class);
    userRegistrationAdminServiceStub = Mockito.mock(UserRegistrationAdminServiceStub.class);
    serviceClient =  Mockito.mock(ServiceClient.class);;
    PowerMockito.whenNew(UserAdminStub.class).withAnyArguments().thenReturn(userAdminStub);
    PowerMockito.whenNew(UserRegistrationAdminServiceStub.class).withAnyArguments().thenReturn
            (userRegistrationAdminServiceStub);
    PowerMockito.when(userRegistrationAdminServiceStub._getServiceClient()).thenReturn(serviceClient);
    Mockito.when(serviceClient.getOptions()).thenReturn(new Options());
    Mockito.when(serviceReferenceHolder.getRealmService()).thenReturn(realmService);
    Mockito.when(realmService.getBootstrapRealm()).thenReturn(userRealm);
    Mockito.when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    PowerMockito.doNothing().when(CarbonUtils.class, "setBasicAccessSecurityHeaders", Mockito.anyString(),
            Mockito.anyString(), Mockito.anyBoolean(), (ServiceClient) Mockito.anyObject());
    FlaggedName flaggedName = new FlaggedName();
    flaggedName.setSelected(true);
    flaggedName.setItemName(role);
    flaggedNames = new FlaggedName[]{flaggedName};
}
 
Example #21
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 #22
Source File: DiscoveryAdminClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public DiscoveryAdminClient(ConfigurationContext configCtx, String backendServerURL,
                               String cookie, Locale locale) throws AxisFault {
    bundle = ResourceBundle.getBundle(BUNDLE, locale);

    String serviceURL = backendServerURL + "DiscoveryAdmin";
    stub = new DiscoveryAdminStub(configCtx, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
 
Example #23
Source File: DiscoveryAdminClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public DiscoveryAdminClient(ConfigurationContext configCtx, String backendServerURL,
                               String cookie, Locale locale) throws AxisFault {
    bundle = ResourceBundle.getBundle(BUNDLE, locale);
    String serviceURL = backendServerURL + "DiscoveryAdmin";
    stub = new DiscoveryAdminStub(configCtx, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
 
Example #24
Source File: FileDownloadServiceClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public FileDownloadServiceClient(ConfigurationContext ctx, String serverURL,
                         String cookie, HttpSession session) throws AxisFault {
    this.session = session;
    String serviceEPR = serverURL + "FileDownloadService";
    stub = new FileDownloadServiceStub(ctx, serviceEPR);
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    if (cookie != null) {
        options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
    }
}
 
Example #25
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 #26
Source File: ClusterAdminClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public ClusterAdminClient(String cookie,
                          String backendServerURL,
                          ConfigurationContext configCtx,
                          Locale locale) throws AxisFault {
    String serviceURL = backendServerURL + "ClusterAdmin";
    bundle = ResourceBundle.getBundle(BUNDLE, locale);

    stub = new ClusterAdminStub(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: 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(IdentityManagementServiceUtil.getInstance().getServiceContextURL())
                            .append(IdentityManagementEndpointConstants.ServiceEndpoints.USER_REGISTRATION_SERVICE)
                            .toString().replaceAll("(?<!(http:|https:))//", "/");

        stub = new UserRegistrationAdminServiceStub(serviceURL);
        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
    }
 
Example #28
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 #29
Source File: ConditionalAuthMgtClient.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public ConditionalAuthMgtClient(String cookie, String backendServerURL,
                                ConfigurationContext configCtx) throws AxisFault {

    String serviceURL = backendServerURL + "ConditionalAuthenticationMgtService";
    stub = new ConditionalAuthenticationMgtServiceStub(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 #30
Source File: EventBrokerAdminClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void configureCookie(ServiceClient client) throws AxisFault {
    if (SessionCookie != null) {
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, SessionCookie);
    }
}