Writing tenant aware web service in wso2 application server - web-services

I am trying to develop a axis2 web service to be deployed on WSO2 Application Server 5.0.1. Currently we have requirement, that web services support multi-tenancy and in some web services some process based on tenant. Upon the service context i need to retrieve tenant information from the current request. Currently i create to tenant in my local environment using Application Server management console test1.com and test2.com. How can i retrieve domain name and if possible tenant id of test1.com and test2.com from request and how should client call the web service to a specific tenant, for example to test1.com ?
Thanks

You can use CarbonContext to retrieve current tenant and other stuffs.
CarbonContext cCtx = CarbonContext.getCurrentContext();
cCtx.getTenantDomain();
cCtx.getTenantId();
Refer this article for more information on how to use carbon platform APIs.

Related

How to integrate apim with wso2 micro intergrator

Integrate apim with micro integator
How to integrate apim with micro integator without using integration studio
If you have already created a back-end API, then you don't need Micro-integrator, and you can directly expose that API through the API Manager. The API Manager can add schema validation as well.
If you need to implement additional message mediations, message transformations, and service orchestration on top of your existing back-end services, then you can do that using Micro-integrator and expose that as an API using API Manager.
Please see - https://apim.docs.wso2.com/en/latest/get-started/integration-quick-start-guide/
Micro Integrator is already embedded with the API Manager 4.1 .If you need to add some transformations to your API that you didn't found in the API Manger ,then you have to do it in the Integration Studio and then publish it to the Publisher Portal using service catalog feature.
You can follow this documentation
https://apim.docs.wso2.com/en/latest/tutorials/integration-tutorials/service-catalog-tutorial/
Integrating API Manager and Micro-integrator will be done via the Service Catalog by adding the following configurations in MI deployment .toml.
[[service_catalog]]
apim_host = "https://localhost:9443"
enable = true
username = "admin"
password = "admin"
Once you have created the integration service and deployed it in the Micro-integrator, you only need to start the two servers (APIM server and the Micro-integrator server).
More information - https://apim.docs.wso2.com/en/latest/integrate/develop/working-with-service-catalog/

Multiple tenant in wso2is

Is tenant functionality useful for a saas web application? In wso2 docs the tenants are useful for multiple departments, but in my case I have multiple clientes with your own users.
How can I share my saas application between multiple tenant, if this tenant are isolated?
What’s the best way of use the wso2 capabilities for saas apps, using roles and access attributes (abac) ?
You can use the tenant functionality for your requirement. You can configure a service provider as the SaaS application, then that application can be access by all other tenant members.
By default, the SaaS Application check box is disabled, which means the web application is not shared among tenants so only users in the current tenant (the one you use to define the service provider) will be allowed to log into the web application. Alternatively, if you enabled the SaaS Application check box, that means this web application is shared among tenants so users from any tenant will be allowed to log into the web application.
You can refer here for more info
What’s the best way of use the wso2 capabilities for saas apps, using roles and access attributes (abac) ?
If you meant to configure the authentication mechanism for the saas apps using roles and access attributes, you can use the Adaptive Authentication feature. This feature will allow you to control the authentication/ authorization flow using simple javascript

User impersonation via admin services in WSO2 possible?

I am making a RemoteRegistry connection to a WSO2 server as user admin, but I am in need of being able to create registry resources as a different user (so the owner of the resource is not admin but another existing user). Is it possible to impersonate another user, or obtain a Registry instance for another user?
This is possible for code that runs inside the WSO2 (for example, code deployed in the built-in Tomcat instance that WSO2 itself runs on), but this particular requirement is for code that accesses the WSO2 server remotely via external APIs, rather than directly from within.
The WSO2 server in question is a WSO2 Identity Server v5.x that also includes functionality from WSO2 Governance Registry.

How to discover axis2 web service with WSO2 Governance Registry?

My question if is it possible to discover or integrate axis2 web services with WSO2 Governance Registry?
I want to discover all the web services and automatically upload their info to the WSO2 GREG, and check automatically if there is a new web services.
Yes you can do this with WSO2 Greg and Application server. Here are the steps you required.
In jenkins(or any other task scheduler to check available services frequentrly) we will deployed scheduled task to trigger some event periodically.
Periodic task will call WSO2 App Server’s admin services to get service metadata. To list service meta data for axis2 services we can call service admin soap service (https://127.0.0.1:9443/services/ServiceAdmin?wsdl)
In same way we can call all services and get complete service data(if you need other service types in addition to axis2 services).
Then we can call registry rest API and push that information.
Please refer this article for more information about Registry REST API.
You can find detailed description and soap service details in this article.

Login multiple web applications (php) by SSO using WSO2 IS

I have several web aplicaciones (PHP) that requires a control roles to access them. The roles are defined in WSO2 Identity Server, my problem is how to communicate web applications to access them at managing the identity server and if that can be done with the WSO2 Web Services Framework for PHP or need something more.
You can use simplesamlphp [1] with WSO2 Identity server[2] to get SSO to your application.
[1] https://simplesamlphp.org/
[2] https://docs.wso2.com/display/IS500/SAML2+IdP+with+SimpleSAMLphp+Service+Provider