From a582997c80cb7b256763bafe914bbf30d05e5e1d Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Fri, 15 Sep 2017 13:12:41 +0530 Subject: [PATCH] Changed to camel case text. --- .../handler/service/AuthHandlerService.java | 2 +- .../service/impl/AuthHandlerServiceImpl.java | 20 ++++---- .../mgt/auth/handler/util/Constants.java | 1 + .../handler/util/dto/AccessTokenInfo.java | 50 +++++++++---------- .../handler/util/dto/ApiApplicationKey.java | 16 +++--- .../publisher/src/api/authHandler.js | 6 +-- 6 files changed, 49 insertions(+), 46 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/AuthHandlerService.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/AuthHandlerService.java index 5e4e9314d0a..2f0a83228e5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/AuthHandlerService.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/AuthHandlerService.java @@ -40,7 +40,7 @@ public interface AuthHandlerService { @Path("/refresh") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) - Response refresh(@QueryParam("refresh_token") String refresh_token, @QueryParam("clientId") String clientId, + Response refresh(@QueryParam("refreshToken") String refreshToken, @QueryParam("clientId") String clientId, @QueryParam("clientSecret") String clientSecret); @POST diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/impl/AuthHandlerServiceImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/impl/AuthHandlerServiceImpl.java index cbb7846b94b..4c51e39ad5f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/impl/AuthHandlerServiceImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/service/impl/AuthHandlerServiceImpl.java @@ -67,12 +67,14 @@ public class AuthHandlerServiceImpl implements AuthHandlerService { } }; - private Client disableHostnameVerification = new Client.Default(getTrustedSSLSocketFactory(), new HostnameVerifier() { - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - }); + private Client disableHostnameVerification = new Client.Default(getTrustedSSLSocketFactory(), + new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + } + ); @POST @Path("/login") @@ -116,14 +118,15 @@ public class AuthHandlerServiceImpl implements AuthHandlerService { @Path("/refresh") @Produces(MediaType.APPLICATION_JSON) @Override - public Response refresh(@QueryParam("refresh_token") String refresh_token, @QueryParam("clientId") String clientId, + public Response refresh(@QueryParam("refreshToken") String refreshToken, @QueryParam("clientId") String clientId, @QueryParam("clientSecret") String clientSecret) { try { TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification) .requestInterceptor(new BasicAuthRequestInterceptor(clientId, clientSecret)) .contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder()) .target(TokenIssuerService.class, Constants.TOKEN_ENDPOINT); - AccessTokenInfo accessTokenInfo = tokenIssuerService.getRefreshToken(Constants.REFRESH_GRANT_TYPE, refresh_token); + AccessTokenInfo accessTokenInfo = tokenIssuerService.getRefreshToken(Constants.REFRESH_GRANT_TYPE, + refreshToken); return Response.status(200).entity(new JSONObject(accessTokenInfo)).build(); } catch (Exception e) { return Response.status(500).build(); @@ -131,7 +134,6 @@ public class AuthHandlerServiceImpl implements AuthHandlerService { } - @POST @Path("/logout") @Override diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/Constants.java index 9cb64b83fcf..5837fd2d689 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/Constants.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/Constants.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.application.mgt.auth.handler.util; +//TODO: Remove hardcoded localhost and ports public class Constants { public static String SCOPES = "perm:application:get perm:application:create perm:application:update " + "perm:application-mgt:login perm:application:delete perm:platform:add perm:platform:remove " + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/AccessTokenInfo.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/AccessTokenInfo.java index 6f750d7cb9a..3421aff3af2 100755 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/AccessTokenInfo.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/AccessTokenInfo.java @@ -30,54 +30,54 @@ import javax.xml.bind.annotation.XmlRootElement; @JsonIgnoreProperties(ignoreUnknown = true) public class AccessTokenInfo { - @XmlElement(required = true, name = "token_type") - private String token_type; + @XmlElement(required = true, name = "tokenType") + private String tokenType; - @XmlElement(required = true, name = "expires_in") - private String expires_in; + @XmlElement(required = true, name = "expiresIn") + private String expiresIn; - @XmlElement(required = true, name = "refresh_token") - private String refresh_token; + @XmlElement(required = true, name = "refreshToken") + private String refreshToken; - @XmlElement(required = true, name = "access_token") - private String access_token; + @XmlElement(required = true, name = "accessToken") + private String accessToken; public AccessTokenInfo() {} - public String getToken_type() { - return token_type; + public String getTokenType() { + return tokenType; } - public void setToken_type(String token_type) { - this.token_type = token_type; + public void setTokenType(String tokenType) { + this.tokenType = tokenType; } - public String getExpires_in() { - return expires_in; + public String getExpiresIn() { + return expiresIn; } - public void setExpires_in(String expires_in) { - this.expires_in = expires_in; + public void setExpiresIn(String expiresIn) { + this.expiresIn = expiresIn; } - public String getRefresh_token() { - return refresh_token; + public String getRefreshToken() { + return refreshToken; } - public void setRefresh_token(String refresh_token) { - this.refresh_token = refresh_token; + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; } - public String getAccess_token() { - return access_token; + public String getAccessToken() { + return accessToken; } - public void setAccess_token(String access_token) { - this.access_token = access_token; + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; } @Override public String toString() { - return access_token + " " + token_type + " " + refresh_token + " "; + return accessToken + " " + tokenType + " " + refreshToken + " "; } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/ApiApplicationKey.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/ApiApplicationKey.java index d66b4691fb8..7a00854a890 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/ApiApplicationKey.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.authhandler/src/main/java/org/wso2/carbon/device/application/mgt/auth/handler/util/dto/ApiApplicationKey.java @@ -27,23 +27,23 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class ApiApplicationKey { @XmlElement - private String client_id; + private String clientId; @XmlElement - private String client_secret; + private String clientSecret; public String getConsumerKey() { - return this.client_id; + return this.clientId; } - public void setClient_id(String consumerKey) { - this.client_id = consumerKey; + public void setClientId(String consumerKey) { + this.clientId = consumerKey; } public String getConsumerSecret() { - return this.client_secret; + return this.clientSecret; } - public void setClient_secret(String consumerSecret) { - this.client_secret = consumerSecret; + public void setClientSecret(String consumerSecret) { + this.clientSecret = consumerSecret; } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/authHandler.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/authHandler.js index f5941423d46..111027a2dc5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/authHandler.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/src/main/resources/publisher/src/api/authHandler.js @@ -43,9 +43,9 @@ class AuthHandler { login_promise.then(response => { console.log(response); const userName = response.data.userName; - const validityPeriod = response.data.expires_in; // In seconds - const WSO2_IOT_TOKEN = response.data.access_token; - const refreshToken = response.data.refresh_token; + const validityPeriod = response.data.expiresIn; // In seconds + const WSO2_IOT_TOKEN = response.data.accessToken; + const refreshToken = response.data.refreshToken; const clientId = response.data.application_info[0].consumerKey; const clientSecret = response.data.application_info[0].consumerSecret;