Changed to camel case text.

merge-requests/7/head
Menaka Jayawardena 7 years ago
parent 9619371cab
commit a582997c80

@ -40,7 +40,7 @@ public interface AuthHandlerService {
@Path("/refresh") @Path("/refresh")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(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); @QueryParam("clientSecret") String clientSecret);
@POST @POST

@ -67,12 +67,14 @@ public class AuthHandlerServiceImpl implements AuthHandlerService {
} }
}; };
private Client disableHostnameVerification = new Client.Default(getTrustedSSLSocketFactory(), new HostnameVerifier() { private Client disableHostnameVerification = new Client.Default(getTrustedSSLSocketFactory(),
@Override new HostnameVerifier() {
public boolean verify(String s, SSLSession sslSession) { @Override
return true; public boolean verify(String s, SSLSession sslSession) {
} return true;
}); }
}
);
@POST @POST
@Path("/login") @Path("/login")
@ -116,14 +118,15 @@ public class AuthHandlerServiceImpl implements AuthHandlerService {
@Path("/refresh") @Path("/refresh")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Override @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) { @QueryParam("clientSecret") String clientSecret) {
try { try {
TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification) TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification)
.requestInterceptor(new BasicAuthRequestInterceptor(clientId, clientSecret)) .requestInterceptor(new BasicAuthRequestInterceptor(clientId, clientSecret))
.contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder()) .contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(TokenIssuerService.class, Constants.TOKEN_ENDPOINT); .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(); return Response.status(200).entity(new JSONObject(accessTokenInfo)).build();
} catch (Exception e) { } catch (Exception e) {
return Response.status(500).build(); return Response.status(500).build();
@ -131,7 +134,6 @@ public class AuthHandlerServiceImpl implements AuthHandlerService {
} }
@POST @POST
@Path("/logout") @Path("/logout")
@Override @Override

@ -18,6 +18,7 @@
package org.wso2.carbon.device.application.mgt.auth.handler.util; package org.wso2.carbon.device.application.mgt.auth.handler.util;
//TODO: Remove hardcoded localhost and ports
public class Constants { public class Constants {
public static String SCOPES = "perm:application:get perm:application:create perm:application:update " + 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 " + "perm:application-mgt:login perm:application:delete perm:platform:add perm:platform:remove " +

@ -30,54 +30,54 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class AccessTokenInfo { public class AccessTokenInfo {
@XmlElement(required = true, name = "token_type") @XmlElement(required = true, name = "tokenType")
private String token_type; private String tokenType;
@XmlElement(required = true, name = "expires_in") @XmlElement(required = true, name = "expiresIn")
private String expires_in; private String expiresIn;
@XmlElement(required = true, name = "refresh_token") @XmlElement(required = true, name = "refreshToken")
private String refresh_token; private String refreshToken;
@XmlElement(required = true, name = "access_token") @XmlElement(required = true, name = "accessToken")
private String access_token; private String accessToken;
public AccessTokenInfo() {} public AccessTokenInfo() {}
public String getToken_type() { public String getTokenType() {
return token_type; return tokenType;
} }
public void setToken_type(String token_type) { public void setTokenType(String tokenType) {
this.token_type = token_type; this.tokenType = tokenType;
} }
public String getExpires_in() { public String getExpiresIn() {
return expires_in; return expiresIn;
} }
public void setExpires_in(String expires_in) { public void setExpiresIn(String expiresIn) {
this.expires_in = expires_in; this.expiresIn = expiresIn;
} }
public String getRefresh_token() { public String getRefreshToken() {
return refresh_token; return refreshToken;
} }
public void setRefresh_token(String refresh_token) { public void setRefreshToken(String refreshToken) {
this.refresh_token = refresh_token; this.refreshToken = refreshToken;
} }
public String getAccess_token() { public String getAccessToken() {
return access_token; return accessToken;
} }
public void setAccess_token(String access_token) { public void setAccessToken(String accessToken) {
this.access_token = access_token; this.accessToken = accessToken;
} }
@Override @Override
public String toString() { public String toString() {
return access_token + " " + token_type + " " + refresh_token + " "; return accessToken + " " + tokenType + " " + refreshToken + " ";
} }
} }

@ -27,23 +27,23 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
public class ApiApplicationKey { public class ApiApplicationKey {
@XmlElement @XmlElement
private String client_id; private String clientId;
@XmlElement @XmlElement
private String client_secret; private String clientSecret;
public String getConsumerKey() { public String getConsumerKey() {
return this.client_id; return this.clientId;
} }
public void setClient_id(String consumerKey) { public void setClientId(String consumerKey) {
this.client_id = consumerKey; this.clientId = consumerKey;
} }
public String getConsumerSecret() { public String getConsumerSecret() {
return this.client_secret; return this.clientSecret;
} }
public void setClient_secret(String consumerSecret) { public void setClientSecret(String consumerSecret) {
this.client_secret = consumerSecret; this.clientSecret = consumerSecret;
} }
} }

@ -43,9 +43,9 @@ class AuthHandler {
login_promise.then(response => { login_promise.then(response => {
console.log(response); console.log(response);
const userName = response.data.userName; const userName = response.data.userName;
const validityPeriod = response.data.expires_in; // In seconds const validityPeriod = response.data.expiresIn; // In seconds
const WSO2_IOT_TOKEN = response.data.access_token; const WSO2_IOT_TOKEN = response.data.accessToken;
const refreshToken = response.data.refresh_token; const refreshToken = response.data.refreshToken;
const clientId = response.data.application_info[0].consumerKey; const clientId = response.data.application_info[0].consumerKey;
const clientSecret = response.data.application_info[0].consumerSecret; const clientSecret = response.data.application_info[0].consumerSecret;

Loading…
Cancel
Save