From 63721cb79dc1301835feac2188e22ddad27fc082 Mon Sep 17 00:00:00 2001 From: milanperera Date: Tue, 28 Jul 2015 15:34:38 +0530 Subject: [PATCH 1/2] Refactored --- .../DynamicClientRegistrationUtil.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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 4a64d6368d..0cdb0a097f 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 @@ -43,30 +43,26 @@ import java.util.Arrays; public class DynamicClientRegistrationUtil { + private static final String TOKEN_SCOPE = "tokenScope"; private static final Log log = LogFactory.getLog(DynamicClientRegistrationUtil.class); public static OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException { OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); - //Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. - String userId = profile.getOwner(); String applicationName = profile.getClientName(); - String grantType = profile.getGrantType(); if (log.isDebugEnabled()) { log.debug("Trying to create OAuth application: '" + applicationName + "'"); } - String callBackURL = profile.getCallbackUrl(); - String tokenScope = profile.getTokenScope(); String tokenScopes[] = new String[1]; tokenScopes[0] = tokenScope; - oAuthApplicationInfo.addParameter("tokenScope", Arrays.toString(tokenScopes)); + oAuthApplicationInfo.addParameter(TOKEN_SCOPE, Arrays.toString(tokenScopes)); OAuthApplicationInfo info; try { - info = createOAuthApplication(userId, applicationName, callBackURL, grantType); + info = createOAuthApplication(profile); } catch (Exception e) { throw new APIManagementException("Can not create OAuth application : " + applicationName, e); } @@ -98,8 +94,15 @@ public class DynamicClientRegistrationUtil { } public static OAuthApplicationInfo createOAuthApplication( - String userId, String applicationName, String callbackUrl, String grantType) + RegistrationProfile profile) throws APIManagementException, IdentityException { + + //Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. + String userId = profile.getOwner(); + String applicationName = profile.getClientName(); + String grantType = profile.getGrantType(); + String callbackUrl = profile.getCallbackUrl(); + if (userId == null || userId.isEmpty()) { return null; } From 508082808c04078d5f96a6976897bd109e8ef928 Mon Sep 17 00:00:00 2001 From: milanperera Date: Thu, 30 Jul 2015 17:10:12 +0530 Subject: [PATCH 2/2] Fixed a bug in commons.licence --- .../org/wso2/carbon/device/mgt/common/license/mgt/License.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java index d41a64ab82..fb7d3a4fdf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/license/mgt/License.java @@ -36,7 +36,7 @@ public class License { private String text; public License() { - this.validFrom = new Date(); + this.validTo = new Date(); this.validFrom = new Date(); }