From 97c19c23b0cf275d0a6d26ced3e1d5a59607af37 Mon Sep 17 00:00:00 2001 From: mharindu Date: Wed, 26 Aug 2015 17:14:12 +0530 Subject: [PATCH] Added method level comments and null checks in DCA --- .../extension/DynamicClientRegistrationUtil.java | 5 +++++ .../oauth/extension/RegistrationService.java | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java index 0cdb0a097f9..0a7698217a6 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java @@ -228,6 +228,11 @@ public class DynamicClientRegistrationUtil { oAuthAdminService.removeOAuthApplicationData(consumerKey); ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); + + if (appMgtService == null) { + throw new APIManagementException("Error occurred while retrieving Application Management" + + "Service"); + } ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName); if (createdServiceProvider == null) { diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java index a31673a7762..962b7210918 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java +++ b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java @@ -45,9 +45,24 @@ public interface RegistrationService { } } + /** + * This method is used to register an Oauth application. + * + * @param profile contains the necessary attributes that are + * needed in order to register an app. + * @return Status 200 if success including consumerKey and consumerSecret. + */ @POST Response register(RegistrationProfile profile); + /** + * This method is used to remove already registered Oauth application. + * + * @param applicationName name of the application. + * @param userId name of the application owner. + * @param consumerKey provided consumerKey for the registered application. + * @return Status 200 if success. + */ @DELETE public Response unregister(@QueryParam("applicationName") String applicationName, @QueryParam("userId") String userId,