Monday, August 03, 2015

Updating wso2 APIManager APIs with Publisher APIs

Here i'll show how to add and update apis to wso2 api manager using publisher-apis(1)


1. Login and get cookie
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=admin&password=admin'


2. Add API
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=YoutubeFeeds&visibility=public&version=1.0.0&description=Youtube Live Feeds&endpointType=nonsecured&http_checked=http&https_checked=https&&wsdl=&tags=youtube,gdata,multimedia&tier=Silver&thumbUrl=http://www.10bigideas.com.au/www/573/files/pf-thumbnail-youtube_logo.jpg&context=/youtube&tiersCollection=Gold&resourceCount=0&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*" -d'endpoint_config={"production_endpoints":
{"url":"http://gdata.youtube.com/feeds/api/standardfeeds","config":null}
,"endpoint_type":"http"}';


3. Update API with a new resource(POST) called "/postTest"
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=updateAPI&name=YoutubeFeeds&visibility=public&version=1.0.0&description=Youtube Live Feeds&endpointType=nonsecured&http_checked=http&https_checked=https&&wsdl=&tags=youtube,gdata,multimedia&tier=Silver&thumbUrl=http://www.10bigideas.com.au/www/573/files/pf-thumbnail-youtube_logo.jpg&context=/youtube&tiersCollection=Gold&resourceCount=2&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*&resourceMethod-1=POST&resourceMethodAuthType-1=Application&resourceMethodThrottlingTier-1=Unlimited&uriTemplate-1=/postTest" -d'endpoint_config={"production_endpoints":
{"url":"http://gdata.youtube.com/feeds/api/standardfeeds","config":null}
,"endpoint_type":"http"}';


4. Add two more methods PUT and GET for the same "/postTest" resource
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=updateAPI&name=YoutubeFeeds&visibility=public&version=1.0.0&description=Youtube Live Feeds&endpointType=nonsecured&http_checked=http&https_checked=https&&wsdl=&tags=youtube,gdata,multimedia&tier=Silver&thumbUrl=http://www.10bigideas.com.au/www/573/files/pf-thumbnail-youtube_logo.jpg&context=/youtube&tiersCollection=Gold&resourceCount=4&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*&resourceMethod-1=POST&resourceMethodAuthType-1=Application&resourceMethodThrottlingTier-1=Unlimited&uriTemplate-1=/postTest&resourceMethod-2=PUT&resourceMethodAuthType-2=Application&resourceMethodThrottlingTier-2=Unlimited&uriTemplate-2=/postTest&resourceMethod-3=GET&resourceMethodAuthType-3=Application&resourceMethodThrottlingTier-3=Unlimited&uriTemplate-3=/postTest" -d'endpoint_config={"production_endpoints":
{"url":"http://gdata.youtube.com/feeds/api/standardfeeds","config":null}
,"endpoint_type":"http"}';


Note that here we use the zero based indexes. Also note that resourceMethod can take any one of the following values: GET, POST, DELETE, PUT, OPTIONS - (1)

(1) - https://docs.wso2.com/display/AM180/Publisher+APIs

Tuesday, July 14, 2015

Automating JAX-WS Client Generation

This post describes a solution to automate the development of proxy service clients. This needs a Maven Multi Module project as the parent project, ESB project and a Registry project. Additionally we need a simple maven project to generate the client sources. So the project structure would looks like follows.
MavenParentProject
├── ESBconfigProject
├── RegistryProject
├── proxy-service-clients
Here ESBconfigProject contains the proxy services and RegistryProject contains the wsdls referred by ESB project. The proxy-service-clients project is a simple maven project, which is used to generate the client source.
In MavenParentProject's pom file define the modules in following order

    RegistryProject
    ESBconfigProject
    proxy-service-clients

ESBconfigProject proxy-service-clients
In proxy-service-clients project's pom file define the jaxws-maven-plugin[1] as follows
 
  org.codehaus.mojo
  jaxws-maven-plugin
  1.12
   
    
    package
      
      wsimport 
     
     
   
    
    com.sample.stub 
    ../RegistryProject
    src/main/java 
    
  
Then do a maven build ('mvn clean install') on parent project and it will generate the source for clients in proxy-service-clients/src/main/java directory and compiled jar will be generated at proxy-service-clients's target directory.

WSO2 ESB - Connecting APIs with Call Mediator


In this post i'm going to discuss an API interconnecting scenario with aid of an simple use case. Here the use case is as follows. We have two apis 1. Which gives the city name when longitude, latitude coordinates are given. 2. An API which gives temperature of a city (when city name is given). Here my objective is to combine (chain) both apis and get the temperature when lon-lat is given.

First we will create the mock APIs for  Map API and Weather API. To create APIs I used WSO2 Developer Studio [1]. Using DevStudio I created a JAX-RS project and deploy it on WSO2 AS[2]
Source code for Map service and Weather service is as follows.


You can download the war file from here. Once deployed the war file on WSO2 AS, you would be able to access the API's as follows. Note that i have set portOffset of WSO2 AS as 2 since i run both servers in same machine.

http://localhost:9765/SimpleMap_1.0.0/services/weather/gettemperature?city=Kandy

First one will give {"city":"kandy"} as the output and second will give the 24.5 as the temperature output.

Now it is the time to play with WSO2 ESB to chain the above two apis. Please have a look at ESB config below, As code says what it does i'm not going to explain in detail. Figure below show the DevStudio view of the API.



Now you can call the ESB api directly to get the temperate when the coordinates of the location is given.
http://localhost:8280/MapService/gettemperature?x=7&y=80

References
[1] - http://wso2.com/products/developer-studio/
[2] - http://wso2.com/products/application-server/
[3] - http://wso2.com/products/enterprise-service-bus/

Monday, April 27, 2015

WSO2IS-5.0.0 Admin Services

1. Navigate to IS_HOME/repository/conf" directory and open the carbon.xml file, then change the value of the "HideAdminServiceWSDLs" to false;

2. Stop the server with if already started.

3. Start with following command
           sh wso2server.sh -DosgiConsole

4. In the osgi console type listAdminServices

osgi> listAdminServices
Admin services deployed on this server:
1. ProvisioningAdminService, ProvisioningAdminService, https://localhost:9443/services/ProvisioningAdminService/ 
2. IdentitySAMLSSOConfigService, IdentitySAMLSSOConfigService, https://localhost:9443/services/IdentitySAMLSSOConfigService/ 
3. CarbonAppUploader, CarbonAppUploader, https://localhost:9443/services/CarbonAppUploader/ 
4. JaggeryAppAdmin, JaggeryAppAdmin, https://localhost:9443/services/JaggeryAppAdmin/ 
5. JaxwsWebappAdmin, JaxwsWebappAdmin, https://localhost:9443/services/JaxwsWebappAdmin/ 
6. RemoteUserStoreManagerService, RemoteUserStoreManagerService, https://localhost:9443/services/RemoteUserStoreManagerService/ 
7. UserProfileMgtService, UserProfileMgtService, https://localhost:9443/services/UserProfileMgtService/ 
8. StatisticsAdmin, StatisticsAdmin, https://localhost:9443/services/StatisticsAdmin/ 
9. LoggedUserInfoAdmin, LoggedUserInfoAdmin, https://localhost:9443/services/LoggedUserInfoAdmin/ 
10. WebappAdmin, WebappAdmin, https://localhost:9443/services/WebappAdmin/ 
11. ws-xacml, ws-xacml, https://localhost:9443/services/ws-xacml/ 
12. RemoteUserRealmService, RemoteUserRealmService, https://localhost:9443/services/RemoteUserRealmService/ 
13. TopicManagerAdminService, TopicManagerAdminService, https://localhost:9443/services/TopicManagerAdminService/ 
14. ClaimManagementService, ClaimManagementService, https://localhost:9443/services/ClaimManagementService/ 
15. IdentitySTSAdminService, IdentitySTSAdminService, https://localhost:9443/services/IdentitySTSAdminService/ 
16. NDataSourceAdmin, NDataSourceAdmin, https://localhost:9443/services/NDataSourceAdmin/ 
17. ServiceGroupAdmin, ServiceGroupAdmin, https://localhost:9443/services/ServiceGroupAdmin/ 
18. IdentityApplicationManagementService, IdentityApplicationManagementService, https://localhost:9443/services/IdentityApplicationManagementService/ 
19. CustomMeteringService, CustomMeteringService, https://localhost:9443/services/CustomMeteringService/ 
20. STSAdminService, STSAdminService, https://localhost:9443/services/STSAdminService/ 
21. DirectoryServerManager, DirectoryServerManager, https://localhost:9443/services/DirectoryServerManager/ 
22. OAuthAdminService, OAuthAdminService, https://localhost:9443/services/OAuthAdminService/ 
23. RegistryAdminService, RegistryAdminService, https://localhost:9443/services/RegistryAdminService/ 
24. FileDownloadService, FileDownloadService, https://localhost:9443/services/FileDownloadService/ 
25. ContentSearchAdminService, ContentSearchAdminService, https://localhost:9443/services/ContentSearchAdminService/ 
26. LoginStatisticsAdmin, LoginStatisticsAdmin, https://localhost:9443/services/LoginStatisticsAdmin/ 
27. CustomUIAdminService, CustomUIAdminService, https://localhost:9443/services/CustomUIAdminService/ 
28. SearchAdminService, SearchAdminService, https://localhost:9443/services/SearchAdminService/ 
29. RemoteAuthorizationManagerService, RemoteAuthorizationManagerService, https://localhost:9443/services/RemoteAuthorizationManagerService/ 
30. RemoteProfileConfigurationManagerService, RemoteProfileConfigurationManagerService, https://localhost:9443/services/RemoteProfileConfigurationManagerService/ 
31. SCIMConfigAdminService, SCIMConfigAdminService, https://localhost:9443/services/SCIMConfigAdminService/ 
32. IdentityProviderAdminService, IdentityProviderAdminService, https://localhost:9443/services/IdentityProviderAdminService/ 
33. IWAAuthenticator, IWAAuthenticator, https://localhost:9443/services/IWAAuthenticator/ 
34. LoggingAdmin, LoggingAdmin, https://localhost:9443/services/LoggingAdmin/ 
35. SampleDeployer, SampleDeployer, https://localhost:9443/services/SampleDeployer/ 
36. XMPPConfigurationService, XMPPConfigurationService, https://localhost:9443/services/XMPPConfigurationService/ 
37. SecurityAdminService, SecurityAdminService, https://localhost:9443/services/SecurityAdminService/ 
38. KeyStoreAdminService, KeyStoreAdminService, https://localhost:9443/services/KeyStoreAdminService/ 
39. ServerRolesManager, ServerRolesManager, https://localhost:9443/services/ServerRolesManager/ 
40. IdentityProviderMgtService, IdentityProviderMgtService, https://localhost:9443/services/IdentityProviderMgtService/ 
41. ResourceAdminService, ResourceAdminService, https://localhost:9443/services/ResourceAdminService/ 
42. ThemeMgtService, ThemeMgtService, https://localhost:9443/services/ThemeMgtService/ 
43. FileUploadService, FileUploadService, https://localhost:9443/services/FileUploadService/ 
44. RemoteTenantManagerService, RemoteTenantManagerService, https://localhost:9443/services/RemoteTenantManagerService/ 
45. EventBrokerService, EventBrokerService, https://localhost:9443/services/EventBrokerService/ 
46. TracerAdmin, TracerAdmin, https://localhost:9443/services/TracerAdmin/ 
47. MultipleCredentialsUserAdmin, MultipleCredentialsUserAdmin, https://localhost:9443/services/MultipleCredentialsUserAdmin/ 
48. UserStoreConfigAdminService, UserStoreConfigAdminService, https://localhost:9443/services/UserStoreConfigAdminService/ 
49. RepositoryAdminService, RepositoryAdminService, https://localhost:9443/services/RepositoryAdminService/ 
50. TenantMgtAdminService, TenantMgtAdminService, https://localhost:9443/services/TenantMgtAdminService/ 
51. DeploymentSynchronizerAdmin, DeploymentSynchronizerAdmin, https://localhost:9443/services/DeploymentSynchronizerAdmin/ 
52. EntitlementPolicyAdminService, EntitlementPolicyAdminService, https://localhost:9443/services/EntitlementPolicyAdminService/ 
53. ServerAdmin, ServerAdmin, https://localhost:9443/services/ServerAdmin/ 
54. ServiceAdmin, ServiceAdmin, https://localhost:9443/services/ServiceAdmin/ 
55. UserIdentityManagementAdminService, UserIdentityManagementAdminService, https://localhost:9443/services/UserIdentityManagementAdminService/ 
56. EntitlementAdminService, EntitlementAdminService, https://localhost:9443/services/EntitlementAdminService/ 
57. UserAdmin, UserAdmin, https://localhost:9443/services/UserAdmin/ 
58. AccountCredentialMgtConfigService, AccountCredentialMgtConfigService, https://localhost:9443/services/AccountCredentialMgtConfigService/ 
59. UserInformationRecoveryService, UserInformationRecoveryService, https://localhost:9443/services/UserInformationRecoveryService/ 
60. PropertiesAdminService, PropertiesAdminService, https://localhost:9443/services/PropertiesAdminService/ 
61. LogViewer, LogViewer, https://localhost:9443/services/LogViewer/ 
62. RemoteClaimManagerService, RemoteClaimManagerService, https://localhost:9443/services/RemoteClaimManagerService/ 
63. EntitlementService, EntitlementService, https://localhost:9443/services/EntitlementService/ 
64. OAuth2TokenValidationService, OAuth2TokenValidationService, https://localhost:9443/services/OAuth2TokenValidationService/ 

65. ProfilesAdminService, ProfilesAdminService, https://localhost:9443/services/ProfilesAdminService/

Friday, April 03, 2015

Applying Security from wso2 DeveloperStudio

Please refer [1]  for the subject, Note that this is a workaround only, proper way is on its way ..)

[1] -https://docs.google.com/document/d/1MDGwH4hk2X2COGCF4aYp7gSqmqbDzITKrKnA44s5ep8/pub